Delta01 Posted September 17, 2007 Share Posted September 17, 2007 Hi, I'm trying to make a script for a game. I have most features working, but when i try to use another While/Wend statement in another While/Wend statement, ExitLoop doesn't close the While/Wend statement that's inside the other While/Wend statement. When i click the button in the GUI to activate the second While/Wend statement, everything freezes up. So, I thought if i added the GuiControls into the second while/wend it would work. My code is below, anybody know how i could fix it? expandcollapse popup#include <GUIConstants.au3> #include <Date.au3> Global $Pixel1 = PixelGetColor(4, 758), $stamp = TimerInit() HotKeySet("{F5}", "Terminate") HotKeySet("^m", "Minimize") HotKeySet("^s", "Maximize") HotKeySet("^k", "Kill") HotKeySet("^7", "Box") $main = GUICreate("Booya's Tools", 229, 150) $Kill = GUICtrlCreateButton("Kill SRO", 35, 12, 80, 25) $Hide = GUICtrlCreateButton("Minimize SRO", 35, 37, 80, 25) $Show = GUICtrlCreateButton("Maximize SRO", 35, 63, 80, 25) $Close = GUICtrlCreateButton("Close script", 35, 88, 80, 25) $AntiStuck = GuiCtrlCreateButton("Anti-Stuck-On", 115, 12, 80, 25) $AntiStuckOff = GuiCtrlCreateButton("Anti-Stuck-Off", 115, 37, 80, 25) $Help = GuiCtrlCreateButton("Help", 115, 62, 80, 25) $Label = GuiCtrlCreateLabel("Made by BooYA©", 140, 135) GuiSetstate() $2nd = GuiCreate("Help File", 300, 680) $Close2 = GuiCtrlCreateButton("Close Help", 95, 615, 100, 35) $Text = GuiCtrlCreateLabel("---------------README------------------", 75, 10) $Text2 = GuiCtrlCreateLabel("The SroTimer will start immediatly, once the script has started." & @CRLF & " I recommend starting script after Silkroad." & @CRLF & "- Your screen and in-game resoultion MUST be 1024x768 for" & @CRLF & "the Anti-Stuck to work." & @CRLF & "- The game must be active for this to work." & @CRLF & @CRLF & "---------------------------------------" & @CRLF & @CRLF & "Functions" & @CRLF & @CRLF & "1. Minimizes Silkroad and hides it from the taskbar," & @CRLF & "Press CTRL + M or use the GUI" & @CRLF & "2. Shows Silkroad after being minimized via CTRL + m," & @CRLF & "Press CTRL + s or use the GUI" & @CRLF & "3. Kills Silkroad instantly. Press CTRL + k or use the GUI" & @CRLF & "4. Once silkroad closes or freezes, a message box will appear" & @CRLF & "showing how long before it closed/froze (Buggy atm)" & @CRLF & "5. Will detect if your character is stuck in town, or stuck" & @CRLF & "anywhere and fix it." & @CRLF & "-If it can't fix it, it will determine if you have been DC'ed." & @CRLF & "-If you have been DC'ed or if it can't fix it a message box will" & @CRLF & "appear showing how long it was before it got stuck." & @CRLF & @CRLF & "---------------------------------------" & @CRLF & @CRLF & "Troubleshooting" & @CRLF & @CRLF & "Q. The Anti-Stuck features aren't working." & @CRLF & @CRLF & "A. Your screen and in-game resoultion must be 1024x768," & @CRLF & "anything else will not work." & @CRLF & @CRLF & "Q. Why does my anti-virus say this is a virus?" & @CRLF & @CRLF & "A. All programs made in AutoIt are flagged as a virus by some" & @CRLF & "Anti-Virus programs. This program is clean." & @CRLF & "If you don't trust my program then don't use it." & @CRLF & @CRLF & "For more information on AutoIt files being flagged as virus'" & @CRLF & "please go to the following link.", 5, 28) $Link = GuiCtrlCreateInput("http://www.autoitscript.com/forum/index.php?showtopic=34658", 10, 575, 250, 20) GuiCtrlCreateLabel("Made by BooYA©", 210, 665) While 1 $GuiControl = GUIGetMsg() Select Case $GuiControl = $Close Exit Case $GuiControl = $Kill If ProcessExists("sro_client.exe") then sleep(20) ProcessClose("sro_client.exe") Else MsgBox(48,"BooYA's Tools","Silkroad client not found.") EndIf Case $GuiControl = $Hide If ProcessExists("sro_client.exe") then WinSetState("SRO_Client", "", @SW_MINIMIZE) WinSetState("SRO_Client", "", @SW_HIDE) Else MsgBox(48,"BooYA's Tools","Silkroad client not found.") EndIf Case $GuiControl = $Show If ProcessExists("sro_client.exe") then WinSetState("SRO_Client", "", @SW_SHOW) WinSetState("SRO_Client", "", @SW_RESTORE) Else MsgBox(48,"BooYA's Tools","Silkroad client not found.") EndIf Case $GuiControl = $Help GuiSetState(@SW_SHOW, $2nd) Case $GuiControl = $Close2 GuiSetState(@SW_HIDE, $2nd) ;Anti-Stuck Case $GuiControl = $AntiStuck If ProcessExists("sro_client.exe") Then While 1 If $GuiControl = $AntiStuckOff Then ExitLoop 1 EndIf If $GuiControl = $Close then Exit EndIf ToolTip("AntiStuck is running.", 0, 0) If PixelGetColor(205,55) = 0x181818 Then ;Mp Empty sleep(120000) EndIf If PixelGetcolor(205,55) = 0x7C8FD1 Then ;Mp full If PixelGetColor(205,38) = 0x181718 Then ;Hp Empty sleep(120000) ElseIf PixelGetColor(205, 55) = 0x7C8FD1 Then ;Mp Full sleep(30000) EndIf EndIf If PixelGetColor(205, 38) = 0xFF6978 Then ;Hp full If PixelGetColor(205, 55) = 0x7C8FD1 Then ;Mp full If PixelGetColor(4, 758) = PixelGetColor(4, 758) Then sleep(60000) If $Pixel1 = $Pixel1 then send("{END}") sleep(1500) send("{INS}") sleep(600000) send("^7") EndIf EndIf EndIF EndIf WEnd Else MsgBox(48,"BooYA's Tools","Silkroad client not found.") EndIf EndSelect WEND Func Terminate() Exit 0 EndFunc Func Minimize() WinSetState("SRO_Client", "", @SW_MINIMIZE) WinSetState("SRO_Client", "", @SW_HIDE) EndFunc Func Maximize() WinSetState("SRO_Client", "", @SW_SHOW) WinSetState("SRO_Client", "", @SW_RESTORE) EndFunc Func Kill() Processclose("sro_client.exe") EndFunc Func Box() $diff = TimerDiff($stamp) MsgBox(0,"Booya's Tools","Silkroad closed or froze after " & StringFormat("%.1f", $diff / 60000) & " minutes ("& StringFormat("%.1f", $diff / 3600000) & " Hours)") EndFunc Thanks Link to comment Share on other sites More sharing options...
weaponx Posted September 17, 2007 Share Posted September 17, 2007 Your problem is here: ;Anti-Stuck Case $GuiControl = $AntiStuck If ProcessExists("sro_client.exe") Then While 1 If $GuiControl = $AntiStuckOff Then ExitLoop 1 EndIf If $GuiControl = $Close Then Exit EndIf You are checking the value of $GuiControl within the inner loop but the actual value is being determined by the outer while loop. So $GuiControl is always equal to $AntiStuck Link to comment Share on other sites More sharing options...
Siao Posted September 17, 2007 Share Posted September 17, 2007 (edited) You don't need that inner While loop. Use global boolean flag - StuckOn button turns it True, StuckOff button turns it False. Then instead of If ProcessExists("sro_client.exe") then... use If $doStuck = True AND ProcessExists("sro_client.exe") then... Sleep() in MessageLoop is a GUI killer though, in any case. Rework the logic of your bot to work without sleeps. Edited September 17, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Delta01 Posted September 17, 2007 Author Share Posted September 17, 2007 (edited) Ahh, so i should try something like this? expandcollapse popup$Help = GuiCtrlCreateButton("Help", 115, 62, 80, 25) $Label = GuiCtrlCreateLabel("Made by BooYA©", 140, 135) GuiSetState() GuiCtrlSetState($AntiStuckOff, $GUI_DISABLE) ...... While 1 ........ Case $GuiControl = $AntiStuckOff ExitLoop Case $GuiControl = $AntiStuck If ProcessExists("sro_client.exe") Then GuiCtrlSetState($AntiStuckOff, $GUI_ENABLE) While 1 ToolTip("AntiStuck is running.", 0, 0) If PixelGetColor(205,55) = 0x181818 Then ;Mp Empty sleep(120000) EndIf If PixelGetcolor(205,55) = 0x7C8FD1 Then ;Mp full If PixelGetColor(205,38) = 0x181718 Then ;Hp Empty sleep(120000) ElseIf PixelGetColor(205, 55) = 0x7C8FD1 Then ;Mp Full sleep(30000) EndIf EndIf If PixelGetColor(205, 38) = 0xFF6978 Then ;Hp full If PixelGetColor(205, 55) = 0x7C8FD1 Then ;Mp full If PixelGetColor(4, 758) = PixelGetColor(4, 758) Then sleep(60000) If $Pixel1 = $Pixel1 then send("{END}") sleep(1500) send("{INS}") sleep(600000) send("^7") EndIf EndIf EndIF EndIf WEnd ........... Would that work? Was writing this up before you replied, Siao. Would this still work tho? I need the sleeps for the script.. Edited September 17, 2007 by Delta01 Link to comment Share on other sites More sharing options...
wolf9228 Posted September 17, 2007 Share Posted September 17, 2007 (edited) Hi, I'm trying to make a script for a game. I have most features working, but when i try to use another While/Wend statement in another While/Wend statement, ExitLoop doesn't close the While/Wend statement that's inside the other While/Wend statement. When i click the button in the GUI to activate the second While/Wend statement, everything freezes up. So, I thought if i added the GuiControls into the second while/wend it would work. My code is below, anybody know how i could fix it? expandcollapse popup#include <GUIConstants.au3> #include <Date.au3> Global $Pixel1 = PixelGetColor(4, 758), $stamp = TimerInit() HotKeySet("{F5}", "Terminate") HotKeySet("^m", "Minimize") HotKeySet("^s", "Maximize") HotKeySet("^k", "Kill") HotKeySet("^7", "Box") $main = GUICreate("Booya's Tools", 229, 150) $Kill = GUICtrlCreateButton("Kill SRO", 35, 12, 80, 25) $Hide = GUICtrlCreateButton("Minimize SRO", 35, 37, 80, 25) $Show = GUICtrlCreateButton("Maximize SRO", 35, 63, 80, 25) $Close = GUICtrlCreateButton("Close script", 35, 88, 80, 25) $AntiStuck = GuiCtrlCreateButton("Anti-Stuck-On", 115, 12, 80, 25) $AntiStuckOff = GuiCtrlCreateButton("Anti-Stuck-Off", 115, 37, 80, 25) $Help = GuiCtrlCreateButton("Help", 115, 62, 80, 25) $Label = GuiCtrlCreateLabel("Made by BooYA©", 140, 135) GuiSetstate() $2nd = GuiCreate("Help File", 300, 680) $Close2 = GuiCtrlCreateButton("Close Help", 95, 615, 100, 35) $Text = GuiCtrlCreateLabel("---------------README------------------", 75, 10) $Text2 = GuiCtrlCreateLabel("The SroTimer will start immediatly, once the script has started." & @CRLF & " I recommend starting script after Silkroad." & @CRLF & "- Your screen and in-game resoultion MUST be 1024x768 for" & @CRLF & "the Anti-Stuck to work." & @CRLF & "- The game must be active for this to work." & @CRLF & @CRLF & "---------------------------------------" & @CRLF & @CRLF & "Functions" & @CRLF & @CRLF & "1. Minimizes Silkroad and hides it from the taskbar," & @CRLF & "Press CTRL + M or use the GUI" & @CRLF & "2. Shows Silkroad after being minimized via CTRL + m," & @CRLF & "Press CTRL + s or use the GUI" & @CRLF & "3. Kills Silkroad instantly. Press CTRL + k or use the GUI" & @CRLF & "4. Once silkroad closes or freezes, a message box will appear" & @CRLF & "showing how long before it closed/froze (Buggy atm)" & @CRLF & "5. Will detect if your character is stuck in town, or stuck" & @CRLF & "anywhere and fix it." & @CRLF & "-If it can't fix it, it will determine if you have been DC'ed." & @CRLF & "-If you have been DC'ed or if it can't fix it a message box will" & @CRLF & "appear showing how long it was before it got stuck." & @CRLF & @CRLF & "---------------------------------------" & @CRLF & @CRLF & "Troubleshooting" & @CRLF & @CRLF & "Q. The Anti-Stuck features aren't working." & @CRLF & @CRLF & "A. Your screen and in-game resoultion must be 1024x768," & @CRLF & "anything else will not work." & @CRLF & @CRLF & "Q. Why does my anti-virus say this is a virus?" & @CRLF & @CRLF & "A. All programs made in AutoIt are flagged as a virus by some" & @CRLF & "Anti-Virus programs. This program is clean." & @CRLF & "If you don't trust my program then don't use it." & @CRLF & @CRLF & "For more information on AutoIt files being flagged as virus'" & @CRLF & "please go to the following link.", 5, 28) $Link = GuiCtrlCreateInput("http://www.autoitscript.com/forum/index.php?showtopic=34658", 10, 575, 250, 20) GuiCtrlCreateLabel("Made by BooYA©", 210, 665) While 1 $GuiControl = GUIGetMsg() Select Case $GuiControl = $Close Exit Case $GuiControl = $Kill If ProcessExists("sro_client.exe") then sleep(20) ProcessClose("sro_client.exe") Else MsgBox(48,"BooYA's Tools","Silkroad client not found.") EndIf Case $GuiControl = $Hide If ProcessExists("sro_client.exe") then WinSetState("SRO_Client", "", @SW_MINIMIZE) WinSetState("SRO_Client", "", @SW_HIDE) Else MsgBox(48,"BooYA's Tools","Silkroad client not found.") EndIf Case $GuiControl = $Show If ProcessExists("sro_client.exe") then WinSetState("SRO_Client", "", @SW_SHOW) WinSetState("SRO_Client", "", @SW_RESTORE) Else MsgBox(48,"BooYA's Tools","Silkroad client not found.") EndIf Case $GuiControl = $Help GuiSetState(@SW_SHOW, $2nd) Case $GuiControl = $Close2 GuiSetState(@SW_HIDE, $2nd) ;Anti-Stuck Case $GuiControl = $AntiStuck If ProcessExists("sro_client.exe") Then While 1 If $GuiControl = $AntiStuckOff Then ExitLoop 1 EndIf If $GuiControl = $Close then Exit EndIf ToolTip("AntiStuck is running.", 0, 0) If PixelGetColor(205,55) = 0x181818 Then ;Mp Empty sleep(120000) EndIf If PixelGetcolor(205,55) = 0x7C8FD1 Then ;Mp full If PixelGetColor(205,38) = 0x181718 Then ;Hp Empty sleep(120000) ElseIf PixelGetColor(205, 55) = 0x7C8FD1 Then ;Mp Full sleep(30000) EndIf EndIf If PixelGetColor(205, 38) = 0xFF6978 Then ;Hp full If PixelGetColor(205, 55) = 0x7C8FD1 Then ;Mp full If PixelGetColor(4, 758) = PixelGetColor(4, 758) Then sleep(60000) If $Pixel1 = $Pixel1 then send("{END}") sleep(1500) send("{INS}") sleep(600000) send("^7") EndIf EndIf EndIF EndIf WEnd Else MsgBox(48,"BooYA's Tools","Silkroad client not found.") EndIf EndSelect WEND Func Terminate() Exit 0 EndFunc Func Minimize() WinSetState("SRO_Client", "", @SW_MINIMIZE) WinSetState("SRO_Client", "", @SW_HIDE) EndFunc Func Maximize() WinSetState("SRO_Client", "", @SW_SHOW) WinSetState("SRO_Client", "", @SW_RESTORE) EndFunc Func Kill() Processclose("sro_client.exe") EndFunc Func Box() $diff = TimerDiff($stamp) MsgBox(0,"Booya's Tools","Silkroad closed or froze after " & StringFormat("%.1f", $diff / 60000) & " minutes ("& StringFormat("%.1f", $diff / 3600000) & " Hours)") EndFunc Thanks #include <GUIConstants.au3> GUICreate ("",300,200) $buttonstart = GUICtrlCreateButton ("start loop2",20,20,70,22) GUISetState( ) While 1 $msg = GUIGetMsg() Select case $msg = $GUI_EVENT_CLOSE ExitLoop case $msg = $buttonstart dim $i = 1 , $i2 =0 While $i = 1 $i2 = $i2 + 1 SplashTextOn("Title", $i2, 90, 60, -1, -1, 4, "", 24) Sleep(1000) SplashOff() if $i2 = 10 then $i = 0 wend EndSelect Wend Edited September 17, 2007 by wolf9228 صرح السماء كان هنا Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now