Process Left-click AFTER the Active Window Change

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kkleinfelter
Posts: 32
Joined: 21 Dec 2018, 10:59

Process Left-click AFTER the Active Window Change

10 Sep 2019, 13:28

When I

Code: Select all

~lbutton::
    CoordMode, Mouse, Window
    MouseGetPos, mx, my, buttonHwnd
and the user clicks on a window other than the active window, the x, y, and hwnd are for the window which is losing focus and not the window which was clicked on. At least sometimes.

This *is* what the doc says: "Relative: Coordinates are relative to the active window."

Is there a way to ensure that Windows has handled the event BEFORE AutoHotkey gets it?
How can I get the X, Y, hwnd of the window which was CLICKED instead of the window which was ACTIVE?
kkleinfelter
Posts: 32
Joined: 21 Dec 2018, 10:59

Re: Process Left-click AFTER the Active Window Change

10 Sep 2019, 14:03

Well, the best I can come up with is the following. Is there a better way? Is there a drawback to my method I should be aware of?

Code: Select all

    CoordMode, Mouse, Window
    MouseGetPos, mx, my, buttonHwnd
    WinActivate, ahk_id %buttonHwnd%
    MouseGetPos, mx, my, buttonHwnd
kkleinfelter
Posts: 32
Joined: 21 Dec 2018, 10:59

Re: Process Left-click AFTER the Active Window Change

10 Sep 2019, 14:22

No, that still isn't working. I keep getting negative values for X or Y. I'm clearly not getting the X/Y coordinate relative to the clicked window because I'm clicking in the window and I'm getting things like -400
kkleinfelter
Posts: 32
Joined: 21 Dec 2018, 10:59

Re: Process Left-click AFTER the Active Window Change

15 Sep 2019, 15:13

I gave up on directly getting click coordinates relative to the *clicked* (not the active) window. My 'solution' was to get the coordinates in *screen* mode, get the origin of the window the mouse is over (in screen mode), and subtract the window origin from the mouse position. i.e. I calculated the relative position.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 386 guests