Jump to content

Don't pause script while running COM object method?


Recommended Posts

Hello!

I'm using the Windows Photo Printing Wizard in my script. Simplified example:

#include <ScreenCapture.au3>
#include <File.au3>

Local $sTempFile_1 = _TempFile(@TempDir, "~ISO_", ".bmp")
Local $sTempFile_2 = _TempFile(@TempDir, "~ISO_", ".bmp")

local $GUI = GUICreate("Example", 200, 200)
GUISetState(@SW_SHOW)
Sleep(250)

_ScreenCapture_CaptureWnd($sTempFile_1, $GUI)
Sleep(500)
_ScreenCapture_CaptureWnd($sTempFile_2, $GUI)

If Not @error Then
    Local $CommDlg = ObjCreate('WIA.CommonDialog')
    Local $Files = ObjCreate('WIA.Vector')
    If IsObj($CommDlg) And IsObj($Files) Then
        $Files.Add($sTempFile_1)
        $Files.Add($sTempFile_2)
        $CommDlg.ShowPhotoPrintingWizard($Files)
        FileDelete($sTempFile_1)
        FileDelete($sTempFile_2)
    EndIf
EndIf

The script runs fine, but unfortunately Microsoft decided to enable "Fit to Frame" by default and there's apparently no way to turn it off, so it has to be manually disabled each time I start the wizard.

The script pauses while the Wizard is showing, so I can't uncheck the checkbox within my script. Is there any way to run $CommDlg.ShowPhotoPrintingWizard($Files) in the background without using a second script? I tried adlibbing, but the script still pauses.

Link to comment
Share on other sites

Is there any way to run $CommDlg.ShowPhotoPrintingWizard($Files) in the background without using a second script? I tried adlibbing, but the script still pauses.

No.

AutoIt scripts run in a single thread, if it is blocked then another script is needed to automate whatever is blocking it.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

No.

AutoIt scripts run in a single thread, if it is blocked then another script is needed to automate whatever is blocking it.

I know, but since ShowPhotoPrintingWizard isn't technically "part of the script", it runs in a seperate thread anyway I assumed, like ShellExecute/ShellExecuteWait.

Link to comment
Share on other sites

It is technically "part of the script" because the method is called by the AutoIt script.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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