Jump to content
Sign in to follow this  
mike1212

Any Ideas

Recommended Posts

mike1212

Hello

I need a way to check for a pixel color change at a given location,

x900 y 856 the color is normally 227359.

The color will change to 1006484 at random this is when I need to mouseclick Left?

I would like the mouse to click once then exit the loop but be ready when called upon.

I used this code to no avail.

While 1
$coord = PixelSearch( 0, 0, 90, 856, 1006484 )
If Not @error Then
    MouseClick ("left", $coord[0], $coord[1])
EndIf
WEnd
Func MyExit ()
Exit
EndFunc

TY Mike :)

Edited by mike1212

Share this post


Link to post
Share on other sites
WHRobin566

hmm ill try

while 1
if pixelgetcolor(900, 856) = 1006484 Then
Mouseclick("left", 900, 856)
endif
sleep(10)
wend

that will click where color changed i dont know if you want it to click there but if you dont then just erase the 900, 856 in mouseclick and leave it at "left" or you can put in new cords.

Hope this helps. havn't tried it. :)

Edited by WHRobin566

Witch Hunter Robin

Share this post


Link to post
Share on other sites
mike1212

hmm ill try

while 1
if pixelgetcolor(900, 856) = 1006484 Then
Mouseclick("left", 900, 856)
endif
sleep(10)
wend

that will click where color changed i dont know if you want it to click there but if you dont then just erase the 900, 856 in mouseclick and leave it at "left" or you can put in new cords.

Hope this helps. havn't tried it. :D

<{POST_SNAPBACK}>

That works great, however what is happening is it clicks when color changes

and keeps going back to the x y location to click it again. :D

I need it to click once when the pixel is correct, then exit the loop until the program

tells it to look from it again.

Getting close.

Any Idea on this?

Thanks Mike :)

Edited by mike1212

Share this post


Link to post
Share on other sites
quaizywabbit

While Not PixelGetColor(900, 856) = 227359
   checkpixelcolor()
WEnd
Func checkpixelcolor()
   If PixelGetColor(900, 856) = 1006484 Then
$mouse = MouseGetPos()
      MouseClick("left", 900, 856, 0); 0= instantaneous move
MouseMove($mouse[0],$mouse[1], 0); 0= instantaneous move
   EndIf
EndFunc  ;==>checkpixelcolor

or

While Not PixelGetColor(900, 856) = 227359
$mouse = MouseGetPos()
   MouseClick("left", 900, 856, 0); 0= instantaneous move
MouseMove($mouse[0],$mouse[1], 0); 0=instantaneous move
WEnd

dunno if this is what you're after or not.....might need a Sleep() inserted in there

edit....reread original post....added mouse return to original coordinates

Edited by quaizywabbit

[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites
mike1212

While Not PixelGetColor(900, 856) = 227359
   checkpixelcolor()
WEnd
Func checkpixelcolor()
   If PixelGetColor(900, 856) = 1006484 Then
$mouse = MouseGetPos()
      MouseClick("left", 900, 856, 0); 0= instantaneous move
MouseMove($mouse[0],$mouse[1], 0); 0= instantaneous move
   EndIf
EndFunc  ;==>checkpixelcolor

or

While Not PixelGetColor(900, 856) = 227359
$mouse = MouseGetPos()
   MouseClick("left", 900, 856, 0); 0= instantaneous move
MouseMove($mouse[0],$mouse[1], 0); 0=instantaneous move

I guess what is happening is the script stays active in the loop.

I need it to 1. wait til color changes 2. then click 3. then die.

I dont know if a command statement of  of 

WEnd

dunno if this is what you're after or not.....might need a Sleep() inserted in there

edit....reread original post....added mouse return to original coordinates

<{POST_SNAPBACK}>

It looks like the script runs and clicks the color change when its present but when color change is not present it dies.

I need it to

1. wait til color changes

2. then click

3. then die.

4. the time delay needs to be random, a set sleep delay will not work.

I think this is where the problem is.

It needs to watch for the color change and when that happens, execute, then die

right away, so the next operation is not running with this one.

Any Comments?

TY Mike :)

Edited by mike1212

Share this post


Link to post
Share on other sites
quaizywabbit

from what I understand so far, AutoIt isn't a multi-threaded language (i.e. It can't do 2 simultaneous operations)

You can:

put the rest of your script inside the while loop

call "checkpixelcolor()" periodically at strategic points in your script(or just use adlib to call it periodically)

Use it in a separate compiled script that runs only while your main script runs(this would create a separate thread, that won't interfere with the rest of your script.)

because it is a random change, it needs to stay looped to detect the change and respond immediately.

Beyond that, I'm at a loss cause' I don't know what exactly you're trying to make.

Edited by quaizywabbit

[u]Do more with pre-existing apps![/u]ANYGUIv2.8

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.