Queener Posted August 6, 2013 Share Posted August 6, 2013 $Coords = PixelSearch(1009, -875, 1108, -762, 0x968A4B) $Coords2 = PixelSearch(269, -774, 907, -468, 0xC30000) $Coords3 = PixelSearch(132, -907, 196, -900, 0x470137) while 1 WinActivate("mspaint", "") sleep(500) if IsArray($Coords) = true Then GoHere() sleep(500) elseif IsArray($Coords2) = true Then GoHere2() ElseIf IsArray($Coords3) = true Then GoHere3() EndIf WEnd Func GoHere() while 1 if IsArray($Coords) = True Then MouseMove($Coords[0],$Coords[1],1) MouseDown("Left") sleep(5000) MouseUp("Left") WEnd EndFunc The code works, but for some reason, it keep looping the GoHere() None stop eventhough the pixel is being replaced. Which ever function is being called first will infinite loop. What I want is if that function call for a pixel and if it no longer exist or seeing in mspaint; that it move to the next Function. Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
jaberwacky Posted August 6, 2013 Share Posted August 6, 2013 (edited) You are missing an EndIf. Try this and see if it works then: $Coords = PixelSearch(1009, -875, 1108, -762, 0x968A4B) $Coords2 = PixelSearch(269, -774, 907, -468, 0xC30000) $Coords3 = PixelSearch(132, -907, 196, -900, 0x470137) while 1 WinActivate("mspaint", "") sleep(500) if IsArray($Coords) = true Then GoHere() sleep(500) elseif IsArray($Coords2) = true Then GoHere2() ElseIf IsArray($Coords3) = true Then GoHere3() EndIf WEnd Func GoHere() while 1 if IsArray($Coords) = True Then MouseMove($Coords[0],$Coords[1],1) MouseDown("Left") sleep(5000) MouseUp("Left") EndIf WEnd EndFunc Also, there is no break out of the while loop in GoHere(). Use an ExitLoop, strategically placed, might do the trick. Edited August 6, 2013 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Queener Posted August 6, 2013 Author Share Posted August 6, 2013 (edited) correct me if I'm wrong but if I add the exitloop as: Func GoHere() while 1 if IsArray($Coords) = True Then MouseMove($Coords[0],$Coords[1],1) MouseDown("Left") sleep(5000) MouseUp("Left") else exitloop EndIf WEnd EndFunc doesn't that exit the entire loop? I believe I tried that also and it stops what its doing until I close the program and reopen. Edited August 6, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
hiho Posted August 6, 2013 Share Posted August 6, 2013 Why do you have a loop in GoHere() and what's the poin of the double isarray check? PixelSearch always returns an array? Link to comment Share on other sites More sharing options...
BrewManNH Posted August 6, 2013 Share Posted August 6, 2013 Your problem is that your PixelSearch is outside of the loop, it's only checked once before you enter the While loop. So the results are always going to be the same no matter what is happening on the screen. Also, you're checking if the variables are arrays even after you've checked that they're arrays. Your While loop checks $coords, then you check it again inside the GoHere function, and you're stuck inside the While loop in that function with no exit. Whatever it is you're trying to do, you're doing it all wrong. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Queener Posted August 6, 2013 Author Share Posted August 6, 2013 Nvm, Found a tutorial and use it to impliment into 3 color array. Works great! I tried both individual method which cause overstack so I continue onto array instead; HotKeySet("{ESC}", "Quit") WinActivate("Just a test.bmp - Paint", "") WinSetState("Just a test.bmp - Paint", "", @SW_MAXIMIZE) Dim $pos[2] Global $counter=0 Global $on=0 start() Func Start() Local $color[3]= [0xED1C24, 0x22B14C, 0xB97A57] $on = 1 While $on = 1 For $i = 0 to 1 $pos = PixelSearch(0,0, 530, 330, $color[$i], 20, 1) if not @error Then MouseMove($pos[0],$pos[1],0) sleep(20) mousedown("left") EndIf Next if @error Then $counter = $counter+1 EndIf if $counter>5 Then $on=0 Mouseup("Left") MsgBox(1, "Color", "Colored") EndIf WEnd Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") 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