Sign in to follow this  
Followers 0
ViVoxity

More Pixel Searching

3 posts in this topic

#1 ·  Posted (edited)

After a couple years break, I've decided I want to make an auto-clicker for my extremely repetitive task..

But my search func doesn't work.

All I really need the program to do is find a section on the screen, search for the pixel, hover and click.

Here is what I have so far.

The issue I am having is it either clicks in the top left corner, or the bottom right..

Never on the pixel.

What am I doing wrong?

#Include <GUIConstantsEx.Au3>
#Include <WindowsConstants.Au3>
Opt ('GUIOnEventMode','1')
        Sleep(5000)
        HotKeySet("{F8}","_Search")
        HotKeySet("{F9}","_Pause")
Global $Pause = False
Global $test = True

$GUI = GUICreate ('Current Pixel','150','20','-1','-1','-1','128')
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')
$Input = GUICtrlCreateInput ('','0','0','150','20','1')
GUICtrlSetFont ($Input, '9','600','','Arial')
GUICtrlSetState ($Input, $GUI_DISABLE)
GUISetState (@SW_SHOW, $GUI)
WinSetOnTop ($GUI, '','1')



While '1'
If $Pause = False Then
$Pos = MouseGetPos ()
$Pixel = PixelGetColor ($Pos['0'], $Pos['1'])
$Pixel = '0x' & Hex ($Pixel, '6')
GUICtrlSetData ($Input, $Pixel)
EndIf
WEnd

Func _Search()
$Color=0x552D1B
$pixelsearch = PixelSearch(0, 0, 157, 709, 0x552D1B, 1, 2)
If @error=1 Then
 MouseClick("left", $pixelsearch, $pixelsearch, 1)
  Sleep(1000)
EndIf
EndFunc

Func _Pause ()
If $Pause = False Then
$Pause = True
ClipPut (GUICtrlRead ($Input))
Else
$Pause = False
EndIf
EndFunc

Func _Exit ()
Exit
EndFunc
Edited by ViVoxity

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Well why don't you start by fixing those numbers and arrays.

You need to read the helpfile, "Language Reference - Datatypes"

Then the wiki, Arrays

I actually went and did some reading and messing around, and I've withered it down to a better post.

I'm running the _Func Function in my script and I'm trying to move my mouse to the position of an exact pixel.

I have created a new gui that lets me see my current pixel, then I pause the script.

Here's where my Issue is.

Func _Search()
    $coord = PixelSearch(0, 0, 1680, 1050, 0xC70A2F)
    MouseClick("left", $coord, $coord, 2)
EndFunc   ;==>_Search

1680 and 1050 is my screen resolution, that would be my entire screen right?

When I run my function the mouse goes to 0,0 and clicks instead of going to the color.

Wow, Array's are awesome ;)

Everything is working now :evil:

Func _Search()
    $coord = PixelSearch(0, 0, 1680, 1050, 0xC70A2F)
    MouseClick("left", $coord[0], $coord[1], 2)
EndFunc   ;==>_Search
Edited by ViVoxity

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0