Lycan Posted January 8, 2019 Share Posted January 8, 2019 Hi again, On to my next headache, now that I have the zoom sorted (thanks LarsJ!) I have to find a way to identify if the diagram has completed redrawing with the new ratio. Unfortunately the code behind it doesn't even change the cursor to busy, the only thing that I can see that identifies if the redraw has completed is a type of progress bar (of type "button") that only shows up in inspect.exe when the redaw is occurring. SimpleSpy can't capture it as it occurs either too quickly or if it's there for a while it's because the CPU is maxed out and SimpleSpy doesn't capture the Ctrl-W in time. Honestly, I have no idea where to start. Any help is appreciated. Link to comment Share on other sites More sharing options...
LarsJ Posted January 8, 2019 Share Posted January 8, 2019 You can try $oValue.SetValue( "0.500" & @CR ) You can try adding this code to the previous code expandcollapse popup; --- Detect "Loading" button --- ConsoleWrite( "--- Detect ""Loading"" button ---" & @CRLF ) $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "GRTV Values Loading", $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) $pButton = 0 Local $hTimer = TimerInit() While Not $pButton And TimerDiff( $hTimer ) < 3000 ; Wait for max 3 seconds $oNetworkDisplay.FindFirst( $TreeScope_Descendants, $pCondition, $pButton ) Sleep( 50 ) ; 20 times per second WEnd If Not $pButton Then Return ConsoleWrite( "Detect ""Loading"" button ERR" & @CRLF ) ConsoleWrite( "Detect ""Loading"" button OK" & @CRLF ) ; --- Detect "Loading" done --- ConsoleWrite( "--- Detect ""Loading"" done ---" & @CRLF ) ; $pButton > 0 means that loading is still going on ; $pButton = 0 means that loading is done and button has disappeared While $pButton And TimerDiff( $hTimer ) < 6000 ; Wait for max 6 seconds in total $oNetworkDisplay.FindFirst( $TreeScope_Descendants, $pCondition, $pButton ) Sleep( 50 ) ; 20 times per second WEnd If $pButton Then Return ConsoleWrite( "Detect ""Loading"" done ERR" & @CRLF ) ConsoleWrite( "Detect ""Loading"" done OK" & @CRLF ) Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Lycan Posted January 8, 2019 Author Share Posted January 8, 2019 6 hours ago, LarsJ said: You can try $oValue.SetValue( "0.500" & @CR ) >>> hmm strange enough, neither that nor @CRLF worked - but when I dropped it back to Send("{ENTER}") it worked fine. Bizarre? You can try adding this code to the previous code expandcollapse popup; --- Detect "Loading" button --- ConsoleWrite( "--- Detect ""Loading"" button ---" & @CRLF ) $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "GRTV Values Loading", $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) $pButton = 0 Local $hTimer = TimerInit() While Not $pButton And TimerDiff( $hTimer ) < 3000 ; Wait for max 3 seconds $oNetworkDisplay.FindFirst( $TreeScope_Descendants, $pCondition, $pButton ) Sleep( 50 ) ; 20 times per second WEnd If Not $pButton Then Return ConsoleWrite( "Detect ""Loading"" button ERR" & @CRLF ) ConsoleWrite( "Detect ""Loading"" button OK" & @CRLF ) ; --- Detect "Loading" done --- ConsoleWrite( "--- Detect ""Loading"" done ---" & @CRLF ) ; $pButton > 0 means that loading is still going on ; $pButton = 0 means that loading is done and button has disappeared While $pButton And TimerDiff( $hTimer ) < 6000 ; Wait for max 6 seconds in total $oNetworkDisplay.FindFirst( $TreeScope_Descendants, $pCondition, $pButton ) Sleep( 50 ) ; 20 times per second WEnd If $pButton Then Return ConsoleWrite( "Detect ""Loading"" done ERR" & @CRLF ) ConsoleWrite( "Detect ""Loading"" done OK" & @CRLF ) Man more beautiful code :-o Thanks again :-) Going through the logic, the first while loop waits for a maximum of 3 seconds whilst looking for the button to appear and then sets the pButton value to > 0 The second while loop waits a maximum of 6 seconds for the load to finish completely and the button to disappear. ok fair enough, I've tweaked those values to suite. I also had to add in a little bit of code to increase (and decrease, at the end) the priority of the AutoIT process during this run, otherwise the Application being automated would hog all the CPU cycles and the loops wouldn't get a chance to check within their time limits (so by the time they got CPU cycles, the button had already disappeared). As I'm using the predefined variable @AutoITPID, I'm curious how that will work when I compile the script into a .exe Thanks again LarsJ :-) That's some elegantly brilliant coding there and I'm indebted to you :-) Link to comment Share on other sites More sharing options...
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