2017-01-29 9 views
-2

현재 AutoIt에 프로그램이 설정되어 있습니다. 이 코드뿐만 아니라, 내 질문에 대답하는 것이 유용 할 수 있습니다 몇 가지 메모로 작성 무슨이다 :이 질문을 위해서AutoIt에서 "Q"버튼을 누르면 프로그램을 멈추게하려면 어떻게해야합니까?

;File with data is pw.txt 
$fh = FileOpen("pw.txt") 
;Loops 5 times, every time it loops $attempt should equal the next line of pw.txt 
For $i = 1 To 10 
$attempt = FileReadLine($fh) 
MouseClick("left");MouseClick("left",711,256) 
Sleep(700) 
Send($attempt);Enters whatever is in $attempt variable 
Sleep(700) 
Send("{enter}") 
Sleep(700) 
MouseClick("left") 
Sleep(700);Once first loop is finished, second loop begins. The only thing that is different is what is entered ($attempt) 
Next 
FileClose("pw.txt");After finished looping, file closes. 

를, 그래서 후 $ 전 = 10, 10 루프 카운트를 설정 (루프가 10 번 반복 된 후에도) 프로그램은 계속 활성화되지만 아무 작업도 수행되지 않습니다.

사용자가 키보드의 "Q"버튼을 누르면 내 프로그램이 멈추고 더 이상의 작업이 수행되지 않도록하려는 것입니다. (프로그램을 완전히 닫고 루프를 중지하고 싶지는 않습니다) . 가급적이면, 다음에 프로그램을 실행할 때 루프가 1에서 시작되도록하고 싶습니다.

예를 들어 루프 4에 있었고 "Q"버튼을 누르면 루프가 멈추었습니다. "F5"버튼을 클릭하여 프로그램을 다시 실행하면 루프 1에있게됩니다.

도움이 될 것입니다! 감사!

+1

HotKeySet – Richard

답변

0

timed 루프를 반복해서 실행할 수있는 메인 루프가 필요합니다. 또한 실행을위한 함수가 필요하며 단축키라고하는 단축 루프를 중지해야합니다.

HotKeySet('q', '_stopLoop') 
HotKeySet('{F5}', '_runLoop') 
HotKeySet('^!e', '_exit') ; (Ctrl+Alt+e) required to stop the main loop 
Global $iLoopCounter 

; start your loop now 
_runLoop() 


; you need a main loop 
While True 
    Sleep(10) 
WEnd 

Func _exit() 
    Exit 
EndFunc 

Func _MyLoop() 
    While $iLoopCounter < 10 
     $iLoopCounter += 1 
     ; your loop code here 

     ;==================================== for demonstration 
     ConsoleWrite('$iLoopCounter: ' & $iLoopCounter & @CRLF) 
     Sleep(1000) 
     ;====================================================== 

    WEnd 
EndFunc 

Func _runLoop() 
    $iLoopCounter = 0 
    _MyLoop() 
EndFunc 

Func _stopLoop() 
    $iLoopCounter = 10 
EndFunc