yarz Posted June 23, 2008 Share Posted June 23, 2008 Hello all, I want to make a script that searches for a colour, moves the mouse to that colour and then clicks it. This is what I have, but it is not working..: CODE; Get the color to match (change this to suit). sleep(10000) $iColor = 0x00FF00 Dim $Coord[2] While IsArray($Coord) $Coord = PixelSearch(1204, 566, 1414, 627, $iColor) If @error = 0 then ; The color was found MouseMove($Coord) MouseClick("left") Sleep(5000) ; A debug message that lasts only one second MsgBox(4096, "Debug", "Mouse Left Click done.", 1) EndIf WEnd MsgBox(4096, "Debug", "While loop has terminated") My idea was, it searches the pixelcoordinates and saves it in $Coord, then it moves the mouse to $Coord, but that's not working. I've just started with AutoIt so this is maybe a newb question, but can anyone help me out? Thanks Link to comment Share on other sites More sharing options...
Valuater Posted June 23, 2008 Share Posted June 23, 2008 These numbers are way-off my screen $Coord = PixelSearch(1204, 566, 1414, 627, $iColor) PixelSearch ( left, top, right, bottom, color ) and look ay MouseMove() again, it needs two coordinates 8) Link to comment Share on other sites More sharing options...
yarz Posted June 23, 2008 Author Share Posted June 23, 2008 These numbers are way-off my screen$Coord = PixelSearch(1204, 566, 1414, 627, $iColor)PixelSearch ( left, top, right, bottom, color )and look ay MouseMove() again, it needs two coordinates8)Well, I have a 24" screen so that can be right..I want to move the mouse to the colour, but that place can be in 4 different positions, so i can't give the coordinates as a number.. Link to comment Share on other sites More sharing options...
Valuater Posted June 23, 2008 Share Posted June 23, 2008 this is how it would be used.. ; Get the color to match (change this to suit). Sleep(10000) $iColor = 0x00FF00 Dim $Coord[2] While IsArray($Coord) $Coord = PixelSearch(1204, 566, 1414, 627, $iColor) If @error = 0 Then ; The color was found MouseMove($Coord[0], $Coord[1]) MouseClick("left") Sleep(5000) ; A debug message that lasts only one second MsgBox(4096, "Debug", "Mouse Left Click done.", 1) EndIf WEnd MsgBox(4096, "Debug", "While loop has terminated") 8) Link to comment Share on other sites More sharing options...
cageman Posted June 23, 2008 Share Posted June 23, 2008 (edited) Dim $icolor,$timer,$Coord[2] ; Get the color to match (change this to suit). sleep(10000) $iColor = 0x00FF00 $timer=Timerinit() Do Do $Coord = PixelSearch(1204, 566, 1414, 627, $iColor) Until IsArray($Coord) or Timerdiff($timer)>10000 If IsArray($Coord) Then MouseMove($Coord[0],$coord[1]) MouseClick("left") sleep(5000) Endif Until @error<>0 This would work i guess. I always prefer this so you can even state how long the search should be. Edited June 23, 2008 by cageman Link to comment Share on other sites More sharing options...
yarz Posted June 23, 2008 Author Share Posted June 23, 2008 Thanks! I didn't know about the numbers. Now I want that AutoIt refreshes the page when the result is negative so i've this: CODE; Get the color to match (change this to suit). Sleep(10000) $iColor = 0x00FF00 Dim $Coord[2] While IsArray($Coord) $Coord = PixelSearch(1204, 566, 1414, 627, $iColor) If @error = 0 Then ; The color was found MouseMove($Coord[0], $Coord[1]) MouseClick("left") Sleep(10000) ; A debug message that lasts only one second MsgBox(4096, "Debug", "Mouse Left Click done.", 1) EndIf If @error = 1 Then Sleep(Random(8000, 14000)) Send('{f5}') SetError(0) EndIf WEnd MsgBox(4096, "Debug", "While loop has terminated") But I think there is something wrong with the loop, but I'm still figuring out what 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