Jump to content

Recommended Posts

Posted

Hello All,

I need help with selecting items in the save as dialogue box

I surf the net and Autoit forum but none of the solutions seem to work for me

below is the code I have worked with which is basically not doing what i wanted

the file still get saved in the previous selected folder.

I want the file to be saved in what ever folder i indicated in my code.

WinWaitActive("Save As", "&Save", 10)
    Sleep(1000)
    If ControlTreeView("Save As", "", 100, "Exist", "Desktop") Then
    ControlTreeView($windowname, "", 100, "Select", "Desktop|My Folder") ; to save file in My Folder (specific folder of choice) 
    
       Else
       
        MsgBox(0, "not existing", "this is not working"); i am trying to check if the first example works if not try other option
    WinWaitActive("Save As", "")
    ControlClick("Save As", "", "[CLASS:Button; INSTANCE:100]")
    $hTree = ControlGetHandle("Save As", "", "[CLASS:SysTreeView32; INSTANCE:100]") ; get handle to the treeview window
        ControlTreeView("Save As", "", $hTree, "Expand", "#0|#13") ; expand a node
        ControlTreeView("Save As", "", $hTree, "Expand", "#0|#13|#10") ; expand a child node of the above node
    EndIf
    ControlSend($windowname, "", $control, "file name" & ".pdf")
    ControlClick($windowname, "&Save", 1, "left", 1) 

My file still saves still does not save in the specified folder. :sweating:

Thanks for the help in advance 

Posted

I think it is a typo. Keyword should be "Exists" (the trailing "s" is missing):

If ControlTreeView("Save As", "", 100, "Exists", "Desktop") Then

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Thanks Water for the quick response. i corrected the typo. However, my file still save else where (not in specified folder)

there must be a way to do this :think:

Posted

Then you need to add some error checking after each function call. Either check the return value or @error.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Hi water

I have narrowed in on the code and the returned value

I discovered my default folder is selected in the save as window, but not clicked

it appears selected folder needs to be clicked .

How do I stimulate the clicking of the folder in the save as window?

my code and comment is below

If ControlTreeView("Save As", "", 100, "Exists", "Desktop|CSCS Statements") Then
    ControlTreeView("Save As", "", 100, "Select", "#1|#11") ; expand a node
    ControlClick("Save As", "", 100, "left", 1); this is not clicking my selected folder 
    Sleep(2000)
Else
    MsgBox(0, "Folder Message", "Default Folder not found ")
EndIf

thanks in advance.

Posted

Which application do you try to automate? A reproducer script would be fine - something I can run here.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

The following example works for Notepad. Open Notepad, open the Save as dialog and then run the AutoIt script.

Global $sWindowTitle = "Save As" 
Global $sFileName = "file name.pdf"
$hWND = WinActivate($sWindowTitle)
ConsoleWrite($hWND & @CRLF)
$vResult = WinWaitActive($hWND)
ConsoleWrite($vResult & @CRLF)
$vResult = ControlSend($hWND, "", 1001, @DesktopDir & "\" & $sFileName)
ConsoleWrite($vResult & @CRLF)
$vResult = ControlClick($hWND, "", 1)
ConsoleWrite($vResult & @CRLF)
Exit

No selecting of the folder required. Simply write the complete path to the Control and click "Save".

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Hi Zedna and Water,

You help are appreciated.

I have tried out your suggestions, but I am yet to grab the solution (I kept away due to the shame of not making this work).

I resulted to the following

Func Printwebpage_to_PDF()

    Local $filename = @MyDocumentsDir & "\Statement folder\" & $aArray1[$i] & ".pdf"
    If WinExists("Print") Then
        WinActivate("Print")
        WinWaitActive("Print", "", 10)
        Send("PrimoPDF {Enter 2}")
        WinWaitActive("PrimoPDF by Nitro PDF Software", "", 10)
        ControlClick("PrimoPDF by Nitro PDF Software", "", "[TEXT:Create PDF]")
        WinWaitActive("Save As", "&Save", 10)
        Sleep(1500)
        ControlSend("Save As", "", 1001, $filename)
        Sleep(2000) ; wait 2 seconds
        ControlClick("Save As", "&Save", 1, "left", 1)
        WinWaitActive("Adobe Acrobat Professional", ".pdf", 10)
        Sleep(1000)
        ;WinActivate("Adobe Acrobat Professional", ".pdf")
        WinClose("Adobe Acrobat Professional", ".pdf")

    EndIf

EndFunc   ;==>Printwebpage_to_PDF 

 I declared the folder and "controlsend" to the save as dialogue.

Now although this works often time the system makes an error of sending "|" instead of "". in the string

so sometimes I get

C:|Users|My profileDocumentsStatement folderJohn.pdf

C:UsersMy profileDocuments|Statement folderJohn.pdf

instead of 

C:UsersMy profileDocumentsStatement folderJohn.pdf

I have tried to increase the sleep period but the error do occur often causing me headache.

my question is what can cause system to control send "|" instead of ""

also can i format my directory like " @myspecifiedDir" which is C:UsersMy profileDocumentsStatement folder

the same way we have @MyDocumentsDir and @ScriptDir

Thank you for your time

Posted

Thanks Zedna,

nice to know about the bug/limitation and  my other option.

Now moving on to the second question

"can i format my directory like " @myspecifiedDir" which is C:UsersMy profileDocumentsStatement folder

the same way we have @MyDocumentsDir and @ScriptDir.

 

Thanks

 

Vinyking

  • 3 weeks later...
Posted (edited)
  On 2/13/2014 at 2:46 AM, antonioj84 said:

 

can anyone tell me what is wrong with this code, I am trying to read the tree until " Use Policy List of Quirks Mode sites"  also any links to download the lib3 will be great

 

#include <GUITreeView.au3>
#RequireAdmin
ShellExecute("gpedit.msc")
Local $Title= "Local Group Policy Editor"
Global $hWnd = ControlGetHandle("[Class:MMCMainFrame;Title:$title]","[ClassN:SysTreeView32; INSTANCE:1]", _
"[ClassnameNN:SysTreeView321]")
 
;WinWait($Title)
;WinActivate($Title)
;WinWaitActive($Title)
;ControlFocus($Title,"","[CLASS:SysTreeView32; INSTANCE:1]")
;send("{down  }" )
 
;$sPath = "Computer Configuration|Administrative Templates| Windows Components|Internet Explorer| Compatibility View|Use Policy List of Quirks Mode sites"
 
Global $hWnd = ControlGetHandle("[Class:MMCMainFrame;Title:$title]","[Class:SysTreeView32; INSTANCE:1]", _
"[ClassnameNN:SysTreeView321]")
 
$searchText = "Use Policy List of Quirks Mode sites"
 
$hItemFound = _GUICtrlTreeView_FindItem($hWnd, $searchText, True)
While $hItemFound
   _GUICtrlTreeView_SelectItem($hWnd, $hItemFound)
      $next = _GUICtrlTreeView_GetNextVisible($hWnd, $hItemFound)
   $hItemFound = _GUICtrlTreeView_FindItem($hWnd, $searchText, True, $next)
   Sleep(5000)
   WEnd
 
Exit

 

Edited by antonioj84

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