Sign in to follow this  
Followers 0
jmoney

Seemingly Simple Script

7 posts in this topic

Long time reader, first time poster.

I want to write a script that will do the following:

-When a pixel at a set position is color x, perform function x. If it is color y, perform function y. If it is color z, perform function z.

-The function would either be to left click a certain point on the screen or press a certain button.

Any help on a example script would really be appreciated. This is would be my first real script so I do not have a whole lot of code knowledge yet but I want to learn it >_<

Share this post


Link to post
Share on other sites



Code to do this could look like this

$var = PixelGetColor( 120, 160 )
If $var = 0x000000 Then MouseClick("left", 20, 780)
If $var = 0xFFFFFF Then MouseClick("left", 30, 790)

Reading and Reading and Reading the docs, especially the 'Language Reference' section, is highly suggested.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

snowmaker,

why is your script working if the help file clearly says that PixelGetColor() returns a decimal value?

It should be:

$var = Hex(PixelGetColor( 120, 160 ))

But it isn't...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

This works. I tried it before I posted it in another thread because I questioned the hex/dec thing myself. But I don't know why it does work.

$var = PixelGetColor( 120, 160 ) ;$var is decimal value
;MsgBox(0,"The color is", $var)
If $var = 0xc0c0c0 Then          ;but matches with equiv hex value
MouseClick("left", 20, 780)
EndIf
Edited by snowmaker

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

I know it works, but why?

Share this post


Link to post
Share on other sites

So to do a key instead it would be

then enter('key') ?

Also how often does it scan for pixel changes? Could I put a delay on the scans?

Thanks for the fast reply

Share this post


Link to post
Share on other sites

So to do a key instead it would be

then enter('key') ?

Also how often does it scan for pixel changes? Could I put a delay on the scans?

Thanks for the fast reply

Send("{Enter}")

While 1
    Sleep(1000) ;1 second delay
    $var = PixelGetColor( 120, 160 )
    If $var = 0x000000 Then MouseClick("left", 20, 780)
    If $var = 0xFFFFFF Then MouseClick("left", 30, 790)
WEnd

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