Jump to content

Whats wrong { Solved } - Pixel Search


LibertyMan
 Share

Recommended Posts

I must be doing wrong, help me please...

It's not finding the color and running tooltip()

The Color is there & the color is already in hex form...

;Pre-Set Colors! ---> Start
Global $Green = "30E730" , $Yellow = "CACA2E" , $Purple = "D21CD2" , $White = "F7F7F7" , $Blue = "2289E2" , $Orange = "F69535" , $Red = "FE6161"
;End Pre-Set Colors --> End
$x = 315
$y = 217

For $y2 = 192 to $y ; 286 ; The Start 
For $x2 = 285 to $x ; 193 ; The End

$test = PixelGetColor ($x2,$y2)
If Hex($test,6) = $Green Or $Yellow Or $Purple Or $White Or $Blue Or $Orange Or $Red Then
  Case  $test = $Yellow
        ToolTip("Yellow")
    Sleep(3000)
    _WriteLog()
    Case  $test = $Purple
        ToolTip("Purple")
Sleep(3000)
    Case $test = $White
        ToolTip("White")
Sleep(3000)
    Case $test = $Blue
        ToolTip("Blue")
Sleep(3000)
    Case $test = $Orange
        ToolTip("Orange")
Sleep(3000)
    Case $test = $Red
        ToolTip("Red")
Sleep(3000)
    Case Else
    ToolTip("Cant Find Matching Color YET!")
    ;Sleep(4000)
EndSelect
EndIf
Next
Next
Edited by LibertyMan
Link to comment
Share on other sites

Next

Next should be at end...

My problem is not that, updated

first post so peoples may know.

My problem is detecting the color...

It's pulling the hex numbers, but not saying the color n text.

Edited: Thought maybe I wrote the case wrong or something?...

Case Hex($test,6) = hex(0X30E730,6)
Tooltip("GREEN")
Sleep(3000)
 and even
 Case $test = 30E730
Tooltip("GREEN")
Sleep(3000)
Edited by LibertyMan
Link to comment
Share on other sites

Heh,..

forgot to add hex On $test Updating first post and changing to solved.

Thank you..

Case  $test = $Yellow
        ToolTip("Yellow")
    Sleep(3000)
    _WriteLog()
    Case  $test = $Purple
        ToolTip("Purple")
Sleep(3000)
    Case $test = $White
        ToolTip("White")
Sleep(3000)
    Case $test = $Blue
        ToolTip("Blue")
Sleep(3000)
    Case $test = $Orange
        ToolTip("Orange")
Sleep(3000)
    Case $test = $Red
        ToolTip("Red")
Sleep(3000)
    Case Else
    ToolTip("Cant Find Matching Color YET!")
    ;Sleep(4000)
EndSelect
EndIf
Next
Next
Link to comment
Share on other sites

Hi,

#Include <Misc.au3>
;Pre-Set Colors! ---> Start
Global $Green = 0x30E730 , $Yellow = 0xCACA2E , $Purple = 0xD21CD2 , $White = 0xF7F7F7 , $Blue = 0x2289E2 , $Orange = 0xF69535 , $Red = 0xFE6161

While Not _IsPressed("1B") ; Esc to exit
    Sleep(10)
    $aMGP = MouseGetPos()
    $Color = Hex(PixelGetColor($aMGP[0],$aMGP[1]), 6)
    Switch $Color
        Case Hex($Green, 6)
            ToolTip("Green")
        Case Hex($Yellow, 6)
            ToolTip("Yellow")
        Case  Hex($Purple, 6)
            ToolTip("Purple")
        Case Hex($White, 6)
            ToolTip("White")
        Case Hex($Blue, 6)
            ToolTip("Blue")
        Case Hex($Orange, 6)
            ToolTip("Orange")
        Case Hex($Red, 6)
            ToolTip("Red")
        Case Else
            ToolTip("Cant Find Matching Color YET!" & @LF & "Current Color: " & $Color)
    EndSwitch
WEnd
Not sure if it's correct way of comparing the colors, but give it a shot.

Cheers

Link to comment
Share on other sites

Thank you Smashly but I've got it to work and even changed

from select to switch

For $i = 192 to $y  ; 286 ; The Start 
For $j = 285 to $x  ; 193 ; The End

$test = PixelGetColor ($j,$i)
Switch $test
ToolTip(Hex($test,6))
    Case Hex($test,6) = $Green 
    ToolTip("Green")
    Sleep(3000)
    Case  Hex($test,6) = $Yellow
        ToolTip("Yellow")
    Sleep(3000)
    _WriteLog()
    Case Hex($test,6) = $Purple
        ToolTip("Purple")
Sleep(3000)
    Case Hex($test,6) = $White
        ToolTip("White")
Sleep(3000)
    Case $test = $Blue
        ToolTip("Blue")
Sleep(3000)
    Case Hex($test,6) = $Orange
        ToolTip("Orange")
Sleep(3000)
    Case Hex($test,6) = $Red
        ToolTip("Red")
Sleep(3000)

EndSwitch

Next
Next
Link to comment
Share on other sites

Hi, glad to hear you worked it out.

Your Switch statement could use some work.

Switch Hex($test,6) ;<- This is what Case is comparing against
    Case $Green ;<- So if Hex($test,6) = $Green then True

No need to do

Switch $test
    Case Hex($test,6) = $Green

Instead do something like

Switch Hex($test,6)
    Case $Green

Cheers

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