ViVoxity Posted December 28, 2009 Share Posted December 28, 2009 Here is what I'm doing. I want to Search for a pixel in a small radius of my mouse. Here's my crappy attempt. Func _Search() $DesktopIcon = 0x667431 While $Repeat = True $Pos = MouseGetPos() $coord = PixelSearch(0, 0, 1680, 1050, $DesktopIcon) MouseMove($coord[0], $coord[1], 5) If $coord = PixelSearch($Pos, $Pos, $Pos, $Pos, $DesktopIcon) Then MouseClick("left", $coord[0], $coord[1], 2) Else Sleep(5000) EndIf WEnd This is my horrid attempt. Though what I would really like to do is this. 1. Find and click on my first task. 2. Sleep. 3. Check and see if my first task is still there. 4. If it is, Sleep. 5. If it is not, Repeat first task. I just took some big reverse hits, so I'm pretty high and lost Link to comment Share on other sites More sharing options...
danielmohr91 Posted December 29, 2009 Share Posted December 29, 2009 (edited) I'm completely new to this myself, but I think I might be able to help out a bit. For the $pos variable you want +5 -5 etc... so it's searching 5 above 5 to the left and 5 below and 5 to the right - a 10x10 box. Make sense? I also changed the If... Then... You need to check for errors. $DesktopIcon = 0x667431 Func start() While $Repeat = True $Pos = MouseGetPos() $coord = PixelSearch(0, 0, 1680, 1050, $DesktopIcon) MouseMove($coord[0], $coord[1], 5) $coord = PixelSearch($Pos + 5, $Pos + 5, $Pos - 5, $Pos - 5, $DesktopIcon) If @error Then Sleep(5000) Else MouseClick("left", $coord[0], $coord[1], 2) EndIf WEnd EndFunc ;==>start If this is a stand alone script, it will close out right away, because the function isn't called. something like this: $DesktopIcon = 0x667431 #Region HotKeySet("{home}", "start") ; and of course another hotkey and function to make $Repeat = False... While 1 Sleep(100) WEnd #EndRegion ; you could also delete the stuff in the Region and replace it with "start()" without quotes - to start it right away. though, if you do that, it will start at your current mouse position, I don't know if you want that... Func start() $Repeat = True While $Repeat = True $Pos = MouseGetPos() $coord = PixelSearch(0, 0, 1680, 1050, $DesktopIcon) MouseMove($coord[0], $coord[1], 5) $coord = PixelSearch($Pos + 5, $Pos + 5, $Pos - 5, $Pos - 5, $DesktopIcon) If @error Then Sleep(5000) Else MouseClick("left", $coord[0], $coord[1], 2) EndIf WEnd EndFunc ;==>start should work You generally want set hotkeys loop functions Edited December 29, 2009 by danielmohr91 Link to comment Share on other sites More sharing options...
ViVoxity Posted December 29, 2009 Author Share Posted December 29, 2009 I'm completely new to this myself, but I think I might be able to help out a bit. For the $pos variable you want +5 -5 etc... so it's searching 5 above 5 to the left and 5 below and 5 to the right - a 10x10 box. Make sense? I also changed the If... Then... You need to check for errors. $DesktopIcon = 0x667431 Func start() While $Repeat = True $Pos = MouseGetPos() $coord = PixelSearch(0, 0, 1680, 1050, $DesktopIcon) MouseMove($coord[0], $coord[1], 5) $coord = PixelSearch($Pos + 5, $Pos + 5, $Pos - 5, $Pos - 5, $DesktopIcon) If @error Then Sleep(5000) Else MouseClick("left", $coord[0], $coord[1], 2) EndIf WEnd EndFunc ;==>start If this is a stand alone script, it will close out right away, because the function isn't called. something like this: $DesktopIcon = 0x667431 #Region HotKeySet("{home}", "start") ; and of course another hotkey and function to make $Repeat = False... While 1 Sleep(100) WEnd #EndRegion ; you could also delete the stuff in the Region and replace it with "start()" without quotes - to start it right away. though, if you do that, it will start at your current mouse position, I don't know if you want that... Func start() $Repeat = True While $Repeat = True $Pos = MouseGetPos() $coord = PixelSearch(0, 0, 1680, 1050, $DesktopIcon) MouseMove($coord[0], $coord[1], 5) $coord = PixelSearch($Pos + 5, $Pos + 5, $Pos - 5, $Pos - 5, $DesktopIcon) If @error Then Sleep(5000) Else MouseClick("left", $coord[0], $coord[1], 2) EndIf WEnd EndFunc ;==>start should work You generally want set hotkeys loop functions Wow, thanks for the response. I don't think the +5 -% works. Try it.. It doesn't. You have to create something like this. (Thank god for C++) $MousePosX = $Pos[0]+5 $MousePosY = $Pos[1]-5 Then create your pixel scan like so. $coord = PixelSearch($MousePosA[0], $MousePosA[1],$MousePosA[0], $MousePosA[1], $DesktopIcon) You would have to do it with X and Y though. I am pretty sure that's how I should have done it. I figured all this out while my post was being ignored. Also, I need to run a function every 5 seconds while $Var = True How would I do that? And, is there a better way to do this? While $Start = True $SlotCheck = PixelSearch(1621, 904, 1670, 940,0x593A0c) If @error = 0 Then $Bank = False Else Sleep(5000) $Start = False EndIf WEnd I'm trying to check if a pixel is somewhere, if it is, then I want it to do a task, if not I want it to do a different task. How would I go about doing this? Link to comment Share on other sites More sharing options...
JohnOne Posted December 29, 2009 Share Posted December 29, 2009 Do you know the coordinates of the pixel ? Is it always in the same place, if there at all ? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ViVoxity Posted December 29, 2009 Author Share Posted December 29, 2009 Do you know the coordinates of the pixel ? Is it always in the same place, if there at all ? $Pos = MouseGetPos() $Pixel = PixelGetColor($Pos['0'], $Pos['1']) $Pixel = '0x' & Hex($Pixel, '6') GUICtrlSetData($Input, $Pixel) $Pos = MouseGetPos() GUICtrlSetData($InMpos, $Pos[0] & "," & $Pos[1]) I have the Color and the coordinate of the pixel. The coords move after small amounts of time. Link to comment Share on other sites More sharing options...
JohnOne Posted December 29, 2009 Share Posted December 29, 2009 While 1 $Pos = MouseGetPos() ;this is now x and y and assuming your piexel is at the same coords $pixel = PixelGetColor($pos[0], $pos[1]) $coords = Pixelsearch($pos[0]-5,$pos[1]-5,$pos[0]+5,$pos[1]+5,$pixel) $mousemove($coords[0],$coords[1],0) Wend AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Camden Posted December 29, 2009 Share Posted December 29, 2009 Wow, thanks for the response. I don't think the +5 -% works. Try it.. It doesn't. You have to create something like this. (Thank god for C++) $MousePosX = $Pos[0]+5 $MousePosY = $Pos[1]-5 Then create your pixel scan like so. $coord = PixelSearch($MousePosA[0], $MousePosA[1],$MousePosA[0], $MousePosA[1], $DesktopIcon) You would have to do it with X and Y though. I am pretty sure that's how I should have done it. I figured all this out while my post was being ignored. Also, I need to run a function every 5 seconds while $Var = True How would I do that? And, is there a better way to do this? While $Start = True $SlotCheck = PixelSearch(1621, 904, 1670, 940,0x593A0c) If @error = 0 Then $Bank = False Else Sleep(5000) $Start = False EndIf WEnd I'm trying to check if a pixel is somewhere, if it is, then I want it to do a task, if not I want it to do a different task. How would I go about doing this? Checkout the adlibenable functions for calling functions every x amount of time. Cheers* 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