icepick090 Posted December 29, 2005 Share Posted December 29, 2005 I need help making a script to pixelsearch for a certain color, and then move the mouse to that color and right click it.. Willing to pay with paypal, msn: izorins@gmail.com what i have seen from people is: Func _ScanOverheadMap() If $winpos[2] = 646 Then ;windowed $coord = PixelSearch($winpos[0] + 3 + 50, $winpos[1] + 22 + 25, $winpos[0] + 3 + 580, $winpos[1] + 22 + 270, 0x7BA6F7, 0, 5) Else ;fullscreen $coord = PixelSearch($winpos[0] + 50, $winpos[1] + 25, $winpos[0] + 580, $winpos[1] + 270, 0x7BA6F7, 0, 5) EndIf If IsArray($coord) Then Return True Else Return False EndIf Link to comment Share on other sites More sharing options...
LxP Posted December 29, 2005 Share Posted December 29, 2005 (edited) Welcome to the forums!This should do it:; Search the entire desktop for colour #7BA6F7 Local $Coords = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, 0x7BA6F7) ; If successful then click that location If Not @Error Then MouseClick('Right', $Coords[0], $Coords[1])Edit: Changed to the colour from the top post. Edited December 29, 2005 by LxP Link to comment Share on other sites More sharing options...
icepick090 Posted December 29, 2005 Author Share Posted December 29, 2005 hmm thats for desktop? what i am needing is for a full screen game. Link to comment Share on other sites More sharing options...
LxP Posted December 29, 2005 Share Posted December 29, 2005 The @DesktopWidth and @DesktopHeight macros are used to determine what 'full-screen' is. Link to comment Share on other sites More sharing options...
icepick090 Posted December 29, 2005 Author Share Posted December 29, 2005 oh, so this should work in the game? Link to comment Share on other sites More sharing options...
LxP Posted December 29, 2005 Share Posted December 29, 2005 It sure should. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 29, 2005 Moderators Share Posted December 29, 2005 Look at Opt("PixelCoordMode", NUMBER) in the help file, if you are wanting to do it in a specific window, you'll need to replace 'NUMBER' with either 2 or 0, and make sure the Coordinates your using are using the same (Client or Window Coords) using the AutoInfo tool (Can be changed in Options on the AutoInfo tool). Also look at Opt("MouseCoordMode", NUMBER) using the same example to replace 'NUMBER'. Then it should work on your game. So my code would look something like: Opt("WinTitleMatchMode", 4) Opt("PixelCoordMode", 2) Opt("MouseCoordMode", 2) Global $GameTitle = "My Game" While 1 If Not WinActive($GameTitle) Then WinActivate($GameTitle) $Coords = PixelSearch(xCoordStart, yCoordStart, xCoordEnd, yCoordEnd, 0x7BA6F7) If Not @Error And IsArray($Coords) Then MouseClick('Left', $Coords[0], $Coords[1], 1, 1) Sleep(10) Wend 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. Link to comment Share on other sites More sharing options...
icepick090 Posted December 29, 2005 Author Share Posted December 29, 2005 hmm it worked but it seems to close out after a few seconds. Link to comment Share on other sites More sharing options...
LxP Posted December 29, 2005 Share Posted December 29, 2005 Whose code are you referring to? My code isn't designed to click more than once. Link to comment Share on other sites More sharing options...
icepick090 Posted December 29, 2005 Author Share Posted December 29, 2005 (edited) your code Edited December 29, 2005 by icepick090 Link to comment Share on other sites More sharing options...
LxP Posted December 29, 2005 Share Posted December 29, 2005 (edited) maybe because it doesnt repeat?Precisely.Ron's code will repeat and it will also continually click the same spot. Is that desired or should the code wait until the spot that was clicked change colour?Edit: Added context. Edited December 29, 2005 by LxP Link to comment Share on other sites More sharing options...
icepick090 Posted December 29, 2005 Author Share Posted December 29, 2005 hmm i dont really understand but the color it clicks is the color of an armor a person has on, so it will auto follow them. Link to comment Share on other sites More sharing options...
LxP Posted December 29, 2005 Share Posted December 29, 2005 To put it another way, should the script click the colour and then wait for the colour to move? Or should it just keep clicking away even if nothing changes? Link to comment Share on other sites More sharing options...
icepick090 Posted December 29, 2005 Author Share Posted December 29, 2005 hmm click and wait for the color to move, because the people will be moving Link to comment Share on other sites More sharing options...
LxP Posted December 29, 2005 Share Posted December 29, 2005 Something like this will do it then:; Define colour to match Local $Match = 0x7BA6F7 ; Loop indefinitely While 1 ; Search the entire desktop for colour Local $Coords = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, $Match) ; If successful then click that location If Not @Error Then MouseClick('Right', $Coords[0], $Coords[1]) ; Wait until the colour at that point changes Do Sleep(100) Until PixelGetColor($Coords[0], $Coords[1]) <> $Match Else Sleep(100) EndIf WEndRon's example will help you if you're looking to adapt the code to work with a windowed game as well.Another piece of advice: grab the beta and set that up as the default to run scripts (Start > Programs > AutoIt v3 > Beta > Toggle AU3 Beta) because it has an improved PixelSearch() engine which will give much faster results. Link to comment Share on other sites More sharing options...
icepick090 Posted December 29, 2005 Author Share Posted December 29, 2005 Something like this will do it then: ; Define colour to match Local $Match = 0x7BA6F7 ; Loop indefinitely While 1 ; Search the entire desktop for colour Local $Coords = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, $Match) ; If successful then click that location If Not @Error Then MouseClick('Right', $Coords[0], $Coords[1]) ; Wait until the colour at that point changes Do Sleep(100) Until PixelGetColor($Coords[0], $Coords[1]) <> $Match Else Sleep(100) EndIf WEnd Ron's example will help you if you're looking to adapt the code to work with a windowed game as well. Another piece of advice: grab the beta and set that up as the default to run scripts (Start > Programs > AutoIt v3 > Beta > Toggle AU3 Beta) because it has an improved PixelSearch() engine which will give much faster results.ok did that, but it doesnt work ingame but on my desktop it does. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 29, 2005 Moderators Share Posted December 29, 2005 Use the options that are in mine (Opt()'s) with Alex's code as he stated. 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. Link to comment Share on other sites More sharing options...
icepick090 Posted December 29, 2005 Author Share Posted December 29, 2005 Opt("WinTitleMatchMode", 4) Opt("PixelCoordMode", 2) Opt("MouseCoordMode", 2) ; Define colour to match Local $Match = 0xEF6B08 ; Loop indefinitely While 1 ; Search the entire desktop for colour Local $Coords = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, $Match) ; If successful then click that location If Not @Error Then MouseClick('Right', $Coords[0], $Coords[1]) ; Wait until the colour at that point changes Do Sleep(100) Until PixelGetColor($Coords[0], $Coords[1]) <> $Match Else Sleep(100) EndIf WEnd like that? Link to comment Share on other sites More sharing options...
icepick090 Posted December 29, 2005 Author Share Posted December 29, 2005 hmm that doesnt appear to work either... hmm, what should i do? =x Link to comment Share on other sites More sharing options...
LxP Posted December 29, 2005 Share Posted December 29, 2005 When you say 'it doesn't work', what exactly do you mean? Does the mouse move in any way? Does it click the wrong location?I would suggest trying this script with the beta; it will beep high to indicate that it found the pixel or low otherwise. I've also slowed it down so that the beeps don't drive you mad.; Define colour to match Local $Match = 0xEF6B08 ; Loop indefinitely While 1 ; Search the entire desktop for colour Local $Coords = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, $Match) ; If successful then click that location If Not @Error Then Beep(800, 50) MouseClick('Right', $Coords[0], $Coords[1]) ; Wait until the colour at that point changes Do Sleep(1000) Until PixelGetColor($Coords[0], $Coords[1]) <> $Match Else Beep(100, 50) Sleep(1000) EndIf WEnd 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