Why doesn't my ControlClick work when my mouse sidebuttons are pressed?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Anonymiss
Posts: 17
Joined: 31 Oct 2021, 10:24

Why doesn't my ControlClick work when my mouse sidebuttons are pressed?

Post by Anonymiss » 29 Jan 2022, 03:36

Here is the code.

Code: Select all

SetControlDelay -1
sleep 25
ControlClick, x1038 y1002, App,,,, NA
The app I'm using has a submit button that has a tooltip that pops up when the mouse hovers over it. Without holding the side buttons, it works absolutely fine. Pressing my hotkey just presses the mouse at the correct coordinates.

However, when holding down either mouse sidebuttons (xbutton1 or xbutton2), I actually see the tooltip popping up indicating that the cursor is at the right spot but the click itself never goes through. What could be the reason why?

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: Why doesn't my ControlClick work when my mouse sidebuttons are pressed?

Post by boiler » 29 Jan 2022, 06:11

It might be because a WM_LBUTTONDOWN message is sent to your app and it is accepting a button click when the wParam contains the value 0x0001 (MK_LBUTTON), but it also contains either 0x0020 (MK_XBUTTON1) or 0x0040 (MK_XBUTTON2), so it doesn’t act because the parameter is 0x0021 or 0x0041. I didn’t look at the AHK source, but maybe when executing ControlClick, it checks the physical status of the other mouse buttons and sets the wParam accordingly when sending WM_LBUTTONDOWN.

In case something like that is happening, instead of ControlClick, you might try sending WM_LBUTTONDOWN yourself via PostMessage with 0x0001as the wParam (and the click location as the lParam):

Code: Select all

PostMessage, 0x0201, 0x0001, (1002 << 16) | 1038,, App
If your window’s client area does not start at 0,0 in its window, then change the above coordinates to be relative to the client area.

I am guessing there will be no difference, but it’s worth a shot.

Anonymiss
Posts: 17
Joined: 31 Oct 2021, 10:24

Re: Why doesn't my ControlClick work when my mouse sidebuttons are pressed?

Post by Anonymiss » 29 Jan 2022, 11:43

boiler wrote:
29 Jan 2022, 06:11
It might be because a WM_LBUTTONDOWN message is sent to your app and it is accepting a button click when the wParam contains the value 0x0001 (MK_LBUTTON), but it also contains either 0x0020 (MK_XBUTTON1) or 0x0040 (MK_XBUTTON2), so it doesn’t act because the parameter is 0x0021 or 0x0041. I didn’t look at the AHK source, but maybe when executing ControlClick, it checks the physical status of the other mouse buttons and sets the wParam accordingly when sending WM_LBUTTONDOWN.

In case something like that is happening, instead of ControlClick, you might try sending WM_LBUTTONDOWN yourself via PostMessage with 0x0001as the wParam (and the click location as the lParam):

Code: Select all

PostMessage, 0x0201, 0x0001, (1002 << 16) | 1038,, App
If your window’s client area does not start at 0,0 in its window, then change the above coordinates to be relative to the client area.

I am guessing there will be no difference, but it’s worth a shot.
Hi Boiler, thanks for the extremely helpful response. Unfortunately it didn't work - I'll attempt another solution like releasing the side buttons (XButton1 up) for example then.

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: Why doesn't my ControlClick work when my mouse sidebuttons are pressed?

Post by boiler » 29 Jan 2022, 12:35

I assume you’re using a valid WinTitle in place of App. Also remember that you may need to change the x and especially y coordinates to be relative to the client area of the window when using PostMessage.

What you suggested sounds like a good idea.

Post Reply

Return to “Ask for Help (v1)”