Jump to content

Pixelsearch


Recommended Posts

Hi IKilledBambi,

Please create descriptive topics.

Using one word topics makes it really difficult to use the search feature, and those that could probably answer your question will probably not even read your thread.

Doing it enough could cause your posting privileges to be taken away all together, and we don't want that :) .

Thanks.

Link to comment
Share on other sites

I don't know how better to explain it, maybe this will help? I cannot seem to figure out how to measure left top right bottom. Is there an easy way to measure, or do you just guess? Meaning, where does the rectangle start? 500, 500, 500, 500 seems to be really tiny, but 250, 215, 750, 500 its a decent size. What code fills up the whole screen, and how did you know without guessing.

PixelSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )
Link to comment
Share on other sites

It depends on what the PixelCoordMode option is set to.

With the default (2 :absolute screen coords) , it's desktop coords.

Say for example left and top is 50, and right and bottom is 100, it would scan a 50 pixel area, 50 pixels from the left, and 50 pixels from the top.

Basically from X:50 Y:50 to X:100 Y:100

Hope that made some sense. :)

Link to comment
Share on other sites

That helps quite a bit, now I just need to know, how many pixels would search the whole screen from the left. Here's an example.

_ _ _ _ _ _ _ _ _ _

| |

| |

| |

| 100 pixels. |

| ------------------|

| | 50 pixels |

| | |

| | |

| | |

| | |

----------------------

How many pixels would go across the whole screen from the left, and how many from the top? Or can you just give me the coordinates to search the whole screen and I can work with that?

Link to comment
Share on other sites

  • Moderators

@DesktopWidth (For a search, would start at 0 to the width)

@DesktopHeight (For a search, would start at 0 to the height)

@DesktopDepth (To confirm that you are in the right bit ratio that you got your colors to search for in)

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

Alright thanks that helped a lot but now it stopped going to the pixel.. My whole objective is to make it click unread things in the forum(to further my AI knowledge).

HotKeySet("{f6}", "S1")
HotKeySet("{f7}", "S2")

While 1
WEnd

Func S1()
    While 1
        $staple = @DesktopWidth
        $stapler = @DesktopHeight
        Sleep(100)
        MouseClick("left")
        $Coord = PixelSearch($staple, $staple, $stapler, $stapler, 0xFF0000, 5, 2)
        If Not @error Then
            MouseClick( "Left", $Coord[0], $Coord[1], 2, 0)
        EndIf
    WEnd
EndFunc ;==>S1

Func S2()
    While 1
        Sleep(6000)
    WEnd
EndFunc ;==>S2

Before I got that part added it would go to the coords and click, now it's not. I can't figure out why, any ideas?

EDIT: Alright I found out it's just not working now. I must be using the function wrong. =[

Edited by IKilledBambi
Link to comment
Share on other sites

Alright thanks that helped a lot but now it stopped going to the pixel.. My whole objective is to make it click unread things in the forum(to further my AI knowledge).

HotKeySet("{f6}", "S1")
HotKeySet("{f7}", "S2")

While 1
WEnd

Func S1()
    While 1
        $staple = @DesktopWidth
        $stapler = @DesktopHeight
        Sleep(100)
        MouseClick("left")
        $Coord = PixelSearch($staple, $staple, $stapler, $stapler, 0xFF0000, 5, 2)
        If Not @error Then
            MouseClick( "Left", $Coord[0], $Coord[1], 2, 0)
        EndIf
    WEnd
EndFunc;==>S1

Func S2()
    While 1
        Sleep(6000)
    WEnd
EndFunc;==>S2

Before I got that part added it would go to the coords and click, now it's not. I can't figure out why, any ideas?

EDIT: Alright I found out it's just not working now. I must be using the function wrong. =[

First, you do not have to store the @DekstopWidth, etc. macros in a variable(it's actually just a waste of memory), as they're available all the time.

Second, add a sleep in your While 1 WEnd loop(so it doesn't kill the CPU).

Third, what is the use for the S2 function? I don't see any use at all for it, other than somewhat awkward attempt at pausing the script. :S

Forth, the start for both left and right positions(left and top) in the PixelScan is supposed to be 0 to scan the whole screen/desktop/window(depending on what pixel coord mode you've set).

:)

Link to comment
Share on other sites

First, you do not have to store the @DekstopWidth, etc. macros in a variable(it's actually just a waste of memory), as they're available all the time.

Second, add a sleep in your While 1 WEnd loop(so it doesn't kill the CPU).

Third, what is the use for the S2 function? I don't see any use at all for it, other than somewhat awkward attempt at pausing the script. :S

Forth, the start for both left and right positions(left and top) in the PixelScan is supposed to be 0 to scan the whole screen/desktop/window(depending on what pixel coord mode you've set).

Ah alright here's the new code I thought I edited but I might have forgotten to click accept(yea i know lol)

HotKeySet("{f6}", "S1")
HotKeySet("{f7}", "S2")

While 1
Sleep( 100 )
WEnd

Func S1()
    While 1
        $Coord = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xFF0000, 2, 49.8)
        If Not @error Then
            MouseClick( "Left", $Coord[0], $Coord[1], 2, 0)
        EndIf
    WEnd
EndFunc  ;==>S1

Func S2()
    While 1
        Sleep(6000)
    WEnd
EndFunc  ;==>S2

The S2 is my awkward pause, thats the only way I have ever learned how to do it, is there a more resourceful way? And thanks for the sleep, much easier on my cpu.

Link to comment
Share on other sites

I would rather use a global variable that will pause the script's main function, something like this:

HotKeySet("{f6}", "_Pause")

Dim $paused = True

While 1
    If Not $paused Then
        $Coord = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xFF0000, 2, 49.8)
        If Not @error Then
            MouseClick( "Left", $Coord[0], $Coord[1], 2, 0)
        EndIf
        Sleep(1); Sleep a minimum ammount of time(to increase accuracy), while not paused.
    Else
        Sleep(100); Sleep longer when no action has to be taken. :P
    EndIf
WEnd

Func _Pause()
    $paused = Not $paused
EndFunc

Only one button to pause/unpause the script. :)

Link to comment
Share on other sites

  • Moderators

Thanks. =] I wouldn't in 9000 years thought of that lol.

9000 years huh? That's some learning curve :) >_

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...