Warriorfoe Posted November 23, 2016 Share Posted November 23, 2016 (edited) Okay so here's the problem. I have a script I'm testing out where I want it to search for a certain color and if it finds that certain color I want it to check for a second color. I only want it to check for the second color after checking for the first color. If it finds the first color it will check for the second color and whether or not that second color is present it will cause certain actions to be undertaken. Well at least that's what I want it to do. I want this all to be done in a loop where it's constantly checking for the first color. However, once it does find the first color and it executes one of the actions regarding the second, I want the program to quit. I'm having trouble figuring out how to nest conditional statements here. If anyone could help me out it would be much appreciated. expandcollapse popupHotKeySet("{ESC}", "Terminate") HotKeySet("!c", "getColor") HotKeySet("!l", "ClickPositions") Global $color Global $interval $interval = "10000" MsgBox (0, "Starting Up", "Starting, use ESC to quit, Alt + C to get color, and Alt + L to begin Test") Func Terminate() Exit 1 EndFunc Func ClickPositions() MsgBox(0, "Beginning Test", "Hope to god this works") While 1 $Coords = PixelSearch(1006, 48, 1074, 79, 0xECECEC) $1stcoords = PixelSearch(930, 621, 1066, 649, 0x8A211E) $point = MouseGetPos() $posx = Random(930, 1066) $posy = Random(621, 649) $clicklogx = Random(1076, 1093) $clicklogy = Random(38, 54) If IsArray($Coords) Then ;check to see if the first color is there If IsArray($1stcoords) Then ;if it is check for the second color and if that one is there: MouseClick( "left", $point[0], $point[1], 1) If IsArray(<>$1stcoords) Then ;if the second color is not there: MouseClick("left", $clicklogx, $clicklogy, 1, Random(1000, 2500)) Sleep(3000) MouseClick( "left" , $posx, $posy, 1, Random ( 1000 , 2500)) EndIf EndIf EndIf Sleep(2000) WEnd EndFunc While 1 Sleep(250) WEnd Edited November 23, 2016 by Warriorfoe Link to comment Share on other sites More sharing options...
water Posted November 23, 2016 Share Posted November 23, 2016 (edited) Welcome to AutoIt and the forum! Pixelsearch and Mouseclick are not very reliable as they depend on window position and screen size etc. Could you please tell us which program you try to automate? Most of the time there are more reliable ways to do what you want to do. Edited November 23, 2016 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Warriorfoe Posted November 23, 2016 Author Share Posted November 23, 2016 Ya I'm trying to automate logging out on RuneScape. Like I'm not trying to bot or anything I just want to see if this script works in the game. I'm doing this on a throwaway account but I doubt the owners will care if I'm just logging out. Basically I'm trying to have it search for a white dot on a certain area of the minimap and if it finds that color it will check to see if the logout button is there. If it finds it it will just click on it and if it doesn't it will bring it up on the menu and then click on it. Idk I figured I'd try one of my first scripts there cause I play a lot and I just wanted to see if it would work. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 23, 2016 Moderators Share Posted November 23, 2016 @Warriorfoe unfortunately this still falls afoul of the forum rules. Quote Launching, automation or script interaction with games or game servers, regardless of the game. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts