{"id":9688,"date":"2023-07-28T23:04:02","date_gmt":"2023-07-28T23:04:02","guid":{"rendered":"https:\/\/max-drake.cc\/?p=9688"},"modified":"2023-07-29T21:32:21","modified_gmt":"2023-07-29T21:32:21","slug":"activate-python-scripts-from-python-hotkeys","status":"publish","type":"post","link":"https:\/\/max-drake.cc\/?p=9688","title":{"rendered":"Activate Python Scripts from Python Hotkeys with Keyboard package"},"content":{"rendered":"\n<p>Following on from earlier video \u2018Activate Python Scripts from AutoHotKey V2 Hotkeys\u2019 (https:\/\/youtu.be\/QYxTI81FtWI ) I wanted to add a hotkey information help message box, so I can easily find out the hotkeys for triggering specific scripts. I find this useful when I have a lot of hotkeys and hotstrings and so I do not have to remember them all but can easily refer to them with the message box from the system tray Icon for AutoHotKeys.<br>In Python you do not have the system tray icon by default. So I needed to explore a few issues.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Activate Python Scripts from Python Hotkeys\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/JqPifb-qu7k?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><br>1.. How to close the program if using without command console<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>How to run the python script without the command console ( use file extension .pyw &amp; point to where your python.exe file is located at top line with (# ! pathto\/python.exe)<\/li>\n\n\n\n<li>How to show Help information with a list of hotkeys and what they do.<\/li>\n\n\n\n<li>How to create a system tray icon in windows for the python script<\/li>\n\n\n\n<li>How to add a tray item as a pop-up message box in python so you can refer to the script hotkeys easily<\/li>\n\n\n\n<li>How to use a shortcut.lnk file and put it in the windows startup location (found by running RUN &amp; then in run propt putting shell:startup to open file explorer in startup folder to add shortcut link.<br>Resources:<br>Python Keyboard Package &#8211; https:\/\/pypi.org\/project\/keyboard\/<br>Github &amp; Documentation for Keyboard package &#8211; https:\/\/github.com\/boppreh\/keyboard<br>You can download the files from this link:<br>https:\/\/drive.google.com\/drive\/folders\/1Gm6dMSyzs7TJ9ihuD1pu2oGcy1WTTY2P?usp=sharing<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">End comment <\/h3>\n\n\n\n<p>I was pleased with how the python script came out, I was able to replicate most of the features I use in AutoHotKeys Scripts so this would be a viable alternative for someone in a purely pythonic environment. <\/p>\n\n\n\n<p>As I&#8217;m sort of wedded to AutoHotKey I will personally stick with my earlier AutoHotKey v2 script for this process and when I write my book on python I&#8217;ll use this python method for running python scripts. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Following on from earlier video \u2018Activate Python Scripts from AutoHotKey V2 Hotkeys\u2019 (https:\/\/youtu.be\/QYxTI81FtWI ) I wanted to add a hotkey information help message box, so I can easily find out the hotkeys for triggering specific scripts. I find this useful when I have a lot of hotkeys and hotstrings and so I do not have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9689,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[204,467,42,34],"tags":[],"class_list":["post-9688","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-automation","category-coding-programming","category-productivity","category-python"],"featured_image_src":"https:\/\/max-drake.cc\/wp-content\/uploads\/2023\/07\/1mqdefault.jpg","featured_image_src_square":"https:\/\/max-drake.cc\/wp-content\/uploads\/2023\/07\/1mqdefault.jpg","author_info":{"display_name":"Max Drake","author_link":"https:\/\/max-drake.cc\/?author=1"},"_links":{"self":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/9688","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9688"}],"version-history":[{"count":2,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/9688\/revisions"}],"predecessor-version":[{"id":9691,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/9688\/revisions\/9691"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/media\/9689"}],"wp:attachment":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}