Jump to content

IF Color


Recommended Posts

I have the coordinates of an specific Pixel and the color of it.

Now i need help on how to work with it!

I want to make a script, that presses a key, looks if the color in that pixel is corect and if the color is corect it presses another key. if the color is wrong it presses the first key again.

and then i need a detection, that waits until the color of that specific pixel is changed and then it should start another script, where it presses another key and waits some time and then starts in the beginning with the first key again.

can somebody write me code that does something like that?

Link to comment
Share on other sites

No-one is going to write a script for you here.

You are looking for http://www.rentacoder.com/RentACoder/DotNet/default.aspx

However if you wish to learn how to write the code yourself, you should start in the helpfile, with pixelsearch(,) If..Else..EndIf loops, and MouseClick(), ControlClick.

Try a script and ask for help if you are stuck on anything.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I have the coordinates of an specific Pixel and the color of it.

Now i need help on how to work with it!

I want to make a script, that presses a key, looks if the color in that pixel is corect and if the color is corect it presses another key. if the color is wrong it presses the first key again.

and then i need a detection, that waits until the color of that specific pixel is changed and then it should start another script, where it presses another key and waits some time and then starts in the beginning with the first key again.

can somebody write me code that does something like that?

Yep I can...

All you have to do is give me credit and the code is yours..

; Credits to DarK_St3alth
; Srry, can't use tabs here

HotKeySet("{F1}", "Check")
HotKeySet("{ESC}", "Terminate")

Func Check ()
 if $datapoint = true then
 $var2 = PixelGetColor( 10 , 100 )
 MsgBox(0,"Compair", $var&" to "&$var2)
 endif
 $var = PixelGetColor( 10 , 100 )
 $datapoint = true
 MsgBox(0,"The decmial color is", $var)
 MsgBox(0,"The hex color is", Hex($var, 6))
Endfunc
Edited by sniper120
Link to comment
Share on other sites

kackagent,

I can help you write it, but I will not write it for you :D

If you already have the colour and co-ordinates then you can use PixelGetColor() to see if the co-ordinates have the colour. As the function returns the colour at the co-ordinates given, you can check it against the one you have.

James

Edited by JamesBrooks
Link to comment
Share on other sites

kackagent,

I can help you write it, but I will not write it for you :D

If you already have the colour and co-ordinates then you can use PixelGetColor() to see if the co-ordinates have the colour. As the function returns the colour at the co-ordinates given, you can check it against the one you have.

James

*Don't tell them: It's buggy, & wrote it off my head. I don't know if it works or not XD*

Link to comment
Share on other sites

Congrats, you used the exact code from the help file, put it into a function and called it your own. Very well done to you Sir. Posted Image

Well part of it. The PixelGetColor.. Durr... Everyone should be able to tell that. I added the hotkey udf part (less, I'm lazy and it would take 3 seconds for someone to look and find it >.>) and mashed it together.

Link to comment
Share on other sites

Well sniper120, you're script is defunct anyway and wouldn't pass the Au3Check.

; Credits to DarK_St3alth
; And no need to credit me, JamesBrooks

HotKeySet("{F1}", "FindCol")
HotKeySet("{ESC}", "Terminate")

Dim $xX = 10, $yY = 100

While 1
    Sleep(500)
WEnd

Func FindCol()
    Check($xX, $yY)
EndFunc

Func Check($X, $Y)
    $var = PixelGetColor($X, $Y)
    MsgBox(0, "The decmial color is", $var)
    MsgBox(0, "The hex color is", Hex($var, 6))
EndFunc

Func Terminate()
    Exit
EndFunc
Link to comment
Share on other sites

okay, i tried for very much hours now to get it work ... but ... i cant think all that logic things ... i am dumb or something ... :D

here is wat i wanna try yet:

1. monitor the Pixel

2. Wait until the Pixel gets the correct Color

3. If the Color is correct press key "1"

4. Wait until the Color doesnt match the correct Color

5. Press key "2"

6. Start at 1. again.

Link to comment
Share on other sites

okay, i tried for very much hours now to get it work ... but ... i cant think all that logic things ... i am dumb or something ... :D

here is wat i wanna try yet:

1. monitor the Pixel

2. Wait until the Pixel gets the correct Color

3. If the Color is correct press key "1"

4. Wait until the Color doesnt match the correct Color

5. Press key "2"

6. Start at 1. again.

Hi mate, show the code you have tried, and Im certain you will get all the help you need.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Hi mate, show the code you have tried, and Im certain you will get all the help you need.

#include <GUIConstantsEx.au3>

GUICreate("AutoIT", 335, 100)

GUISetState(@SW_SHOW)

Do

Send ( "{TAB}" )

If PixelGetColor (645, 29) = 0xFF0000 Then

Send ( "{1}" )

Else

Send ( "{2}" )

EndIf

Until PixelGetColor (645, 29) = *******

This is what i have till now, i dont know if it is correct to this point, i am a total newb :D

Now i need a loop and something for the "*******" <-- i just dont know how to tell him just to check if the color is the same ... the color in this point always changes, he should only wait until it is "0xFF0000" and stop if it is NOT "0xFF0000"

Link to comment
Share on other sites

See, when you are using a function you are not sure about, you should always read the help documentation about it.

For instance, you are using Send() incorrectly in some of the lines of your code I think.

I think 'Send ( "{1}" )'

Should Be Send("1")

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>

GUICreate("AutoIT", 335, 100)


GUISetState(@SW_SHOW)

While 1

    Do
        If PixelGetColor (563, 73) = 0xFFFFFF Then
            Send ( "1" )
        Else
            Send ( "2" )
        EndIf
WEnd

thats my script and it seems to work ... but it is spamming the buttons now! i need him to only send the button once

Edited by kackagent
Link to comment
Share on other sites

How does this work for you?

#include <GUIConstantsEx.au3>

Dim $pixFound = False

GUICreate("AutoIT", 335, 100)

GUISetState(@SW_SHOW)

Do
    If PixelGetColor (563, 73) = 0xFFFFFF Then
        Send ( "1" )
        $pixFound = True
    Else
        Send ( "2" )
    EndIf
Until $pixFound

MsgBox(0, "", "FOUND!")
Link to comment
Share on other sites

thats my script and it seems to work ... but it is spamming the buttons now! i need him to only send the button once

Try

#include <GUIConstantsEx.au3>

GUICreate("AutoIT", 335, 100)


GUISetState(@SW_SHOW)

While 1

    
        If PixelGetColor (563, 73) = 0xFFFFFF Then
            Send ( "1" )
            Exitloop
        Else
            Send ( "2" )
            ExitLoop 
        EndIf

WEnd
Exit

This will end your script once a button is clicked

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Try

#include <GUIConstantsEx.au3>

GUICreate("AutoIT", 335, 100)


GUISetState(@SW_SHOW)

While 1

    
        If PixelGetColor (563, 73) = 0xFFFFFF Then
            Send ( "1" )
            Exitloop
        Else
            Send ( "2" )
            ExitLoop 
        EndIf

WEnd
Exit

This will end your script once a button is clicked

AutoIt Error

Line 77 (File ""):

Error: "Wend" statement with no matching "While" statement.

Link to comment
Share on other sites

  • Developers

Try

#include <GUIConstantsEx.au3>

GUICreate("AutoIT", 335, 100)


GUISetState(@SW_SHOW)

While 1

    
        If PixelGetColor (563, 73) = 0xFFFFFF Then
            Send ( "1" )
            Exitloop
        Else
            Send ( "2" )
            ExitLoop 
        EndIf

WEnd
Exit

This will end your script once a button is clicked

Why do you have the ExitLoop and While-Wend statements in this scriptlet?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

How does this work for you?

#include <GUIConstantsEx.au3>

Dim $pixFound = False

GUICreate("AutoIT", 335, 100)

GUISetState(@SW_SHOW)

Do
    If PixelGetColor (563, 73) = 0xFFFFFF Then
        Send ( "1" )
        $pixFound = True
    Else
        Send ( "2" )
    EndIf
Until $pixFound

MsgBox(0, "", "FOUND!")

without that "MsgBox" and with "While 1" "WEnd" it keeps spamming the buttons. but thanx for the help :D
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...