Sign in to follow this  
Followers 0
JohnBailey

FileSaveDialog - Activated (focused)

9 posts in this topic

#1 ·  Posted (edited)

Does anyone know how to cause the FileSaveDialog window to Activate? I know it's supposed to but when I run it through loops it gets lost in the background every time. Any ideas as to why this happens or how to cause the FileSaveDialog to show up focused, is much appreciated.

MODS: My apology. I didn't realize I posted this in the GUI Help and Support area. You are more than welcome to move this thread. I didn't even notice that I was in the wrong one.

Edited by JohnBailey

A decision is a powerful thing

Share this post


Link to post
Share on other sites



#4 ·  Posted (edited)

Does anyone know how to cause the FileSaveDialog window to Activate? I know it's supposed to but when I run it through loops it gets lost in the background every time. Any ideas as to why this happens or how to cause the FileSaveDialog to show up focused, is much appreciated.

Maybe you could post youre code to see what you have made until now.

That way somebody else could help you with what you have made so far.

Edited by socratessa

Dont cry tomorrow about what you should have done yesterday. Just do it now.

Share this post


Link to post
Share on other sites

This is just the original script. I am working to rewrite it using a dll call. The problem with the below is that the FileSaveDialog box gets pushed behind the windows when preforming the script on several selected messages.

Note: This requires Outlook to be open and at least one message selected.

Hopefully, someone will yell at me and tell me how else I could improve on my crappy script.

#include <File.au3>
#include <Array.au3>
#include"./Include/OPrinter.au3"
Opt("WinTitleMatchMode", 3)
HotKeySet("{ESC}", "Terminate")
Func Terminate()
    Exit
EndFunc

SetDefault("Adobe PDF")
Sleep(2000)

$oOutlookApp = ObjCreate("Outlook.Application")
$oOutlookExp = $oOutlookApp.ActiveExplorer
$oOutlookSel = $oOutlookExp.Selection
If NOT IsObj($oOutlookApp) Then
    MsgBox(0,'',"$oOutlookApp not object")
Else
    For $x = 1 To $oOutlookSel.Count
        Local $s = FileSaveDialog("Select Location and Give File Name", 'I:\SAI\', "All(*.pdf)",2,"")
        If @error Then ;<--- If cancel is clicked
            Exit
        EndIf
        Dim $szDrive, $szDir, $szFName, $szExt
        $TestPath = _PathSplit($s, $szDrive, $szDir, $szFName, $szExt)
        Local $selectedLocation = $szDrive&$szDir
        Local $fileName = $szFName&$szExt
        ;MsgBox(0,'', $oOutlookSel.Item($x).SenderName) ;<---- Message (Mail) From
        ;ControlSetText('test.txt - Notepad','',"Edit1",$oOutlookSel.Item($x).Body)
        $oOutlookSel.Item($x).PrintOut
        Local $window = 'Save PDF File As'
        WinWaitActive($window)
        WinSetState($window,'',@SW_HIDE)
        ControlSetText($window,'',"Edit1",$s)
        ControlClick($window,'',"Button2")
        If $oOutlookSel.Item($x).Attachments.Count Then
            Local $oOutlookAttachments = $oOutlookSel.Item($x).Attachments
            Local $attachmentsArray = _ArrayCreate("nothing")
            For $xx = 1 To $oOutlookAttachments.Count
                $oOutlookAttachments.Item($xx).SaveAsFile($selectedLocation&$oOutlookAttachments.Item($xx).DisplayName)
                _ArrayAdd($attachmentsArray,$selectedLocation&$oOutlookAttachments.Item($xx).DisplayName)
                ;MsgBox(0,'',$oOutlookAttachments.Item($xx).DisplayName) ;<---Shows the file name
                ;MsgBox(0,'',$oOutlookAttachments.Item($xx).FileName) ;<---Shows the file name another method
            Next
            Sleep(2500)
            For $i = 1 to Ubound($attachmentsArray)-1
                $window = 'Adobe Acrobat Professional - ['&$fileName&']'
                WinActivate($window)
                Sleep(1000)
                Send('{altdown}d')
                Sleep(300)
                Send('n')
                Sleep(500)
                Send('{altup}')
                ;WinMenuSelectItem($window,'','&Document','I&nset Pages...');<-- doesn't work with Acrobat
                Sleep(200)
                $window = 'Select File To Insert'
                ControlSetText($window,'','Edit1',$attachmentsArray[$i])
                Sleep(300)
                ControlClick($window,'','Button2')
                Sleep(300)
                $window = 'Insert Pages'
                ControlClick($window,'','Button5')
                Sleep(1000)
                FileDelete($attachmentsArray[$i])
            Next
        Else
            MsgBox(0,'','no attachments')
        Endif
        Sleep(500)
        $window = 'Adobe Acrobat Professional - ['&$fileName&']'
        WinClose($window)
        Send('{altdown}f')
                Sleep(300)
                Send('x')
                Sleep(500)
                Send('{altup}')
        Sleep(500)
        $window = 'Adobe Acrobat'
        ControlClick($window,'','Button2')
        Sleep(1500)
        $window = 'Adobe Acrobat Professional - ['&$fileName&']'
        WinClose($window)
        Sleep(500)
        $window = 'Adobe Acrobat'
        ControlClick($window,'','Button2')
    Next
EndIf

Back to testing and researching the dll for Dialog boxes


A decision is a powerful thing

Share this post


Link to post
Share on other sites

Valuater, that's wild! I was reading that yesterday and today, but couldn't get anything out of it for my purposes. What you posted is perfect! Thank you very much

The link I posted goes about it a different way completely (dll calls). Any recommendations?


A decision is a powerful thing

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Valuater, that's wild! I was reading that yesterday and today, but couldn't get anything out of it for my purposes. What you posted is perfect! Thank you very much

The link I posted goes about it a different way completely (dll calls). Any recommendations?

Welcome...

Actually, I did not read your script.. but, you could "more easily" incorporate the script i referred to you than to learn all about the Dll and Object possibilities

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  
Followers 0