RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Enterprise
Expertise: Beginner
Apr 19, 2007

Capturing Mouse Events with a Transparent Window

In my recent article on the AutoHotKey scripting language, I advocated using hotkeys to address different domains separated into their own scripts. Of course, when you start a script up you might have difficulty remembering what hotkeys and actions the script allows. Luckily, AutoHotKey allows you to make GUIs quickly. Place the following code in your AutoHotKey script:

WinKill, HotKeysTutor
Gui, +AlwaysOnTop -SysMenu
Gui Color, F0F8FF                     
Gui +E0x20   

Gui Show, X650 Y0 W200 H100, HotKeysTutor ;
Gui, Add, Text,,"Delete Key:"
Gui, Add, Text,,"+ 2 = select two mails"
Gui, Add, Text,,"+ Down = select number mails user inputs"
WinGet ID, ID, A                   ; ...with HWND/handle ID
WinSet Transparent,150,ahk_id %ID%
This will render a transparent floating window at the X coordinate, 650 pixels to the right on your screen, and a Y coordinate, 0 pixels down. Its width and height will be 200 X 100, and the title of the Window will be HotKeysTutor.

The text in the window tells you what hotkeys your script supports. Since you know what these are, write them using the GUI, Add, and Text commands.

Note: At the very top, the script uses the command WinKill, this will destroy any window named HotKeysTutor when the script loads. Thus, if you have numerous scripts, you can put it into any script and customize it for that script and then destroy it when you load a new script.

With very little effort, you can create a function in your scripts to write the window for any particular script and make it creatable by a hotkey.

Bryan Rasmussen
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date