Code: Select all
Morse(Timeout := 150, Count := 3)
{
Global Pattern := ""
Win := WinExist("A")
RegExMatch(Hotkey := A_ThisHotkey, "\W$|\w*$", &Key)
CoordMode("Mouse", "Screen")
MouseGetPos(&X1, &Y1, &Win1)
Loop (Count) {
T := A_TickCount
ErrorLevel := !KeyWait(Key[0])
Pattern .= A_TickCount - T > Timeout
ErrorLevel := !KeyWait(Key[0], "DT" Timeout / 1500)
MouseGetPos(&X2, &Y2, &Win2)
; Skip the operation for Win key if another key pressed!
IF (InStr(Hotkey, "Win") And (Win Key[0] Hotkey Win1) != (WinExist("A") A_PriorKey A_ThisHotkey Win2))
{
SendInput("{LWin Down}" A_PriorKey "{LWin Up}") ; Sending the key combination to OS to run
Exit
}
If ErrorLevel
return Pattern
}
}
LWin::
{
hotkey := SubStr(A_ThisHotkey, 2)
Patterm := Morse()
Switch Patterm
{
Case "0":
MsgBox(hotkey " " Patterm)
Case "1":
MsgBox(hotkey " " Patterm)
Default:
MsgBox(hotkey " " Patterm)
}
Return
}
I don't know how to prevent that.
Appreciate any help