RHolmes Posted December 5, 2017 Posted December 5, 2017 I have a program that has a control that changes color a few seconds into running. So ideally, I would poll this to tell when an event has occurred. I can't seem to retrieve the correct color value for a control. It always seems to return white indicating that its selecting somewhere else in the window. In the PixelGetColor call I'm adding half the width to the x value and subtracting half the height to the y value in order to get the center of the control. (assuming the coords returned by ControlGetPos are top left - which i can't be sure of) But I've also tried without modifying the x/y and with changing the PixelCoordMode option to 2. Maybe I'm making a silly mistake and can't see it? Any help would be appreciated. Code is below: Opt("PixelCoordMode", 0) FileChangeDir( "C:\Where\My\File\Is" ); Run( "MyProgram.exe" ) Local $hClient = WinWaitActive( $CLIENT_TITLE, "", 10 ) Local $systemIndicatorClassNN= "[CLASS:Qt5QWindowIcon; INSTANCE:99]" Local $hSystemIndicator = ControlGetHandle ( $hClient, "", $systemIndicatorClassNN) Local $xywh = ControlGetPos ( $hClient, "", $hSystemIndicator ) For $i = 10 To 1 Step -1 $color = PixelGetColor ( $xywh[0] + ($xywh[2]/2), $xywh[1] - ($xywh[3]/2), $hClient ) LogToFile( $color ) Sleep( 2000 ) Next
careca Posted December 5, 2017 Posted December 5, 2017 Dont forget that pixelgetcolor retrieves the color in decimal, is that what you need? Also why this? For $i = 10 To 1 Step -1 Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
RHolmes Posted December 6, 2017 Author Posted December 6, 2017 It doesn't matter what format the color is in, as long as I can determine if it has changed. So far I've been getting the value 16777215 - which is white. In each iteration of the for loop, I sleep the program for 2 seconds. That way it checks if the color has changed every 2 seconds.
RHolmes Posted December 6, 2017 Author Posted December 6, 2017 Maybe I don't understand how ControlGetPos works? Perhaps the coords it returns are some value I'm not expecting. I'm also using two monitors, I'm not sure if that can confuse the coordinate system?
RHolmes Posted December 6, 2017 Author Posted December 6, 2017 Ok, I finally solved it after a lot of logging! ; get the control Local $hSystemIndicator = ControlGetHandle ( $hClient, "", "SystemReadyWindow" ) ; get pos and size of control Local $xywh = ControlGetPos ( $hClient, "", $hSystemIndicator ) ; check color at the center of the control, not the window $color = PixelGetColor ( $xywh [2]/2, $xywh [3]/2, $hSystemIndicator )
careca Posted December 6, 2017 Posted December 6, 2017 Nice you got it working Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now