Sign in to follow this  
Followers 0
Jmjl

If Statements

12 posts in this topic

Ok, I know this sounds kind of n00bish but I can seem to figure something out invovling If statements. I've looked in the help and it didn't help :D. I understand the concept and I know how it works (I program in VB) only I can't seem to figure this out. What I want to do is constantly be checking the pixel colour in a specific pixel and if the pixel colour equals a certain hex value say red FF0000 then to click on that location only I can't figure it out. Thanks for the help!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

did you try it, already? Show your script, please.

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Does it look something like this?

While 1 = 1
$pixel = PixelGetColor(10,100);or whereever your location is
If Hex($pixel) = FF0000 Then
;do stuff here if it is red
;Else
;could do an else, but its not required
EndIf
WEnd

If so, you're on the right track.

Edited by ending

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yeah, that is pretty much exactly what my code is except I didn't have the

If Hex($pixel) = FF0000 Then

I didn't have the hex part. Does that really matter? Either way when I run your code I still get the error:

Posted Image

Any solutions?

Edited by Jmjl

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi,

what about showing your try? Maybe this helps out 'FF0000'

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Yeah, that is pretty much exactly what my code is except I didn't have the

If Hex($pixel) = FF0000 Then

I didn't have the hex part. Does that really matter? Either way when I run your code I still get the error:

Posted Image

Any solutions?

Your use of the hex number is wrong. For hex you need 0x prefix. Try:

$Color = 0xFF0000 ; edit for color (RGB hex)
$x = 200 ; edit for x pos
$y = 200 ; edit for y pos
While 1
     If PixelGetColor($x,$y) = $Color Then
          ;do stuff here if it is red
          MouseClick($x, $y)
     ;Else
          ;could do an else, but its not required
     EndIf
WEnd

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

THANKS! It worked. I truly appreciate it!

This is just a side quesiton and not really important but it would be nice to have, is there a way to check a range of pixels? i.e. 30, 200 to 50, 300 or something like that?

Share this post


Link to post
Share on other sites

THANKS! It worked. I truly appreciate it!

This is just a side quesiton and not really important but it would be nice to have, is there a way to check a range of pixels? i.e. 30, 200 to 50, 300 or something like that?

Maybe something like PixelChecksum?

Share this post


Link to post
Share on other sites

Or perhaps

For $x = 30 To 50
    For $y = 200 To 300
        If PixelGetColor($x, $y) = 0xFF0000 Then MsgBox(0, "", "Pixel found at :" & $x & ", " & $y)
    Next
Next

Alzo...


Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

THANKS! It worked. I truly appreciate it!

This is just a side quesiton and not really important but it would be nice to have, is there a way to check a range of pixels? i.e. 30, 200 to 50, 300 or something like that?

Check out the PixelSearch() function, which searches a defined rectangle for a color:

$Color = 0xFF0000
$XYResult = PixelSearch(30, 200, 50, 300, $Color)
If @error Then
     MsgBox(16, "Failed", "Color " & $Color & " not found.")
Else
     MsgBox(64, "Success", "Found color " & $Color & " at x=" & $XYResult[0] & ", y=" & $XYResult[1])
EndIf

Edit: Tweak... thanks Daniel W.

:D

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Check out the PixelSearch() function, which searches a defined rectangle for a color:

$Color = 0xFF0000
$XYResult = PixelSearch(30, 200, 50, 300, $Color
If @error Then
     MsgBox(16, "Failed", "Color " & $Color & " not found.")
Else
     MsgBox(64, "Success", "Found color " & $Color & " at x=" & $XYResult[0] & ", y=" & $XYResult[1])
EndIfoÝ÷ Ûú®¢×ºÚ"µÍÌÍÐÛÛÜHÌÍÖTÝ[H^[ÙXÚ
Ì
LÌ ÌÍÐÛÛÜ
BYÜ[ÙÐÞ
M   ][ÝÑZ[Y   ][ÝË  ][ÝÐÛÛÜ    ][ÝÈ  [È ÌÍÐÛÛÜ    [È ][ÝÈÝÝ[][ÝÊB[ÙBÙÐÞ
    ][ÝÔÝXØÙÜÉ][ÝË ][ÝÑÝ[ÛÛÜ ][ÝÈ  [È ÌÍÐÛÛÜ    [È ][ÝÈ]I][ÝÈ  [È ÌÍÖTÝ[ÌH   [È ][ÝËOI][ÝÈ  [È ÌÍÖTÝ[ÌWJB[Y

You missed the ")" after $Color :D


--------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote]

Share this post


Link to post
Share on other sites

Works great, thanks guys!

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