Code: Select all
Gui, add, button, w100 h50 default gpush, Push Me
Gui, show
return
Push()
{
enow := A_tickcount
keywait lbutton
keywait enter
msgbox, 4096, Duration,% A_tickcount - enow
exitapp
}
Code: Select all
Gui, add, button, w100 h50 default gpush, Push Me
Gui, show
return
Push()
{
enow := A_tickcount
keywait lbutton
keywait enter
msgbox, 4096, Duration,% A_tickcount - enow
exitapp
}
Code: Select all
; This script determines the duration of activating (holding) a GUI button
#Requires AutoHotkey v1.1.33
Global start
WM_KEYDOWN := 0x0100
WM_KEYUP := 0x0101
WM_LBUTTONDOWN := 0x0201
WM_LBUTTONUP := 0x0202
Gui Font, s10
Gui Add, Button, w230 Default, OK
Gui Show,, Test
OnMessage(WM_KEYDOWN , "WM_KEYDOWN")
OnMessage(WM_KEYUP , "WM_KEYUP")
OnMessage(WM_LBUTTONDOWN, "WM_KEYDOWN")
OnMessage(WM_LBUTTONUP , "WM_KEYUP")
Return
WM_KEYDOWN(wParam, lParam) {
keyName := GetKeyName("VK" Format("{:x}", wParam))
If (keyName = "LButton") {
MouseGetPos,,,, ctl
If !Instr(ctl, "Button")
Return
}
If !start && keyName ~= "i)^(Space|LButton|Enter)$" {
start := A_TickCount
SoundBeep 1500
}
}
WM_KEYUP(wParam, lParam) {
If start {
elapsed := A_TickCount - start
start := 0
MsgBox 64, Elapsed time, % elapsed " ms"
}
}