How To Get Onmessage On Any Window Not Just The Current GUI

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Roonyroo
Posts: 36
Joined: 29 Jan 2014, 20:29

How To Get Onmessage On Any Window Not Just The Current GUI

04 Apr 2014, 04:56

I've found a great script, but cant figure out how to get the script to detect keys pressed from any window, not just the current gui

It uses Onmessage, which i'm not familiar with

I basically need to know how to get the script to detect keys in any window,

Also how to specify detect keys only from a window labelled 1a, for example

The script im using ...

Code: Select all

SetFormat, Integer, Hex
Gui +ToolWindow -SysMenu +AlwaysOnTop
Gui, Font, s14 Bold, Arial
Gui, Add, Text, w100 h33 vSC 0x201 +Border, {SC000}
Gui, Show,, % "// ScanCode //////////"
 Clipboard =


Loop 
{
  OnMessage( 255+A_Index, "ScanCode" ) ; 0x100 to 0x108
tooltip not pressed

Return

ScanCode( wParam, lParam ) {
 Clipboard := "SC" SubStr((((lParam>>16) & 0xFF)+0xF000),-2) 

GuiControl,, SC, %Clipboard%

tooltip pressed

}
}
esc::exitapp 
nSane

Re: How To Get Onmessage On Any Window Not Just The Current

04 Apr 2014, 11:25

OnMessage isn't going to work for windows not created by the current process.

You're going to have to use a Windows hook. Google SetWindowsHookEx (specifically the CBTHook). There's some AHK examples floating around.
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: How To Get Onmessage On Any Window Not Just The Current

04 Apr 2014, 17:15

CBT hooks require a callback function in an external DLL, and besides, are inappropriate for monitoring keyboard events.

You probably want a keyboard hook. Search the forums for WH_KEYBOARD_LL.

Or use the Input command, which utilizes AutoHotkey's keyboard hook. Or use hotkeys...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: dra3th, Mateusz53, Rohwedder, Spawnova and 259 guests