Sign in to follow this  
Followers 0
litlmike

Pixelsearch And Pixelchecksum

9 posts in this topic

#1 ·  Posted (edited)

Whenever the color 0xFF0000 (red) appears in the rectangle (930, 725, 761, 1023), I want a MsgBox to appear and say "Yes!". I would like this to occur everytime 0xFF0000 appears in the rectangle. How do I do it?

I was wrong, but I thought this might work:

;*****EDIT***** FIXED Co-Ordinates*********

While 1
$coord = PixelSearch ( 930, 725, 1023, 761, 0xFF0000 )  
    If $coord  = 1 Then
    MsgBox(4096, "Yes!", "Yes!")
    EndIf
WEnd
Edited by litlmike

Share this post


Link to post
Share on other sites



Opt('PixelCoordMode', 2); may need to change the 2 to 1 or 0 depending on what your using to get your coords (screen/windows/client)
While 1
    If Not WinActive('Window Title To Search') Then WinActivate('Window Title To Search')
    $coord = PixelSearch ( 930, 725, 761, 1023, 0xFF0000 )  
    If Not @error And IsArray($coord) Then
        MsgBox(4096, "Yes!", 'Found at: X coord: ' $coord[0] & ' Y coord: ' & $coord[1])
    EndIf
WEnd


[center]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.[/center]

Share this post


Link to post
Share on other sites

Your rectangle coordinates are incorrect... they should be...

left,top,right,bottom

...yours appear to be...

right,top,left,bottom

Lar.

Hmm, I didn't even check that..., I didn't know he was having a prob with them specifically, I just thought it was a general question :)

[center]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.[/center]

Share this post


Link to post
Share on other sites

Hmm, I didn't even check that..., I didn't know he was having a prob with them specifically, I just thought it was a general question :)

Actually it was a general question, but I think he was right too, my coords are off. In general, how should I approach this?

Share this post


Link to post
Share on other sites

perhaps...

While 1
    $coord = PixelSearch ( 761, 725, 930, 1023, 0xFF0000 )  
    If Not @error Then MsgBox(4096, "Yes!", "Yes!")
    Sleep(10)
WEnd

or maybe you meant by the systray clock...

While 1
    $coord = PixelSearch ( 725, 930, 761, 1023, 0xFF0000 )  
    If Not @error Then MsgBox(4096, "Yes!", "Yes!")
    Sleep(10)
WEnd

edit: added CPU cycle saving Sleep()

Hmm... didn't seem to do it. Any other ideas?

Share this post


Link to post
Share on other sites

PixelCoordMode? ... Window Is Active?


[center]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.[/center]

Share this post


Link to post
Share on other sites

sorry for posting this here, but you guys seem good with pixels maybe you can help, If you don't mind.My Webpage


Thanks in advance

Share this post


Link to post
Share on other sites

this works on my systray... you need to make sure you have the correct color value... use the window info tool...

$LarrysSysTrayPixel = 0xA9BD31

Opt("WinTitleMatchMode",4)

$systray_rect = WinGetPos("classname=Shell_TrayWnd")

While 1
    $coord = PixelSearch ( $systray_rect[2] - 240, $systray_rect[1], _
        $systray_rect[2], $systray_rect[1] + $systray_rect[3], $LarrysSysTrayPixel )    
    If Not @error Then MsgBox(4096, "Yes!", "Yes!")
    Sleep(10)
WEnd
Nice! It works.

I am glad you showed me "classname=Shell_TrayWnd", I haven't used that before, and I think that will help me on some other problems I have.

Also, no one has been able to explain this to me yet (so I can understand it). But the [2], [1], stuff, what is that? And, how do you know to use it in this case?

Thanks a lot everyone!

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

[2],[1]

Dim $MyArray[2] << Allows 2 elements in an array... those would be [0] and [1], and must use Local/Dim/Global (one of those) to declare it.

So... I could have

$MyArray[0] = 'I am going to '

$MyArray[1] = 'Laugh Out Loud'

Then I can check my array like:

Dim $MyArray[2]
$MyArray[0] = 'I am going to '
$MyArray[1] = 'Laugh Out Loud'
For $i = 0 To Ubound($MyArray) - 1
    MsgBox(0, '$i = ' & $i, $MyArray[$i])
Next

Edit:

I guess it's like being able to have one variable with multiple values, but still have an independence, if you want to look at it like that.

Edited by SmOke_N

[center]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.[/center]

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