Sign in to follow this  
Followers 0
poisonkiller

PixelSearch()

7 posts in this topic

Whats the problem? I have no idea how can i make this work! Plz help!

While 1
    HotKeySet("^h", "Pixel")
    Sleep(100)
WEnd
Func Pixel()
    $col = "100"
    Sleep(2000)
    $pix = PixelSearch(0, 0, 1023, 767, $col)
    MouseMove($pix[0], $pix[1])
    Sleep(500)
    Exit
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Most likely the "100", which may not be the colour you want (I think it's equivalent to HTML #000064). This should move the mouse to the first white location on the screen:

Global $PixelColor = 0xFFFFFF
HotkeySet("^h", "Pixel")

Func Pixel()
    Local $PixelLoc = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, $PixelColor)
    If Not(@Error) Then MouseMove($PixelLoc[0], $PixelLoc[1])
EndFunc

While 1
    Sleep(0x7FFFFFFF)
WEnd

Edit: I've not played around with the MouseMove() command since its v2 incarnation. It's fantastic how it smoothly moves to the new location with varying speed!

Edited by LxP

Share this post


Link to post
Share on other sites

What this :

While 1
    Sleep(0x7FFFFFFF)
WEnd

does? Is this sleep 0xFFFFFFF color?

Share this post


Link to post
Share on other sites

0x7FFFFFFF is the longest number autoit can support.

wich means that this will get you the lowest cpu usage possible.

No, the largest possible number AutoIt should be able to support is somewhere around 2^(64-1) or the maximum size of a 64-bit signed integer. The Windows API function Sleep() takes a DWORD which is an unsigned long so with a 32-bit unsigned long the maximum value is actually 0xFFFFFFFF. However, AutoIt doesn't use the Sleep() function directly when AutoIt's Sleep() is called.

Share this post


Link to post
Share on other sites

So out of curiosity, why is it that AutoIt can support numbers as large as 9,223,372,036,854,775,807 in decimal notation but will only support numbers as large as 2,147,483,647 in hex notation?

Share this post


Link to post
Share on other sites

Primarily because nobody ever expanded the hex notation to support more than 8 characters.

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