vinyking Posted January 11, 2014 Share Posted January 11, 2014 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. Thanks for the help in advance Link to comment Share on other sites More sharing options...
water Posted January 11, 2014 Share Posted January 11, 2014 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: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
vinyking Posted January 11, 2014 Author Share Posted January 11, 2014 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 Link to comment Share on other sites More sharing options...
water Posted January 11, 2014 Share Posted January 11, 2014 Then you need to add some error checking after each function call. Either check the return value or @error. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
vinyking Posted January 12, 2014 Author Share Posted January 12, 2014 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. Link to comment Share on other sites More sharing options...
water Posted January 12, 2014 Share Posted January 12, 2014 Which application do you try to automate? A reproducer script would be fine - something I can run here. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted January 12, 2014 Share Posted January 12, 2014 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: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Zedna Posted January 13, 2014 Share Posted January 13, 2014 (edited) Maybe this will help you or you can get at least inspiration from there ... '?do=embed' frameborder='0' data-embedContent>> Edited January 13, 2014 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
vinyking Posted January 20, 2014 Author Share Posted January 20, 2014 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 Link to comment Share on other sites More sharing options...
Zedna Posted January 21, 2014 Share Posted January 21, 2014 (edited) This is old well known bug/limitation. Replace ControlSend("Save As", "", 1001, $filename) by ControlSetText("Save As", "", 1001, $filename) Edited January 21, 2014 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
vinyking Posted January 22, 2014 Author Share Posted January 22, 2014 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 Link to comment Share on other sites More sharing options...
Zedna Posted January 22, 2014 Share Posted January 22, 2014 No. Just use some variable with descriptive name and store your directory path into it. So the result will be same just instead of @ will be $ at begin. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
vinyking Posted January 22, 2014 Author Share Posted January 22, 2014 Thanks your time, help and concern is well appreciated Vinyking Link to comment Share on other sites More sharing options...
antonioj84 Posted February 13, 2014 Share Posted February 13, 2014 (edited) 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 February 13, 2014 by antonioj84 Link to comment Share on other sites More sharing options...
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