Jump to content

Recommended Posts

Posted

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.

Posted
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. :think:

I use the one come with AutoIt (I selected installer package).

Posted
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.
autoit_scripter_blue_userbar.png

Posted (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 by myu8171
Posted (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 by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

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

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