Jump to content

Recommended Posts

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
  • Moderators
Posted

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

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.

  • Moderators
Posted

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 :)

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.

Posted

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?
  • Moderators
Posted

PixelCoordMode? ... Window Is Active?

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.

Posted

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!

  • Moderators
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

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.

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
  • Recently Browsing   0 members

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