Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 10:11

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



ExitLoop in If-Abfrage

Discussion on ExitLoop in If-Abfrage within the AutoIt forum part of the Coders Den category.

Closed Thread
 
Old   #1

 
Moneypulation's Avatar
 
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
ExitLoop in If-Abfrage

Edit real problem:

Code:
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
	Case $CheckboxOnOff
	   $On = True
    Case $GUI_EVENT_CLOSE
	   Exit
	Case $AA = 0
	   If GUICtrlRead($CheckboxAA) = $GUI_CHECKED Then
	   WinSetState("MWarTool","",@SW_MINIMIZE)
	   While Sleep(30)
		  ToolTip("Go to the center of your Attack Button and press F2")
		  If _IsPressed(71) Then
			 $mPos = MouseGetPos()
			 $Color = PixelGetColor($mPos[0],$mPos[1])
			 MsgBox(0,"",$AA)
			 $AA = 1
			 ToolTip("")
			 WinSetState("MWarTool","",@SW_RESTORE)
			 MsgBox(0,"",$AA)
			 ExitLoop
		  EndIf
		 WEnd
	   EndIf
	EndSwitch
 WEnd
ExitLoop actually works. The part that is not working is the switch. Although I set $AA to 1 in the If statement, the script it goes again into Case $AA = 0. Why is that so? I declared on the top of the script Global $AA = 0
Moneypulation is offline  
Old 10/09/2014, 20:14   #2
 
fuso98's Avatar
 
elite*gold: 428
Join Date: Dec 2011
Posts: 2,722
Received Thanks: 2,035
Quote:
Originally Posted by moneypulation View Post
Hey,

ich versteh einfach nicht wieso ExitLoop keine "Loops" beendet, sondern die If Abfrage, in der sie ist.

Code:
Case $AA = 0
	  If _IsChecked($CheckboxAA) Then
	   WinSetState("MWarTool","",@SW_MINIMIZE)
           While Sleep(30)
                 ToolTip("Go to the center of your Attack Button and press F2")
		  If _IsPressed(71) Then
			 $mPos = MouseGetPos()
			 $Color = PixelGetColor($mPos[0],$mPos[1])
			 MsgBox(0,"",$AA)
			 Global $AA = 1
			 Global $Done = 1
			 ToolTip("")
			 
			 WinSetState("MWarTool","",@SW_RESTORE)
			 MsgBox(0,"",$AA)
			 ExitLoop (1)

		  EndIf
		  
		  If $Done = 1 Then
			 MsgBox(0,"","Test")
			 ExitLoop
		  EndIf

	   WEnd
Das mit dem $Done ist nur ein Test gewesen um zu sehen, ob die Schleife immernoch an ist (Ist nämlich eine While schleife in einer anderen While schleife). Sobald die If bedingung erfüllt wird, werden die Pixel bzw. die Farbe abgespeichert und die While Schleife sollte beendet werden aber ExitLoop bricht nur die If-Abfrage ab (Hab ich getestet) statt die Schleife zu beenden. Und mit ExitLoop (2) beendet er beide While Schleifen und mein Programm beendet sich... Hilfe ?!
If you press F2 the "if..then" that check $done will never be executed! Cause you put an exit loop before the endif.
Exit loop don't work with if...endif but only with while, for and do loop

Maybe i didn't understood your question. Could you try to speak english?
fuso98 is offline  
Old 10/09/2014, 20:15   #3
 
alpines's Avatar
 
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
Hmm.
Code:
While 1
	If 1=1 Then
		MsgBox(0,0,0)
		ExitLoop
		MsgBox(0,0,1)
	EndIf

	MsgBox(0,0,3)
WEnd

MsgBox(0,0,2)
alpines is offline  
Old 10/09/2014, 20:28   #4

 
Moneypulation's Avatar
 
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
Quote:
Originally Posted by fuso98 View Post
If you press F2 the "if..then" that check $done will never be executed! Cause you put an exit loop before the endif.
Exit loop don't work with if...endif but only with while, for and do loop

Maybe i didn't understood your question. Could you try to speak english?
$Done is only made for test reasons. My problem is that my ExitLoop exits the If statement instead of the while loop.

Quote:
Originally Posted by alpines View Post
Hmm.
Code:
While 1
	If 1=1 Then
		MsgBox(0,0,0)
		ExitLoop
		MsgBox(0,0,1)
	EndIf

	MsgBox(0,0,3)
WEnd

MsgBox(0,0,2)
Ja bei mir geht das irgendwie nicht. Es kommt sozusagen Msgbox 0, dann 3
Moneypulation is offline  
Old 10/09/2014, 20:40   #5
 
elite*gold: 0
Join Date: Mar 2009
Posts: 7,260
Received Thanks: 33,149
Downloade dir die letzte stabile AutoIt Version (3.3.12.0).
KDeluxe is offline  
Old 10/09/2014, 20:45   #6

 
Moneypulation's Avatar
 
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
Quote:
Originally Posted by KDeluxe View Post
Downloade dir die letzte stabile AutoIt Version (3.3.12.0).
Ist bei mir 3.3.12.0

Okay I found the real problem:

Code:
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
	Case $CheckboxOnOff
	   $On = True
    Case $GUI_EVENT_CLOSE
	   Exit
	Case $AA = 0
	   If GUICtrlRead($CheckboxAA) = $GUI_CHECKED Then
	   WinSetState("MWarTool","",@SW_MINIMIZE)
	   While Sleep(30)
		  ToolTip("Go to the center of your Attack Button and press F2")
		  If _IsPressed(71) Then
			 $mPos = MouseGetPos()
			 $Color = PixelGetColor($mPos[0],$mPos[1])
			 MsgBox(0,"",$AA)
			 $AA = 1
			 ToolTip("")
			 WinSetState("MWarTool","",@SW_RESTORE)
			 MsgBox(0,"",$AA)
			 ExitLoop
		  EndIf
		 WEnd
	   EndIf
	EndSwitch
 WEnd
ExitLoop actually works. The part that is not working is the switch. Although I set $AA to 1 in the If statement, the script it goes again into Case $AA = 0. Why is that so? I declared on the top of the script Global $AA = 0
Moneypulation is offline  
Old 10/09/2014, 21:19   #7
 
butter123's Avatar
 
elite*gold: 95
Join Date: May 2011
Posts: 982
Received Thanks: 189
an der stelle ist $aa=0 eine zuweisung, die true zurück gibt. case wird benutz um eine variable ($nmsg) auf mehrere werte zu überprüfen ($checkboxonof,$guieventclose). also überprüfst du ob $nmsg = true ist. um zu überprüfen ob $aa = 0 ist musst eine neue ifabfrage machen
butter123 is offline  
Thanks
1 User
Old 10/09/2014, 21:27   #8

 
Moneypulation's Avatar
 
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
Quote:
Originally Posted by butter123 View Post
an der stelle ist $aa=0 eine zuweisung, die true zurück gibt. case wird benutz um eine variable ($nmsg) auf mehrere werte zu überprüfen ($checkboxonof,$guieventclose). also überprüfst du ob $nmsg = true ist. um zu überprüfen ob $aa = 0 ist musst eine neue ifabfrage machen
Danke für den Tipp. Hab jetzt eine If-Abfrage außerhalb des Switch's und jetzt funktionierts
Moneypulation is offline  
Old 10/09/2014, 21:35   #9
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
Quote:
Originally Posted by butter123 View Post
an der stelle ist $aa=0 eine zuweisung, die true zurück gibt.
Fast :P

$aa=0 ist an der stelle eben keine Zuweisung sondern ein Vergleich. Das Ergebnis des Vergleichs wird dann mit dem Wert im Switch-Header verglichen. Stimmen diese überein, so wird der Case ausgeführt.

Code:
$a=1
Switch False
	Case $a=1 ; True != False -> Skip this case!
		ConsoleWrite("0.o"&@CRLF)
	Case Else
		ConsoleWrite("wie erwartet"&@CRLF)
EndSwitch

Switch True
	Case $a=1 ; True == True -> Step into this case!
		ConsoleWrite("wie erwartet"&@CRLF)
	Case Else
		ConsoleWrite("0.o"&@CRLF)
EndSwitch
Semantisch Äquivalent dazu wäre zb:
Code:
$a=1
If False = ($a=1) Then
	ConsoleWrite("0.o"&@CRLF)
Else
	ConsoleWrite("wie erwartet"&@CRLF)
EndIf

If True = ($a=1) Then
	ConsoleWrite("wie erwartet"&@CRLF)
Else
	ConsoleWrite("0.o"&@CRLF)
EndIf
Quote:
Originally Posted by butter123 View Post
um zu überprüfen ob $aa = 0 ist musst eine neue ifabfrage machen
Alternativ könnte man natürlich auch mit Select statt Switch arbeiten. Dort gäbe es keine fixe Variable mit der alles verglichen wird...
lolkop is offline  
Thanks
1 User
Old 10/22/2014, 12:25   #10


 
Lawliet's Avatar
 
elite*gold: 2
Join Date: Jul 2009
Posts: 14,456
Received Thanks: 4,685
#closed
Lawliet is offline  
Closed Thread


Similar Threads Similar Threads
If Abfrage
03/17/2014 - Web Development - 0 Replies
- Hat sich erledigt #closerquest
AFK Abfrage ?
09/05/2012 - Guild Wars 2 - 4 Replies
Servus, habe grad bissel an meinem eigenen Bot rumgeschraut der nu auch laufen kann und auch das ein oder andere Event erledigt. So nun lasse ich ihn die dritte Testrunde laufen und bekomm aufeinmal ein Fenster (wie die normalen fenster wenn man mit einem NPC spricht) und dort steht " Wer ist der Moa wer ist der Mann ?" und als antwort möglichkeiten gabs Rechts , Links und in der Mitte. Dazu läuft eine art Counter runter. Ich hab aus Schock erstmal irgendwo draufgekickt. Ne minute später kam...
bot abfrage
04/08/2011 - Ragnarok Online - 4 Replies
hallo ich habe beim server wo ich bin wenn man da in iein dun is eine botabfrage dann kommt ein bild man muss die zahl eingeben und dann kann man weiter machen wenn ich es aber mit openkore machen wie soll das gehen danke für die hilfe
Exitloop Problem mit mehreren Schleifen
10/21/2009 - AutoIt - 5 Replies
Abend ! und zwar sieht mein Problem wie folgt aus: While 1=1 (das script) If...Then -hier ist das problem: ich möchte das das programm die while schleife sozusagen pausiert -dann das was gemacht werden soll



All times are GMT +1. The time now is 10:11.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.