嘿,我正在尝试创建一个ahk脚本,它将允许我按一个键"q“,并让它切换"e”键来发送"o“或"p”,这取决于变量"count“。我有一些工作,唯一的问题是,我不能得到"q“的关键工作。当我按下"q“键时,什么都不会出现,尽管"e”键确实按我想要的方式切换。
count = 1
q::
If (count = 1) {
count = 2
MsgBox Count is set to 2
return
} else if (count = 2) {
count = 1
MsgBox Count is set to 1
return
}
e::
If (count = 1) {
Send o
return
}
If (count = 2) {
Send p
return
}
Escape::
ExitApp
Return
发布于 2018-11-22 07:42:53
若要通过按键或键组合在两个不同选项之间切换,请使用:=运算符在true(1)和false(0)之间切换变量的值
toggle := 1 ; true (Option 1)
MsgBox Option 1: "e" to "o"
$q:: ; $ prevents the key from triggering itself
toggle := !toggle
If (toggle)
MsgBox Option 1: "e" to "o"
else
MsgBox Option 2: "e" to "p"
return
$e::
If (toggle)
Send o
else
Send p
return
若要增加变量的值,请使用++运算符:
count = 0
$q::
count++
If (count = 1)
MsgBox Count is set to 1
else
If (count = 2)
MsgBox Count is set to 2
else {
count = 1 ; reset
MsgBox Count is set to 1
}
return
$e::
If (count = 1)
Send o
If (count = 2)
Send p
return
https://stackoverflow.com/questions/53423686
复制相似问题