OnMessage - Receive WM_LBUTTONDOWN event?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Guest078
Posts: 23
Joined: 28 Aug 2016, 13:44

OnMessage - Receive WM_LBUTTONDOWN event?

06 Oct 2016, 11:59

Hi,

I use:

Code: Select all

OnMessage(C["MSG"]["WM_LBUTTONDOWN"], "WM_MOUSECLICKS")
in the autoexecute part of my script (the associative array contains the hex value for WM_LBUTTONDOWN) and the WM_MOUSECLICKS function outputs wParam, lParam, msg and the hwnd.

It works fine if I click anywhere inside any of my own gui window(s) but I'd like to capture this left mouse down event if the mouse is used in a different application (e.g. Windows File Explorer).

Is that possible with AHK?
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: OnMessage - Receive WM_LBUTTONDOWN event?

06 Oct 2016, 12:27

Guest078 wrote: It works fine if I click anywhere inside any of my own gui window(s) but I'd like to capture this left mouse down event if the mouse is used in a different application (e.g. Windows File Explorer).

Is that possible with AHK?
its possible but i believe you'd need to inject a dll into all processes. meaning, its not trivial. ahk's OnMessage will only monitor messages of its own process.

you could hack your way around this by implementing an ~LButton down hotkey, and checking the coordinates and window of the click with MouseGetPos

lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: OnMessage - Receive WM_LBUTTONDOWN event?

06 Oct 2016, 16:54

I wouldn't call that a hack; more like the most efficient solution. LButton hotkeys fire when AutoHotkey's mouse hook receives a WM_LBUTTONDOWN message.

Even if you want to use a hook, you don't need a dll. AutoHotkey does it without a dll. You just need to use the right hook.
drawback
Posts: 34
Joined: 11 Aug 2016, 11:31

Re: OnMessage - Receive WM_LBUTTONDOWN event?

06 Oct 2016, 17:31

Ok, thanks!

@lexikos:
Any hints how to implement this? I only need to listen for this event for a specific application (for example: Windows File Explorer)
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: OnMessage - Receive WM_LBUTTONDOWN event?

06 Oct 2016, 21:47

???
implementing an ~LButton down hotkey

Code: Select all

~LButton::
   MsgBox You clicked?
   return
If you want to restrict it to specific applications, use the MouseIsOver example.
drawback
Posts: 34
Joined: 11 Aug 2016, 11:31

Re: OnMessage - Receive WM_LBUTTONDOWN event?

07 Oct 2016, 13:45

Sorry, you're right lexikos. I though about a specialized hook but a hotkey is sufficient in this case. Me culpa!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Lamron750 and 238 guests