GetKeyState for MouseUp

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

GetKeyState for MouseUp

07 May 2019, 00:25

Code: Select all

Onmessage(0x205,"WM_RBUTTONUP")

GUI, new, +hwndGUI_hwnd
Gui, Add, Button, x100 y100 gOk, OK


WinMove, ahk_id%GUI_hwnd%, ,300 , 300, 200, 200
Gui show
return

WM_RBUTTONUP(wparam,Lparam,msg,GUI_hwnd)
{
Rstate := GetKeyState("RButton")
msgbox % "Right MouseUp: Rstate " Rstate
ExitAPP
}

Ok:
ExitAPP
It's the same result for the middle button in the above code with WM_MButtonUP message and "MButton", but If we replace the above code for the WM_LButtonUP & "LButton", GetKeyState returns 1.
It isn't a bug, but AFAIK goes back all the way to the Windows 3.1 implementation of right button for properties in shell. The "previous state" is remembered for the left, but not for the other buttons.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: GetKeyState for MouseUp

07 May 2019, 05:31

Imstearn wrote:... but If we replace the above code for the WM_LButtonUP & "LButton", GetKeyState returns 1.
Interesting, I don't get that 1 here (AHK 1.1.30.03 U64 on Win 10):

Code: Select all

#NoEnv
; L = 0x0202, M = 0x0208, R = 0x0205
Onmessage(0x0202, "WM_LBUTTONUP")
Onmessage(0x0208, "WM_MBUTTONUP")
Onmessage(0x0205, "WM_RBUTTONUP")

Gui, New
Gui, Add, Button, x100 y100 gOk, OK
Gui, Show, w200 h200, Test
Return

GuiClose:
ExitAPP
Ok:
Return

WM_LBUTTONUP(wparam, lparam, msg, hwnd) {
   MsgBox, 0, %A_AhkVersion%, % "LButton Up: BtnState " . GetKeyState("LButton")
}
WM_MBUTTONUP(wparam, lparam, msg, hwnd) {
   MsgBox, 0, %A_AhkVersion%, % "MButton Up: BtnState " . GetKeyState("MButton")
}
WM_RBUTTONUP(wparam, lparam, msg, hwnd) {
   MsgBox, 0, %A_AhkVersion%, % "RButton Up: BtnState " . GetKeyState("RButton")
}
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

Re: GetKeyState for MouseUp

08 May 2019, 02:39

Hey @just me that's right. It now shows as 0- something must have broke here, sorry. :facepalm:
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb and 363 guests