저는 항상 단축키와 기능을 사용하여 스크립트를 일시 중지했습니다. 아래 예제를 확인하십시오!
; Create a hot key. I'm using the "Pause/Break" key typically located near the number pad on the keyboard. The keycode for this key is simply "{PAUSE}"
HotKeySet("{PAUSE}", "togglePause")
; Create a Boolean (True of False variable) to tell your program whether or not your program is paused or unpaused. Set it equal to 'False' so the script is running by default.
global $isPaused = False
; Create the togglePause function to stop/start the script
Func togglePause()
; When this function is initiated, the code on the next line 'toggles' the variable to True/False. If the script is unpaused (the $isPaused variable is set to 'False') then the next line will change it to 'True' and vice versa.
$isPaused = NOT $isPaused
; Create a while loop to stall the program
; The line below is the same thing as "While $isPaused == True"
While $isPaused
; This code will run constantly until the $isPaused variable is set to 'True'. To make the script do nothing, simply add a sleep command.
Sleep(100)
WEnd
EndFunc
이 방법은 단순히 'togglePause를 호출하여이 프로그램이 일시 중지 될 수있다 (이 경우, 일시 정지/브레이크 버튼) 핫 키 또는 프로그램을 눌러 수행 할 수 있기 때문에 이동하는 환상적인 방법입니다 '기능. 예를 들어
: 나는 희망
; Create a hot key. I'm using the "Pause/Break" key typically located near the number pad on the keyboard. The keycode for this key is simply "{PAUSE}"
HotKeySet("{PAUSE}", "togglePause")
; Create a Boolean (True of False variable) to tell your program whether or not your program is paused or unpaused. Set it equal to 'False' so the script is running by default.
global $isPaused = False
MsgBox(0,"Unpaused", "You are able to see this because the program is unpaused!")
; PRETEND LIKE THERE IS A BUNCH OF CODE HERE!
MsgBox(0,"Pausing", "The script will automatically be paused once this dialog closes. Press the pause/break key to unpause!")
togglePause()
Sleep(500)
MsgBox(0,"Ta-Da!", "The script has been manually unpaused!")
; Create the togglePause function to stop/start the script
Func togglePause()
; When this function is initiated, the code on the next line 'toggles' the variable to True/False. If the script is unpaused (the $isPaused variable is set to 'False') then the next line will change it to 'True' and vice versa.
$isPaused = NOT $isPaused
; Create a while loop to stall the program
; The line below is the same thing as "While $isPaused == True"
While $isPaused
; This code will run constantly until the $isPaused variable is set to 'True'. To make the script do nothing, simply add a sleep command.
Sleep(100)
WEnd
EndFunc
이 당신의 질문에 대답! 우려되는 점이 있으면 제 게시물에 의견을 말하십시오. 답변을 위해 최선을 다할 것입니다!
내장 된 일시 중지 기능에서 기대하는 것을 이해하지 못합니다. AutoIt에서 Sleep 기능은 설정된 시간 동안 작동하는 Pause 기능입니다. 루프에서는 영원히 작동합니다. 멈춤 기능은 무엇을해야합니까? –