Jump to content

Find pixel


lopolop
 Share

Recommended Posts

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

Link to comment
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 *

Link to comment
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)

Link to comment
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 *

Link to comment
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]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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]

Link to comment
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?

Edited by lopolop
Link to comment
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]

Link to comment
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....

Link to comment
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]

Link to comment
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)

Link to comment
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
Link to comment
Share on other sites

  • Moderators

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.

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