Sign in to follow this  
Followers 0
IKilledBambi

Pixelsearch

16 posts in this topic

I'm having serious troubles with the left top right bottom.. is there any way to work it out other than random guessing? Don't worry my resolution is correct. =]

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
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]] )

Share this post


Link to post
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. :)

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Is this for a game? If so...what game


"I think, therefore I am"[size="1"]René Descartes[/size]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

My whole objective is to make it click unread things in the forum(to further my AI knowledge).

I'm pretty sure your not even allowed to talk about using it for games on this site. Edited by IKilledBambi

Share this post


Link to post
Share on other sites

You are. There are tutorials on how to make them for flash games, such as curveball. I was helped before on a pixelbot too.


"I think, therefore I am"[size="1"]René Descartes[/size]

Share this post


Link to post
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).

:)

Share this post


Link to post
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.

Share this post


Link to post
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. :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Haha.

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