insanity Posted March 22, 2006 Posted March 22, 2006 I am trying to makes the following code to loop until it kills the creature in the game it is for. The 'you aim for A' is the first attack. then after the first attack if the omnster has not been kill it gives a message 'You attack A' until the monster has died. When the monster dies you get a 'Enemy is Dead, R.I.P.' messge. I am trying to make the script continually click the button until the Enemy id dead message appears, and then to re run the entire script again. Any help would be appreciated. #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(957,382) MouseDown("left") MouseMove(330,118) MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- If 'You aim for A' Then #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(551,220) MouseDown("left") MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- ElseIf 'You attack A' Then #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(551,220) MouseDown("left") MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- If 'Enemy is dead, R.I.P.' Then #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(786,184) MouseDown("left") MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- Thanks
Gigglestick Posted March 22, 2006 Posted March 22, 2006 Here's an endless loop While 1 WEnd My UDFs: ExitCodes
ChrisL Posted March 22, 2006 Posted March 22, 2006 (edited) I can only guess you mean something like this. The first while 1 loops the entire code all the way down to the bottom Wend The second while 1 loops through the section of code untill the Wend immediately after the thing is dead, the exitloop makes it jump out of the inner loop back in to the main loop. expandcollapse popupWhile 1 #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(957,382) MouseDown("left") MouseMove(330,118) MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- While 1 If 'You aim for A' Then #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(551,220) MouseDown("left") MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- ElseIf 'You attack A' Then #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(551,220) MouseDown("left") MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- If 'Enemy is dead, R.I.P.' Then exitloop endif;<<<< that was missing and is why it wasn't working Wend #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(786,184) MouseDown("left") MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- Wend Edited March 23, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
jvanegmond Posted March 22, 2006 Posted March 22, 2006 While 1 If $condition = <value> Then Exit Wend That's basically it. github.com/jvanegmond
ChrisL Posted March 23, 2006 Posted March 23, 2006 (edited) There was an Endif missing above the first Wend. expandcollapse popupWhile 1 #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(957,382) MouseDown("left") MouseMove(330,118) MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- While 1 If 'You aim for A' Then #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(551,220) MouseDown("left") MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- ElseIf 'You attack A' Then #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(551,220) MouseDown("left") MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- If 'Enemy is dead, R.I.P.' Then exitloop Endif Wend #region --- ScriptWriter generated code Start --- Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Shimlar - Microsoft Internet Explorer","") If Not WinActive("Shimlar - Microsoft Internet Explorer","") Then WinActivate("Shimlar - Microsoft Internet Explorer","") WinWaitActive("Shimlar - Microsoft Internet Explorer","") MouseMove(786,184) MouseDown("left") MouseUp("left") Sleep(1000) #endregion --- ScriptWriter generated code End --- Wend Edited March 23, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
tonedeaf Posted March 23, 2006 Posted March 23, 2006 (edited) I am trying to makes the following code to loop until it kills the creature in the game it is for. Here's another example: Edited March 23, 2006 by tonedeaf
Moderators SmOke_N Posted March 23, 2006 Moderators Posted March 23, 2006 I have a question... These 3 If/ElseIf statements:If 'You aim for A' ThenAndElseIf 'You attack A' ThenAndIf 'Enemy is dead, R.I.P.' Then exitloopI suppose your going to make a command for those right?.... like: If ControlGetText('WindowName', '', 100) = 'Enemy is dead, R.I.P.' Then ;Do Something EndIfThe ControlGetText is just an example of finding out if the "Conditional" statement is true or not. If your not using a correct conditional statement, then the rest is really null and void. Also, if your going to keep your "Opt(s)" all the same, there is no need to keep repeating them.... Once would be enough at the top of your script. Here is an example of what it looks to me that you are trying to accomplish:#region --- ScriptWriter generated code Start --- Global $WinName = "Shimlar - Microsoft Internet Explorer" Global $PopUp_Window_Name = 'Whatever the title of the PopUp that you want to get commands from' Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWaitFunc() MouseClick('left', 957, 382) MouseClick('left', 330, 118) Sleep(1000) #endregion --- ScriptWriter generated code End --- While 1 If StringInStr(WinGetText($PopUp_Window_Name), 'You aim for A') Then; StringInStr() and WinGetText Just an example of Conditional WinWaitFunc(); just made a function for this since you are using it so much (winwait()/WinActivate()/WinWaitActive() MouseClick('left', 551, 220) Sleep(1000) ElseIf StringInStr(WinGetText($PopUp_Window_Name), 'You attack A') Then WinWaitFunc() MouseClick('left', 551, 220) Sleep(1000) ElseIf StringInStr(WinGetText($PopUp_Window_Name), 'Enemy is dead, R.I.P.') Then WinWaitFunc() MouseClick('left', 786, 184) Sleep(1000) EndIf WEnd Func WinWaitFunc() WinWait($WinName) If Not WinActive($WinName) Then WinActivate($WinName) WinWaitActive($WinName) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
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