Jump to content

Little help with color recognating script


R4WR
 Share

Recommended Posts

Hello,

I am kinda new to all the scripting (still a newbie) and I needed some help with following script:

What I need to to do is:

- check pixel color --> (color = 0x214252 ; pixel = 470, 667) --> if so keep right clicking it (repeat)

- untill it changes --> then Alt tab, click (pixel = 494, 475), Alt tab (back to 1st window), moove mouse to go and check pixel again (pixel = 470, 667)

Im not sure about: PixelGetColor, PixelGetPos, Alt+Tab and the overall scripting interpretation (since im new ot this)

CODE
HotKeySet("{DELETE}", "Stop") ;script can be stopped by pressing DELETE

$Color = PixelGetColor ("0x214252"); check if pixel has got certain color

While 1 ;repeat endlessly

If $Color = 1 ;pixel has color 0x214252

Then

MouseClick ( "right", 470, 667, 1 , 2 )

Sleep ("600")

If $Color = 0 ;pixel has other color

Then

Send ("Alt+Tab") ;is Alt+Tab put in right?

Sleep("600")

Mouseclick ( "left", 494, 475, 1, 2)

Send("Alt+Tab")

Sleep("600")

MouseGetPos (470, 667) ;mouse goes back to position for colorcheck

WEnd ;repeat

Func Stop() ;to allow the script to stop

Exit ;same

EndFunc ;same

Link to comment
Share on other sites

Link to comment
Share on other sites

You are all screwed up :)

try this

HotKeySet("{DELETE}", "Stop") ;script can be stopped by pressing DELETE

While 1 ;repeat indefinitly
    $Color = PixelGetColor (470,667); get decimal color value of pixel (470,667)
    If $Color = 0x214252 then ; compare color to 0x214252  and if it is the same then
        MouseClick ( "right", 470, 667, 1 ,0 );rightclick on the pixel
        Sleep(600) ; wait for 6/10 of a second
    Else ; if its not the same
        Send("!{TAB}");send Alt+Tab
        Sleep(600);wait
        Mouseclick ( "left", 494, 475, 1, 2) ; leftclick on (494,475)
        Sleep(600); wait again
    EndIf
WEnd ; repeat


Func Stop() ;to allow the script to stop
    Exit ;same
EndFunc ;same
Edited by Paulie
Link to comment
Share on other sites

  • Developers

For the record: your Sleep("600") are wrong too, should be Sleep(600) if you want your script to pause for 600ms. :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thank you all so much :-D

Damn, I wanna study this too so I can learn how to do this without having to ask help.

But, I guess I didn't do too bad for the first try. :-)

I'll let u know if it worked how I expected it to work

Grtz, anna

Link to comment
Share on other sites

after some minor changes (sleep times and stuff) it worked

a next accomplishment wud be to do this minimised... feel free to hook me up, but its not necesaraly.

HotKeySet("{DELETE}", "Stop") ;script can be stopped by pressing DELETE

While 1 ;repeat indefinitly
    $Color = PixelGetColor (470,667); get decimal color value of pixel (470,667)
    If $Color = 0x214252 then ; compare color to 0x214252  and if it is the same then
        MouseClick ( "right", 470, 667, 1 ,0 ) ; rightclick on the pixel
        Sleep(600) ; wait for 6/10 of a second
    Else ; if its not the same
        Send("!{TAB}");send Alt+Tab
        Sleep(600);wait
        Mouseclick ( "left", 494, 475, 1, 2) ; leftclick on (494,475)
        Sleep(1600);wait
        Mouseclick ( "right", 250, 20, 1, 2) ; rightclick on (250, 20)
        Sleep(1600);wait
        Send("!{TAB}");send Alt+Tab
        Sleep(6000); wait again
    EndIf
WEnd ; repeat


Func Stop() ;to allow the script to stop
    Exit ;same
EndFunc ;same

Grtz, and thx again

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