ExitLoop bricht schleife ab

04/01/2016 22:10 Premiumlike#1
Hi jungs ich hab da ein Problem soweit Funktioniert mein Tool hier mal der Code

PHP Code:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 GUICreate("Farm Bot"452104192124)
$Button1 GUICtrlCreateButton("Start"20812741)
$Button2 GUICtrlCreateButton("Stop"160812741)
$Button3 GUICtrlCreateButton("Beenden"300812741)
$Label1 GUICtrlCreateLabel("Farm Bot by Siverbot"806430428)
GUICtrlSetFont(-1144000"MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg 
GUIGetMsg()
    Switch 
$nMsg
        
Case $GUI_EVENT_CLOSE
            
Exit
        Case 
$Button1
            
while 1
                Send
("{LWIN}")
                
sleep(2000)
                If 
$Button2 Then ExitLoop
                
If $Button3 Then ExitLoop
            WEnd
        
Case $Button2
            
While 2
                sleep
(100)
                If 
$Button1 Then ExitLoop
                
If $Button3 Then ExitLoop
            WEnd
        
Case $Button3
            
Exit 0
    
EndSwitch
WEnd 
Was soll es Tuen ?
Wenn ich Start drücke soll er alle 2 Sekunden die Windows Taste Drücken.
Wenn ich Stop Drücke soll er aufhören die Windows Taste zu Tätigen.
Wenn ich auf Beenden Klicke soll sich das Programm schließen.
soweit so gut an sich Funktioniert es auch nur Funktionieren die Schleifen nicht heißt er drückt nur einmal die Windows Taste und bricht dann ab.
Jemand eine Idee ?
04/01/2016 23:26 elmarcia#2
Use a flag instead
04/01/2016 23:55 M3mphizzt#3
@elmarcia bec i tested ur script and it gived me a error i overwritet it a bit ;P
PS. u need to click 2 times on stop ...

04/02/2016 02:00 elmarcia#4
Yeah haven't tested i forgot i named it started, and since the sleep time is 2 secs then pressing stop should fail because it's sleeping not registering messages :)
04/02/2016 18:52 Moneypulation#5
PHP Code:
If $Button2 Then ExitLoop 
Button2 liefert kein boolschen Wert zurück sondern eine ControlID. Du musst, wie in der äußeren Schleife mit GUIGetMsg() = $Button2 abfragen. Da du aber einen Sleep in der Schleife hast, weiß ich nicht wie genau wie AutoIt das behandelt. Alternativen dazu wären HotKeys oder [Only registered and activated users can see links. Click Here To Register...]