Jump to content

Search for color and move to it?


Recommended Posts

How do I search an entire window for a color, then move to that color?

Can somebody give me an example script?

Whats wrong with this script? Also, when they say sizes, what is this in? Pixels around the mouse? What is a reasnable number for a normal sized window?

HotKeySet("{f7}", "tp")
$left = 1000
$top = 1000
$right = 1000
$bottom = 1000
$color = 0xff0000
$shadevar = 25
$step = 1

Func tp()
$pos = PixelSearch($left, $top, $right, $bottom, $color, $shadevar, $step)
sleep(2000)
MouseMove($pos[0], $pos[1])
sleep(2000)
MouseClick("Left")
EndFunc

while 1
    sleep(1)
WEnd
Edited by vivec45
Link to comment
Share on other sites

PixelSearch()
MouseMove()

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

PixelSearch()
MouseMove()
HotKeySet("{f7}", "tp")
$left = 1000
$top = 1000
$right = 1000
$bottom = 1000
$color = 0xff0000
$shadevar = 25
$step = 1

Func tp()
$pos = PixelSearch($left, $top, $right, $bottom, $color, $shadevar, $step)
sleep(2000)
MouseMove($pos[0], $pos[1])
sleep(2000)
MouseClick("Left")
EndFunc

while 1
    sleep(1)
WEnd

Whats wrong with this script? Also, when they say sizes, what is this in? Pixels around the mouse? What is a reasnable number for a normal sized window?

Link to comment
Share on other sites

This may not work but heres the logic behind it:

WinGetClientSize gets the Size of the CLIENT of the window. Returns the Width of window's client area, and the Height of window's client area.

Well PixelSearch searchs a rectangle that you provide ( in this case the entire window ) for a certain pixel. You have to provide the following coordinates:

The Left Most Coordinate of the Rectangle: In this case, half of your Y return for your size of the window.

The Top Mose Coordinate of the Rectangle: In this case, half of the X return for your size of the window.

And the bottom and Right will be the same as their corresponding axis.

I added Opt( "MouseCoord blah so that it will read coordinates based on the windows Client area... not your entire screen.

I rarely use PixelSearch , so I can't say I used it right. But the logics there, the helpfiles open... Maybe this helps though.

If not, I can look everything up and do it right.

Func Tp()
          $Size = WinGetClientSize ( "ENTER WINDOWS FULL TITLE HERE" ); <--- The Window Tool is Awesome.
      $Pix = PixelSearch( $Size[1]/2, $Size[0]/2, $Size[1]/2, $Size[0]/2, 0xff0000, 25, 1)
      Opt( "MouseCoordMode", 2)
      Sleep( 2000 )
      MouseClick( "Left", $pix[0], $pix[1])
EndFunc

While 1
    Sleep( 5000 )
WEnd
Edited by Drew
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...