Right click with shift down, unactive window
Posted: 20 Nov 2023, 05:30
Hi, for the past several days, I've been unsuccessfully trying to send a Right-Click signal while holding down Shift to a specified window that is not in focus. I've tried different approaches, but none of them seem to work.
The script has to work only in the specified window so that I don't affect the whole system with Shift. Here are the approaches I've tried. Note that in these examples, I use the left click for testing purposes. Btw I'm sure that ahk_id is correct since left click works fine.
All of these seem to give similar result - sending left click without shift being held down, Winspector results are as follows:
^q WM_LBUTTONDOWN, WM_LBUTTONUP;
^w or ^e or ^r give same result of WM_KEYDOWN, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_KEYUP.
I'd apprecieate any kind of ideas on how to make that work.
The script has to work only in the specified window so that I don't affect the whole system with Shift. Here are the approaches I've tried. Note that in these examples, I use the left click for testing purposes. Btw I'm sure that ahk_id is correct since left click works fine.
Code: Select all
If !A_IsAdmin
Run *RunAs "%A_ScriptFullPath%"
game := 0x5706dc
WM_LBUTTONDOWN := 0x201
WM_LBUTTONUP := 0x202
MK_SHIFT := 0x0004
client_x := 200
client_y := 200
^q::
PostMessage, %WM_LBUTTONDOWN%, MK_SHIFT, (client_y << 16) | client_x, , ahk_id %game%
sleep 50
PostMessage, %WM_LBUTTONUP%, 0, (client_y << 16) | client_x, , ahk_id %game%
return
^w::
ControlSend, , {Shift Down}, ahk_id %game%
Sleep 50
ControlClick, x%client_x% y%client_y%, ahk_id %game%, , Left
sleep 50
ControlSend, , {Shift Up}, ahk_id %game%
return
^e::
PostMessage, 0x100, 0x10, 0, , ahk_id %game%
sleep 50
PostMessage, %WM_LBUTTONDOWN%, 0x1, (client_y << 16) | client_x, , ahk_id %game%
sleep 50
PostMessage, %WM_LBUTTONUP%, 0x1, (client_y << 16) | client_x, , ahk_id %game%
sleep 50
PostMessage, 0x101, 0x10, 0, , ahk_id %game%
return
^r::
SendMessage, 0x100, 0x10, 0, , ahk_id %game%
sleep 50
SendMessage, %WM_LBUTTONDOWN%, 0x1, (client_y << 16) | client_x, , ahk_id %game%
sleep 50
SendMessage, %WM_LBUTTONUP%, 0x1, (client_y << 16) | client_x, , ahk_id %game%
sleep 50
SendMessage, 0x101, 0x10, 0, , ahk_id %game%
return
^q WM_LBUTTONDOWN, WM_LBUTTONUP;
^w or ^e or ^r give same result of WM_KEYDOWN, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_KEYUP.
I'd apprecieate any kind of ideas on how to make that work.