How would I go about making hotkeys using my numpad. This is what I tried but maybe not understanding the logic. Maybe a better way? Thanks all.
This was adopted from a previous post from Laszlo!
https://autohotkey.com/board/topic/15574-morse-find-hotkey-press-and-hold-patterns/
The timeout works fine.
Code: Select all
;//////////Morse
Morse(timeout = 400) { ;
tout := timeout/1000
key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
Loop {
t := A_TickCount
KeyWait %key%
Pattern .= A_TickCount-t > timeout
KeyWait %key%,DT%tout%
If (ErrorLevel)
Return Pattern
}
}
Code: Select all
; Loop for Numpad Hotkeys
x:=0
while(x<10)
{
x++
Hotkey, Numpad[x], MyLabel[x]
Mylabel[x]:
p := Morse()
If (p = "0")
{
side := sideA[x]
degree := degreeA[x]
Gosub, MeatA[x]
}
Else If (p = "00")
{
side := sideB[x]
degree := degreeB[x]
Gosub, MeatB[x]
}
Else If (p = "01")
{
side := sideB[x]
degree := degreeB[x]
Gosub, MeatC[x]
}
Else If (p = "011") ;Short+Long press+long press
{
MsgBox, NOT SET
}
Else
MsgBox, Press pattern %p%
Return
}
; loop for sending sandwich
a:=0
while(a<10) {
a++
MeatA[a]:
Sendinput, %degree% %side% MeatA%a%
Return
}
b:=0
while(b<10) {
b++
MeatB[b]:
Sendinput, %degree% %side% MeatB%b%
Return
}
c:=0
while(c<10) {
c++
MeatC[c]:
Sendinput, %degree% %side% MeatC%c%
Return
}++
MeatB%b%:
Sendinput, %degree% %side% MeatB%b%
Return
}
c:=0
while(c<10) {
c++
MeatC[c]:
Sendinput, %degree% %side% MeatC%c%
Return
}