This script works great, detects keys pressed, but the subroutine to detect right mouse movement, disables settimer
Running the script, press any key, the variables in the settimer reset perfectly when a keys detected, but if you use the right mouse button, the rbuttn subroutine disables the settimer, no idea why the timer doesnt resume ...
code :
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
x:=0
msgbox press a few keys, & then hold down & move around right mouse button, settimer should stop updating
SetTimer, timerx, 50
gosub wx
wx:
{
loop
{
GetKeyState, state, RButton ;
if state = D
{
gosub rbuttn
return
}
Input, SingleKey, L1, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}
{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}
{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
tooltip %x% %SingleKey%
sleep,100
;SetTimer, timerx, 50
if SingleKey!=
{
;sleep 1000
;msgbox %x% %SingleKey%
x:=0
;gosub wx
}
}
return
timerx:
{
x++
GetKeyState, state, RButton ;
if state = D
{
gosub rbuttn
return
}
;tooltip %x% %SingleKey%
}
return
}
return
rbuttn:
{
xsl:=0
loop
{
xsl++
MouseGetPos, xpos, ypos
xs%xsl%=%xpos%
ys%xsl%=%ypos%
a:=xs%xsl%
b:=ys%xsl%
tooltip a%a% b%b%
sleep 100
GetKeyState, state, RButton
if state = U
{
tooltip rb up
;x:=0
;reload
gosub wx
return
}
}
return
}
esc::exitapp
f1::reload