Home of Macro Scheduler - Macro Tools and Automation Software
Marcus’ Macro Blog
Mostly tips, tutorials, articles and news about Macro Scheduler & Windows Automation
Download Macro Scheduler
Free 30 Day Trial

EXEs and Hotkeys

November 20th, 2007 by Marcus Tettmar

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 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?

Method 1 - make the EXE itself listen for the hot-key:

Use OnEvent to create a KEY_DOWN event handler to watch for the hot-key sequence:

OnEvent>KEY_DOWN,G,5,DoMacro

Label>Idle_Loop
Wait>0.02
Goto>Idle_Loop

SRT>DoMacro
..
.. Your Code Here
..
End>DoMacro

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 - 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’s own fancy icon in the task bar.

See the documentation for the OnEvent function for more info on how to trap different keystrokes.

Method 2 - Let Windows do the work:

Don’t tell me - all these years using Microsoft Windows and you didn’t realise that keyboard shortcuts can be assigned to shortcuts?

So just create a desktop shortcut to your compiled EXE. Right click on the desktop shortcut and select properties. Notice the “Shortcut key” field. Press the keys you want to use to trigger the EXE. Press Ok. Sorted.

Bookmark this at:
    Bookmark EXEs and Hotkeys at del.icio.us    Digg EXEs and Hotkeys at Digg.com    Bookmark EXEs and Hotkeys at Spurl.net    Bookmark EXEs and Hotkeys at Simpy.com    Bookmark EXEs and Hotkeys at NewsVine    Blink this EXEs and Hotkeys at blinklist.com    Bookmark EXEs and Hotkeys at Furl.net    Bookmark EXEs and Hotkeys at reddit.com    Fark EXEs and Hotkeys at Fark.com    Bookmark EXEs and Hotkeys at YahooMyWeb

Leave a Reply

Sitemap | Privacy Policy | © MJT Net Ltd 1997-2008 All Rights Reserved.

Windows Vista and the Windows logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.