distra Posted October 2, 2007 Share Posted October 2, 2007 I'm new to the AutoIT world and I'm trying to automate saving some web pages locally. The following script works if the "Save As" from the file menu is active. CODEControlSend("Save Web Page", "","[CLASS:Edit; INSTANCE:1]", "html_save") ControlClick("Save Web Page", "","[CLASS:Button; TEXT:&Save; INSTANCE:2]") If I try to tie this to _IEAction "saveas" like in the following code, nothing happens. CODE#include <IE.au3> $oIE = _IEAttach ("MSN") _IEAction ($oIE, "saveas") ControlSend("Save Web Page", "","[CLASS:Edit; INSTANCE:1]", "html_save") ControlClick("Save Web Page", "","[CLASS:Button; TEXT:&Save; INSTANCE:2]") Any idea why this fails? Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 2, 2007 Share Posted October 2, 2007 (edited) the problem is with the "saveas" method. The _IEAction() function pauses the script until the user interacts and closes the dialogue box.#include <IE.au3> Opt("WinTitleMatchMode",4) Dim $hwndIE = WinGetHandle("IEAction saveas") Dim $oIE = _IEAttach($hwndIE,"HWND") _IEAction($oie, "saveas") If @error Then DBP("","Error with saveas") EndIf MsgBox(0,"","I don't display until the Save box is closed") #region Function: Debugger #2: Displays Console writes about errors with optional Message boxes. Func DBP($s_ver = "", $s_msg = "", $i_err = 0, $i_flag = 0) ; s_msg is the message displayed, $i_err is the error code ; $i_flag toggles messagebox display. Easily converts your debug notes into a custom errorhandler If $s_ver = "" Then $s_ver = "DBP: Error notification" If $s_msg = "" Then $s_msg = "Undefined message and/or error" $s_msg = "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & $s_msg ConsoleWrite($s_msg & " Error: " & $i_err & @LF) If $i_flag = 1 Then MsgBox(0x1010, $s_ver, $s_msg & @LF & "Error: " & $i_err) SetError($i_err) ; returns $i_err as @error EndFunc ;==>DBP #endregion Edited October 2, 2007 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
distra Posted October 2, 2007 Author Share Posted October 2, 2007 the problem is with the "saveas" method. The _IEAction() function pauses the script until the user interacts and closes the dialogue box.Thanks for the quick response! Anyway around this issue? Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 2, 2007 Share Posted October 2, 2007 (edited) Run a secondary program that's launched immediately before the the "saveas" method and its only purpose is to interact with the resulting window. Edit: Main #include <IE.au3> Opt("WinTitleMatchMode",4) Dim $hwndIE = WinGetHandle("IEAction saveas") Dim $oIE = _IEAttach($hwndIE,"HWND") Dim $file = @ScriptDir & "\SaveAswindow.exe" If FileExists($file) Then Run($file,@ScriptDir,@SW_HIDE) _IEAction($oie, "saveas") If @error Then DBP("","Error with saveas") EndIf MsgBox(0,"","I don't display until the Save box is closed") #region Function: Debugger #2: Displays Console writes about errors with optional Message boxes. Func DBP($s_ver = "", $s_msg = "", $i_err = 0, $i_flag = 0) ; s_msg is the message displayed, $i_err is the error code ; $i_flag toggles messagebox display. Easily converts your debug notes into a custom errorhandler If $s_ver = "" Then $s_ver = "DBP: Error notification" If $s_msg = "" Then $s_msg = "Undefined message and/or error" $s_msg = "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & $s_msg ConsoleWrite($s_msg & " Error: " & $i_err & @LF) If $i_flag = 1 Then MsgBox(0x1010, $s_ver, $s_msg & @LF & "Error: " & $i_err) SetError($i_err) ; returns $i_err as @error EndFunc ;==>DBP #endregionoÝ÷ Ù'¢wZ¯&®¶sd÷BgV÷CµvåFFÆTÖF6ÖöFRgV÷C²ÂB¥vÆR bväW7G2gV÷Cµ6fRDÔÂFö7VÖVçBgV÷C²ÂgV÷C²gV÷C²FVà 6öçG&öÅ6VæBgV÷Cµ6fRDÔÂFö7VÖVçBgV÷C²ÂgV÷C²gV÷C²ÂgV÷C´VFCgV÷C²ÂgV÷C´3¢b3#µFV×b3#·FW7BæFÖǶVçFW'ÒgV÷C² WDÆö÷ VæD`¥tVæ@ Edited October 2, 2007 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
distra Posted October 2, 2007 Author Share Posted October 2, 2007 Can I call another script or how would I do that? I tried using the GUI interface functions with no luck as well. Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 2, 2007 Share Posted October 2, 2007 See above post. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
distra Posted October 2, 2007 Author Share Posted October 2, 2007 I think I understand. Thanks! Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 2, 2007 Share Posted October 2, 2007 Good luck. Remember, I said secondary program, not script. Very important distinction. A script (to me) is the raw, uncompiled form. I've tried using AdLibEnable() but even that function's polling is paused while _IEAction() has control of the "saveas" box. So, just take the "SECONDARY" code and compile it by itself and place it in the same folder as the main. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 2, 2007 Share Posted October 2, 2007 I asked Dale Hohm about it: The DOM object method used by _IEAction($oIE, "saveas") does not return from the API until the save is finished. MS did that as a change several versions ago, and the IE UDF has no way around it.Dale also pointed out you don't HAVE to use IE UDF to get the SaveAs dialog up. 'Alt-f' and 'a' will open the dialog the old fashioned way without blocking the script. This works for me as a demo:#include <IE.au3> $oIE = _IECreate("http://www.google.com", 1) $hIE = _IEPropertyGet($oIE, "hwnd") WinActivate($hIE) WinWaitActive($hIE) ConsoleWrite("Debug: Google window active" & @LF) ControlSend($hIE, "", "", "!f") ; File ControlSend($hIE, "", "", "a") ; SaveAs WinWait("Save Web Page", "", 5) $hSave = WinGetHandle("Save Web Page", "") WinActivate($hSave) ControlFocus($hSave, "", "Edit1") ControlSend($hSave, "","[CLASS:Edit; INSTANCE:1]", "html_save") ControlClick($hSave, "","[CLASS:Button; TEXT:&Save; INSTANCE:2]")Hope that helps. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
distra Posted October 3, 2007 Author Share Posted October 3, 2007 Thanks for the input! Both methods work so I'm up and running! 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