How can I set the key state to "up" without effecting the native function?
The code below displays the current time in a tooltip when you hold the back button on the mouse for more than 500 milliseconds.
The Problem: When you release the button, the native "Back" function will proceed.
The Question: How can I set the key state to "up" without effecting the native function?
Code: Select all
#SingleInstance Force
SetBatchLines -1
~XButton1::
If (A_PriorHotkey "XButton1" AND A_TimeSincePriorHotkey < 500)
{
GoTo, SubTime
}
SubTime:
;~XButton1:: ; ~ allows native function as I need the back button to work.
Loop
{
CurentTime := SubStr(A_Now,-4)
Tooltip, %CurentTime% ; Display the curent date & time in tooltip.
GetKeyState, state, XButton1, P ; Check to see if XButton1 is depressed.
sleep 250 ; sleep for one quarter second.
If State = U ; If XButton1 is up (not depressed).
{{
Tooltip, ; Turns Tooltip off.
break ; Break the loop.
}}
}
return