Sign in to follow this  
Followers 0
lopolop

Find pixel

25 posts in this topic

hey i was woundering if i could use

PixelGetColor ( 437 , 482 )

for a certain coordinate

then checks the value it gets to see if its equal too 0xBDA694

If it isnt equal to that value then have it check every like 7 seconds....

once it finds that value finish the code....


Share this post


Link to post
Share on other sites



hey i was woundering if i could use

PixelGetColor ( 437 , 482 )

for a certain coordinate

then checks the value it gets to see if its equal too 0xBDA694

If it isnt equal to that value then have it check every like 7 seconds....

once it finds that value finish the code....

yes, you can do that with PixelGetColor().

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

You would do it like this:

$x = 0;set $x equal to 0
While $x = 0;keep on doing the same thing until $x is not 0 anymore
    $color = PixelGetColor(437,482);get the color of the pixel at 437,482 and store the color (as decimal) in $color
    If $color = Dec("0xBDA694") Then;check if the pixel has the color you want (your hex colorcode has to be converted to dec)
        $x = 1;if the two colors match do the stuff (set $x equal to 1 (unnessecary^^))
        ExitLoop;exit the While loop
    Else;if the colors don't match do the following stuff
        Sleep(7000);sleep for 7 secs
    EndIf;end the if statement
Wend;defines the end of the while loop

Lol, the commenting took 5x longer than writing the code^^

HF

Felix N. (tdlrali)

Share this post


Link to post
Share on other sites

do 
    sleep(7000)
until PixelGetColor(437,482 ) == dec("BDA694")
exit(0)

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

felix your way would work but... i need a little more help how could i set something at random i want it to mouseclick at 1 of 5 points(randomly) how would i do the random mouse click?


Share this post


Link to post
Share on other sites

felix your way would work but... i need a little more help how could i set something at random i want it to mouseclick at 1 of 5 points(randomly) how would i do the random mouse click?

Thats easy!!!!!!!!!

While 1
      $x=Int(Random(0,6))
      $y=Int(Random(0,6))     
         MouseClick("LEFT",$x,$y,0)
WEnd

http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

o think thats not what i ment...

i need it to click say point

423, 564

or

463,534

or

433,502

(3 more points) i want it to click one of thoese at random

also can i use

$color = PixelGetColor( , )

more then once with out getting any errors like to find a different pixel at different point if the first

$color = PixelGetColor(372,476) isnt found?

Edited by lopolop

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

o think thats not what i ment...

i need it to click say point

423, 564

or

463,534

or

433,502

(3 more points) i want it to click one of thoese at random

How about this? (fill in the coords)

Switch Random(0, 5, 1); Integer between 0 and 5
  Case 0
      $x = 423
      $y = 564 
  Case 1
      $x = 463
      $y = 534 
  Case 2
      $x = 433
      $y = 502 
  Case 3
      $x = 423
      $y = 564 
  EndSwitch
  MouseClick("left",$x,$y)

Edit: MouseClick was wrong...

Edited by Skruge

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

so it would be

$x = 0
While $x = 0
    $color = PixelGetColor(437,482)
    If $color = Dec("0xBDA694") Then
        $x = 1
        Switch Random(0, 5, 1)
  Case 0
      $x = 423
      $y = 564
  Case 1
      $x = 463
      $y = 534
  Case 2
      $x = 433
      $y = 502
  Case 3
      $x = 423
      $y = 564
  Case 4
      $x = 420
      $y = 580
  Case 5
      $x = 330
      $y = 220
  EndSwitch
  MouseClick("left",$x,$y)
        ExitLoop
    Else
        Sleep(7000)
    EndIf
Wend

and $x wont interfear?

Edited by lopolop

Share this post


Link to post
Share on other sites

so it would be

$x = 0
While $x = 0
    $color = PixelGetColor(437,482)
    If $color = Dec("0xBDA694") Then
        $x = 1
        Switch Random(0, 5, 1)
  Case 0
      $x = 423
      $y = 564
  Case 1
      $x = 463
      $y = 534
  Case 2
      $x = 433
      $y = 502
  Case 3
      $x = 423
      $y = 564
  Case 4
      $x = 420
      $y = 580
  Case 5
      $x = 330
      $y = 220
  EndSwitch
  MouseClick("left",$x,$y)
        ExitLoop
    Else
        Sleep(7000)
    EndIf
Wend

and $x wont interfear?

In that case, it would...

I was using $x and $y as an example. You would need to change either of the variable names before integrating it into your code.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

I did almost the same so i won't post it...

BTW you need the beta for this!

If you don't wanna use the beta (why wouldn't you wanna use it? i dont know^^), tell me/us.

I have another version that doesn't require the beta.

Felix N. (tdlrali)

Share this post


Link to post
Share on other sites

np i got beta.... lol


Share this post


Link to post
Share on other sites

inorder to make my program work i need this window where i am trying to find the pixels and stuff in the same spot each time how can i wait for the program to come up(know how too) then move it too 0,0 like when u maximze the screen the top left hand corner is there....


Share this post


Link to post
Share on other sites

inorder to make my program work i need this window where i am trying to find the pixels and stuff in the same spot each time how can i wait for the program to come up(know how too) then move it too 0,0 like when u maximze the screen the top left hand corner is there....

Try this:

Local $WinTitle = "Fill in the blank"
WinWait($WinTitle)
WinMove($WinTitle, "", 0, 0)

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

ok ill check that in a sec but for some reason endswotch isnt showing up like its plain text(usin scite) and i get this error

(23) : ==> "Case" statement with no matching "Select" statement.:

Case 0


Share this post


Link to post
Share on other sites

Hmm what does your whole script look like? like this?:

Local $WinTitle = "Fill in the blank"
WinWait($WinTitle)
WinMove($WinTitle, "", 0, 0)

$i = 0
While $i = 0
    $color = PixelGetColor(437,482)
    If $color = Dec("0xBDA694") Then
        $i = 1
    Switch Random(0, 5, 1)
    Case 0
      $x = 423
      $y = 564
    Case 1
      $x = 463
      $y = 534
    Case 2
      $x = 433
      $y = 502
    Case 3
      $x = 423
      $y = 564
    Case 4
      $x = 420
      $y = 580
    Case 5
      $x = 330
      $y = 220
  EndSwitch
  MouseClick("left",$x,$y)
        ExitLoop
    Else
        Sleep(7000)
    EndIf
Wend

If you have it like that it should work....

B)

Felix N. (tdlrali)

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

it doesnt i get the same error....

Edited by lopolop

Share this post


Link to post
Share on other sites

i keep getting

"Case" statement with no matching "Select" statement.: Case 0


Share this post


Link to post
Share on other sites

ok i found this out... the

the

$i = 0
While $i = 0
    $color = PixelGetColor(437,482)
    If $color = Dec("0xBDA694") Then
        $i = 1

isnt working witha little trial and error i was able to do this.... which works except clicks one button over and over again instead of 1 of the 5 ill keep trying though

While 1
MouseMove( 236 , 470 )
Sleep(3500)

$var = PixelGetColor( 236 , 470 )
If $var = 5985882 Then
MouseClick("left",425,475)
Else
Sleep(0)
EndIf
WEnd

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

hmm, well your script says to click x-425 and y-475 only if it finds 5985882, so I would imagine that's the only button it's clicking.

From Felix's code... Try this:

Opt("PixelCoordMode", 0)
Opt("MouseCoordMode", 0)
Dim $WinTitle = "Fill in the blank"
WinWait($WinTitle)
WinMove($WinTitle, "", 0, 0)


While 1
    $color = PixelGetColor(437,482)
    If $color = 5985882 Then
    $RANDOM = Random(0, 5, 1)
    Select
    Case $RANDOM = 0
      $x = 423
      $y = 564
    Case $RANDOM = 1
      $x = 463
      $y = 534
    Case $RANDOM = 2
      $x = 433
      $y = 502
    Case $RANDOM = 3
      $x = 423
      $y = 564
    Case $RANDOM = 4
      $x = 420
      $y = 580
    Case $RANDOM = 5
      $x = 330
      $y = 220
  EndSelect
  MouseClick("left",$x,$y)
    Else
        Sleep(7000)
    EndIf
Wend

Edit: I took $i and exitloop out, if you want to exit the loop, you can put them back in, but it seemed like you wanted to click different places, and you'll need to edit the $x and $y coords to what you need.

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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