KeyWait Fails with XButton1 and XButton2

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
anotherautohotkeyusr
Posts: 21
Joined: 27 Oct 2015, 18:45

KeyWait Fails with XButton1 and XButton2

16 Oct 2019, 21:52

AutoHotkey v1.1.31.01 Unicode 64-bit
Windows 10 64-bit v1903 build 18362.418

Is this a bug, or my stupidity? KeyWait seems to ignore the key state for XButtonx.

Here's the test code, executed with no other scripts in memory:

Code: Select all

If Not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+
   ExitApp
}

#Persistent
#SingleInstance Force
#NoEnv
#InstallKeybdHook
#InstallMouseHook
#MaxThreadsPerHotkey 1
#MaxThreadsBuffer Off
#KeyHistory 1000
#MaxHotKeysPerInterval 200
SetTitleMatchMode 2
SetTitleMatchMode Slow
SendMode Input
DetectHiddenWindows, On
OnExit, QUIT

#IfWinActive, ahk_class AutoHotkey
    $XButton1::
        KeyWait, XButton1, T1
        If ( ErrorLevel != 0 )
        {
            MsgBox, Long click
        }
        Else
        {
            MsgBox, Short click
        }
    Return
#IfWinActive

QUIT:
ExitApp
Here's the Key history:

Code: Select all

A2  01D	 	d	0.03	LControl
4B  025	 	d	0.00	k
4B  025	 	u	0.09	k
A2  01D	 	u	0.09	LControl
74  03F	 	d	0.28	F5
74  03F	 	u	0.14	F5
05  000	h	d	1.88	XButton1
05  000	h	u	9.20	XButton1
74  03F	 	d	0.66	F5
Even though XButton1 has been held down for 9.20 seconds, KeyWait returns 0 immediately after XButton1 is pressed. Only the "Short click" message is displayed. KeyWait works as documented when changing XButton1 to LButton or RButton.
Attachments
KeyWait_XButton1_test.ahk
(721 Bytes) Downloaded 44 times
Last edited by anotherautohotkeyusr on 17 Oct 2019, 07:08, edited 1 time in total.
gregster
Posts: 9000
Joined: 30 Sep 2013, 06:48

Re: KeyWait Fails with XButton1 and XButton2

16 Oct 2019, 23:18

So far, I can't reproduce it. It shows here 'short click' or 'long click', depending on how long I hold XButton1.
(Latest AHK version on Win10... well, I didn't run it as admin, but I don't think that's the reason)

Is this your only running and complete script ?
anotherautohotkeyusr
Posts: 21
Joined: 27 Oct 2015, 18:45

Re: KeyWait Fails with XButton1 and XButton2

17 Oct 2019, 07:12

gregster wrote:
16 Oct 2019, 23:18
So far, I can't reproduce it. It shows here 'short click' or 'long click', depending on how long I hold XButton1.
(Latest AHK version on Win10... well, I didn't run it as admin, but I don't think that's the reason)

Is this your only running and complete script ?
Thank you for your reply gregster! I initially was working on adding something to my library, which was not working as expected. The above script is a test script I put together, to ensure there was nothing else interfering with this function. The above script was executed alone, with no other scripts running.
anotherautohotkeyusr
Posts: 21
Joined: 27 Oct 2015, 18:45

Re: KeyWait Fails with XButton1 and XButton2

19 Oct 2019, 21:33

So... when Logitech Options is running, the issue occurs.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 200 guests