myu8171 Posted June 18, 2024 Posted June 18, 2024 After clicking Save button, a Save As window shows up and script is paused; no error, the remaining script simply didn't run. After closing the Save As window, console output indicates the script didn't find the Save As window object. If I copy & paste the script snippet that is for the Save As window, and run the snippet in a separate editor window, then that snippet works. The same issue if I compile the scripts into EXE. Currently, the workaround is to run two scripts one by one.
argumentum Posted June 18, 2024 Posted June 18, 2024 What editor are you using ?, the one that comes with AutoIt or the full SciTE ? 35 minutes ago, myu8171 said: The same issue if I compile the scripts into EXE ..now am lost. I'll need more context otherwise I don't know what to guess. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
myu8171 Posted June 18, 2024 Author Posted June 18, 2024 4 hours ago, argumentum said: What editor are you using ?, the one that comes with AutoIt or the full SciTE ? ..now am lost. I'll need more context otherwise I don't know what to guess. I use the one come with AutoIt (I selected installer package).
argumentum Posted June 18, 2024 Posted June 18, 2024 29 minutes ago, myu8171 said: the one come with AutoIt That is the "better than nothing" that come with it but you should -as it is better supported-, use the one from https://www.autoitscript.com/site/autoit-script-editor/downloads/ Maybe after using the full fledged editor, it will all be better Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
myu8171 Posted June 19, 2024 Author Posted June 19, 2024 (edited) 2 hours ago, argumentum said: That is the "better than nothing" that come with it but you should -as it is better supported-, use the one from https://www.autoitscript.com/site/autoit-script-editor/downloads/ Maybe after using the full fledged editor, it will all be better Thanks. I will see if this editor can help with debugging. Console print paused after printing $pCondition_SaveAs OK. Save As window shows up. Code after the ConsoleWrite doesn't execute, no error either. If I close the Save As window, or if I close OK, then $oWindow_SaveAs Err printed out. It seems some sort of process/thread related issue. Tried adding delay after mouse click, didn't work. The same code, if copy & paste to a new au3 file and run, then it runs as expected. Local $pButton_Save, $oButton_Save $oToolBar1.FindFirst( $TreeScope_Descendants, $pCondition9, $pButton_Save) $oButton_Save = ObjCreateInterface( $pButton_Save, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oButton_Save ) Then Return ConsoleWrite( "$oButton_Save ERR" & @CRLF ) ConsoleWrite( "$oButton_Save OK" & @CRLF ) ClickElement($oButton_Save) ConsoleWrite( "--- Find the Save As dialog ---" & @CRLF ) Local $pCondition_SaveAs $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, "Save As", $pCondition_SaveAs) If Not $pCondition_SaveAs Then Return ConsoleWrite("$pCondition_SaveAs ERR" & @CRLF) ConsoleWrite("$pCondition_SaveAs OK" & @CRLF) $saveAsHandle = WinGetHandle($saveAsTitle) Local $pWindow_SaveAs, $oWindow_SaveAs ;$oUIAutomation.ElementFromHandle($saveAsHandle, $pWindow_SaveAs) $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition_SaveAs, $pWindow_SaveAs ) $oWindow_SaveAs = ObjCreateInterface($pWindow_SaveAs, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement) If Not IsObj($oWindow_SaveAs) Then Return ConsoleWrite("$oWindow_SaveAs ERR" & @CRLF) ConsoleWrite("$oWindow_SaveAs OK" & @CRLF) Edited June 19, 2024 by myu8171
argumentum Posted June 19, 2024 Posted June 19, 2024 (edited) 26 minutes ago, myu8171 said: if copy & paste to a new au3 file and run, then it runs as expected. Spoiler 26 minutes ago, myu8171 said: Thanks. I will see if this editor can help with debugging. Console print paused after printing $pCondition_SaveAs OK. Save As window shows up. Code after the ConsoleWrite doesn't execute, no error either. If I close the Save As window, or if I close OK, then $oWindow_SaveAs Err printed out. It seems some sort of process/thread related issue. Tried adding delay after mouse click, didn't work. The same code, if copy & paste to a new au3 file and run, then it runs as expected. Local $pButton_Save, $oButton_Save $oToolBar1.FindFirst( $TreeScope_Descendants, $pCondition9, $pButton_Save) $oButton_Save = ObjCreateInterface( $pButton_Save, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oButton_Save ) Then Return ConsoleWrite( "$oButton_Save ERR" & @CRLF ) ConsoleWrite( "$oButton_Save OK" & @CRLF ) ClickElement($oButton_Save) ConsoleWrite( "--- Find the Save As dialog ---" & @CRLF ) Local $pCondition_SaveAs $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, "Save As", $pCondition_SaveAs) If Not $pCondition_SaveAs Then Return ConsoleWrite("$pCondition_SaveAs ERR" & @CRLF) ConsoleWrite("$pCondition_SaveAs OK" & @CRLF) $saveAsHandle = WinGetHandle($saveAsTitle) Local $pWindow_SaveAs, $oWindow_SaveAs ;$oUIAutomation.ElementFromHandle($saveAsHandle, $pWindow_SaveAs) $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition_SaveAs, $pWindow_SaveAs ) $oWindow_SaveAs = ObjCreateInterface($pWindow_SaveAs, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement) If Not IsObj($oWindow_SaveAs) Then Return ConsoleWrite("$oWindow_SaveAs ERR" & @CRLF) ConsoleWrite("$oWindow_SaveAs OK" & @CRLF) That, as is, did not run at all. warning: $TreeScope_Descendants: possibly used before declaration. $oToolBar1.FindFirst( $TreeScope_Descendants, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "New AutoIt v3 Script.au3"(13,63) : warning: $pCondition9: possibly used before declaration. $oToolBar1.FindFirst( $TreeScope_Descendants, $pCondition9, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "New AutoIt v3 Script.au3"(13,79) : warning: $oToolBar1: possibly used before declaration. $oToolBar1.FindFirst( $TreeScope_Descendants, $pCondition9, $pButton_Save) ... ... If you post running code, I can paste it to my editor and help. But as is, it just don't run Edited June 19, 2024 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
myu8171 Posted June 19, 2024 Author Posted June 19, 2024 2 hours ago, argumentum said: Reveal hidden contents That, as is, did not run at all. warning: $TreeScope_Descendants: possibly used before declaration. $oToolBar1.FindFirst( $TreeScope_Descendants, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "New AutoIt v3 Script.au3"(13,63) : warning: $pCondition9: possibly used before declaration. $oToolBar1.FindFirst( $TreeScope_Descendants, $pCondition9, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "New AutoIt v3 Script.au3"(13,79) : warning: $oToolBar1: possibly used before declaration. $oToolBar1.FindFirst( $TreeScope_Descendants, $pCondition9, $pButton_Save) ... ... If you post running code, I can paste it to my editor and help. But as is, it just don't run The code targets a very specific program. The issue is now very clear: the Save As window causes AutoIT to lose focus.
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