Sign in to follow this  
Followers 0
Doodec

Pixel Color and Key to trigger keystroke.

2 posts in this topic

#1 ·  Posted (edited)

Hi Guys

First, please forgive me if this question is noobish but im just starting with AutoIt.

I used search option and googled the problem but the only similar subject found give me the example of code below.

Source:

Func _NG
    $n = PixelGetColor(386, 45)
    $g = PixelGetColor(380, 43)
        $ngd = 0
        Select
        Case $n = 0x00FFFF and $g = 0x00FFFF and $ngd = 0
                send("{g down}" & "{n down}")
                                $ngd = 1
        Case $n <> 0x00FFFF and $g <> 0x00FFFF and $ngd = 1
                send("{g up}" & "{n up}")
        EndSwitch

endfunc

While 1

    _NG()
    _G()
    _N()

Wend

I can clarly understand the code above but cant write similar one to work the way I planned.

Making long story short:

I need script to check if X,Y Pixel COlor = Black is True THEN check if another X,Y Pixel COlor is one of other FIve colors.

If the aboove conditions are met then script waits for me to push triger button to send keystroke.

The Black Pixels may appear in three possible X,Y positions (2nd Black pixel will not appear if the key to triger is not pressed so there is no point in tracking all three Black to appear at the same time). Read further please... I hope It will become more clear..)

1BlackX=342

1BlackY=425

2BlackX=377

2BlackY=423

3BlackX=454

3BlackY=357

The Colour Pixels may appear in three possible X,Y positions. (under 1Black, 2Black, 3Black)

1ColorX=341

1ColorY=436

2ColorX=378

2ColorY=436

3ColorX=454

3ColorY=436

The Colour Pixels Codes are (taken from AutoIt Window Info) red, blue, white, green, yellow.

black=0x000000

white=0xFFFFFF corresponding key to press = g

red=0x0000FF corresponding key to press = h

yellow=0x00FFFF corresponding key to press = j

blue=0xFF0000 corresponding key to press = k

green=0x00FF00 corresponding key to press = l

The Keystrokes are

g h j k l

Activator

;

So the script should :

1) Look for 1Black pixel to appear (342,425) if true then

2) Get Pixel color from 1color (341,436) and then send coresponding Key (g,h,j,k or l) and wait and send it but only after I press ";" (activator) key. If activator not pressed wait 4 sec and start again from begining.

3) If activator pressed

4) Look for 2Black pixel to appear (377,423) - if not start from beginning.

5) Get Pixel color from 2color (377,436) and then send coresponding Key (g,h,j,k or l) and wait and send it but only after I press ";" (activator) key. If activator not pressed wait 4 sec and start again from begining.

6) If activator pressed look for 3Black to appear ....

Loop

Ufff.... I made a long story after all :x I explained as clear as possible. After a few days searching and trying to write it myself I gave up. The necessary code is just to complicated for newbie like me. I know its time consuming but is there a chance that any of you guys could help me in relation to the above???

Thanks and regards

PS. Apologies for my English.

Edited by Doodec

Share this post


Link to post
Share on other sites



It took me almost whole weekend but I did it myself :x Topic to be closed.

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