{"id":218,"date":"2007-11-20T23:09:55","date_gmt":"2007-11-20T23:09:55","guid":{"rendered":"http:\/\/www.mjtnet.com\/blog\/2007\/11\/20\/exes-and-hotkeys\/"},"modified":"2007-11-20T23:09:55","modified_gmt":"2007-11-20T23:09:55","slug":"exes-and-hotkeys","status":"publish","type":"post","link":"https:\/\/www.mjtnet.com\/blog\/2007\/11\/20\/exes-and-hotkeys\/","title":{"rendered":"EXEs and Hotkeys"},"content":{"rendered":"<p>Something that comes up now and then is whether or not compiled Macro Scheduler macros can respond to hot-keys.  Macro Scheduler itself lets you assign system-wide hot-keys to macros so that when you hit that key combination, no matter where you are in Windows, the macro will be fired.<\/p>\n<p>Some people want to be able to distribute compiled macros (EXEs) to their friends and colleagues and have those EXEs respond to hot-keys in the same way.  Something has to be running in order to listen for the hot-key and act on it.  In the case of regular old Macro Scheduler that is Macro Scheduler itself.  So how do we achieve it with a compiled macro?<\/p>\n<p><strong>Method 1 &#8211; make the EXE itself listen for the hot-key:<\/strong><\/p>\n<p>Use OnEvent to create a KEY_DOWN event handler to watch for the hot-key sequence:<\/p>\n<blockquote><p>\nOnEvent>KEY_DOWN,G,5,DoMacro<\/p>\n<p>Label>Idle_Loop<br \/>\n  Wait>0.02<br \/>\nGoto>Idle_Loop<\/p>\n<p>SRT>DoMacro<br \/>\n..<br \/>\n.. Your Code Here<br \/>\n..<br \/>\nEnd>DoMacro\n<\/p><\/blockquote>\n<p>The above will run indefinitely and whenever CTRL+ALT+G is pressed the macro code in the DoMacro subroutine will be fired.   Clearly the macro has to be running all the time to listen for the hotkey &#8211; after all, something has to listen for it.  So you could have the EXE run on startup by adding a shortcut to the Startup folder for example.  Perhaps also compile the EXE with the \/NOSYSTRAY and \/HIDE parms so that the EXE is not visible when it runs.  Or, better, compile with a custom icon so that your EXE has it&#8217;s own fancy icon in the task bar.<\/p>\n<p>See the <a href=\"http:\/\/www.mjtnet.com\/OnlineHelp\/index.html?onevent.htm\">documentation for the OnEvent function<\/a> for more info on how to trap different keystrokes.<\/p>\n<p><strong>Method 2 &#8211; Let Windows do the work:<\/strong><\/p>\n<p>Don&#8217;t tell me &#8211; all these years using Microsoft Windows and you didn&#8217;t realise that keyboard shortcuts can be assigned to shortcuts?<\/p>\n<p>So just create a desktop shortcut to your compiled EXE.  Right click on the desktop shortcut and select properties.   Notice the &#8220;Shortcut key&#8221; field.  Press the keys you want to use to trigger the EXE.  Press Ok.  Sorted.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Something that comes up now and then is whether or not compiled Macro Scheduler macros can respond to hot-keys. Macro Scheduler itself lets you assign system-wide hot-keys to macros so that when you hit that key combination, no matter where you are in Windows, the macro will be fired. Some people want to be able [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,6],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/218"}],"collection":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/comments?post=218"}],"version-history":[{"count":0,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/218\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/media?parent=218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/categories?post=218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/tags?post=218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}