我有一个脚本推动" k"循环中的按钮。我在" q"上添加了暂停按钮。 我也想要" w"暂停脚本。但我不想要" w"开始我的脚本。这可能吗?
Global $UnPaused
HotKeySet("q", "TogglePause")
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{.}", "Terminate")
While 1
Sleep(100)
WEnd
Func TogglePause()
$UnPaused = NOT $UnPaused
While $UnPaused
Send("k")
WEnd
EndFunc
Func Terminate()
Exit 0
EndFunc
答案 0 :(得分:0)
我建议重新安排你的代码&引入Pause()函数以简化操作:
Global $UnPaused=false;
HotKeySet("q", "Pause")
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{.}", "Terminate")
While 1
if $UnPaused Then
Send("k");
Else
Sleep(100)
EndIf
WEnd
Func Pause()
$UnPaused = False
EndFunc
Func TogglePause()
$UnPaused = NOT $UnPaused
EndFunc
Func Terminate()
Exit 0
EndFunc
如果您不想在暂停时捕获热键,请举例说明:
Global $UnPaused=false;
HotKeySet("q", "Pause")
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{.}", "Terminate")
HotKeySet("w", "Pause")
While 1
if $UnPaused Then
HotKeySet("w", "Pause")
Send("k");
Else
HotKeySet("w")
Sleep(100)
EndIf
WEnd
Func Pause()
$UnPaused = False
EndFunc
Func TogglePause()
$UnPaused = NOT $UnPaused
EndFunc
Func Terminate()
Exit 0
EndFunc