Jump to content

Get toolbar color at relative coordinates


Recommended Posts

Hello,

This question is related to this topic http://www.autoitscript.com/forum/index.php?showtopic=9311&st=0&p=65490&hl=forte%20agent&fromsearch=1&#entry65490

I use forte agent for my news reader. Like the person in the above post I am trying to automate agent functions but there appears to be no way for autoit to view the status bar text as suggested in the prior post. (The Window info tool does not see the text of that control, nor does the WinGetText command)

In Agent - there is a tool bar with astop button which I can click on with AutoIt

My problem is that one of the things i want to do is not only stop the app but determine when it has actually finished "stopping" which is not always right after the user clicks on the button as the app can be slow to return control at times. I see that AutoIT can determine pixel colors based on X,Y locations and I have seen script examples where a script can report the color under the mouse (like an aim bot)

I can click on the button using a command like this:

ControlClick("Agent Rebuild","","[CLASS:ToolbarWindow32;CLASSNN:ToolbarWindow321]","left",10,896,14)

What i need is an example to use a command like

$var = PixelGetColor( 10 , 100 )

where i can pass the info about the toolbar and then do logic based on the value of $var like (if $var="red" then do this else do that )

Is there a way to do this with this or some other command?

Link to comment
Share on other sites

What i need is an example to use a command like

$var = PixelGetColor( 10 , 100 )

where i can pass the info about the toolbar and then do logic based on the value of $var like (if $var="red" then do this else do that )

Is there a way to do this with this or some other command?

you get the color from au3 info tool on prefered location

heare is your example

Do
    $var = PixelGetColor ( 10 , 100 ) ;change 10 , 100 to coordinates of pixel you need
Until "0x" & Hex ( $var , 6 ) = "0x3E5B96" ;change "0x3E5B96" to collor that you get from info tool
MsgBox(0,"","color detected")

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

I read the help for PixelCoordMode which in part says... "either absolute coords or coords relative to the window defined by hwnd (default active window):"

I came up with this example based on your example. My next question is how do you set the "active" window without using WinActivate?

If you use WinActivate then that pops the window to the foreground every time the code runs and in my new example, if the window loses focus then the code breaks.

Is there an example you or someone could show me by where you grab the handle of the window and apply it to this example?

Thanks...

dim $var, $CurrentColor
Opt("PixelCoordMode", 2)        ;1=absolute, 0=relative, 2=client
WinActivate("Agent")

Do
 

    $var = PixelGetColor ( 896 , 14) ;change 10 , 100 to coordinates of pixel you need
    ConsoleWrite("0x" & Hex ( $var , 6 ) & @CRLF)
    $CurrentColor="0x" & Hex ( $var , 6 )

    if $CurrentColor = "0xCE0031" then
        ConsoleWrite("Button is red" & @CRLF)
    Else
        ConsoleWrite("Button is gray" & @CRLF)
    EndIf
    sleep (2000)
until $var ="RunForever"
Link to comment
Share on other sites

you can try it like this

dim $var, $CurrentColor
Opt("PixelCoordMode", 2)        ;1=absolute, 0=relative, 2=client
$h = WinGetHandle("Agent")
Do
 

    $var = PixelGetColor ( 896 , 14, $h ) ;change 10 , 100 to coordinates of pixel you need
    ConsoleWrite("0x" & Hex ( $var , 6 ) & @CRLF)
    $CurrentColor="0x" & Hex ( $var , 6 )

    if $CurrentColor = "0xCE0031" then
        ConsoleWrite("Button is red" & @CRLF)
    Else
        ConsoleWrite("Button is gray" & @CRLF)
    EndIf
    sleep (2000)
until $var ="RunForever"

Note that i never done (or tested) something simular (dont have on what to test at the moment) to this and probably it will not work (or maby not work at all becose i did not tested) if you have any other window on that pixelgetcolor position or if your main window is minimized.

If it dont work maby someone with more expiriance in this subject can step in.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

  • 2 weeks later...

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