Sign in to follow this  
Followers 0
ViVoxity

Searching Pixels

7 posts in this topic

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 ;)

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by danielmohr91

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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*

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