2011-11-05 3 views
3

AutoIt에서 스크립트를 일시 중지하는 데 사용할 수있는 기능은 무엇입니까?AutoIt에서 프로그래밍 방식으로 스크립트를 일시 중지 하시겠습니까?

는 내가 같이 잠을 사용할 수 있습니다 알고

Func TogglePause() 
    $Paused = NOT $Paused 
    While $Paused 
     sleep(100) 
     ToolTip('Script is "Paused"',0,0) 
    WEnd 
    ToolTip("") 
EndFunc 

그러나 AutoIt이 구현 된 일시 정지하는 기능이있다?

+3

내장 된 일시 중지 기능에서 기대하는 것을 이해하지 못합니다. AutoIt에서 Sleep 기능은 설정된 시간 동안 작동하는 Pause 기능입니다. 루프에서는 영원히 작동합니다. 멈춤 기능은 무엇을해야합니까? –

답변

3

수면은 이미 AutoIt의 "일시 중지"기능입니다.

스크립트를 일시 중지하는 다른 유일한 방법은 디버그 모드에서 트레이시 콘을 클릭하는 것입니다.

2

항상 다음 방법을 사용할 수 있습니다. 나는 그것이 가장 효율적이라고 생각한다.

HotKeySet("{F8}", "StartScript") 

While 1 
While $script = True 
MAIN SCRIPT HERE 
    WEnd 
WEnd 

Func StartScript() ; Functions are normally placed last, making it easier to browse the code. 

    If $script = False Then 
     $script = True 
     ToolTip("Runing|Press F8 to Stop",200,100,"Script Name",1,2) 
     Sleep(2000) 
     ToolTip("") 
    Else 
     $script = False 
     ToolTip("Stoped|Press F8 to Start",200,100,"Script Name",1,2) 
     Sleep(2000) 
     ToolTip("") 
    EndIf 
EndFunc ; ==> StartScript 
2

저는 항상 단축키와 기능을 사용하여 스크립트를 일시 중지했습니다. 아래 예제를 확인하십시오!

; 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 

이 당신의 질문에 대답! 우려되는 점이 있으면 제 게시물에 의견을 말하십시오. 답변을 위해 최선을 다할 것입니다!

관련 문제