vpn Posted December 2, 2011 Posted December 2, 2011 Hi,I am new to AutoIt.Could anyone answer the following question regarding to _IEAttach?Question 1:Scenario:1. open browser manually (without AutoIt).- http://cgi-lib.berkeley.edu/ex/fup.html2. click browse button using AutoIthere is the AutoIt src I created, and it does not work!Could you help me on this?#include <IE.au3> WinActivate("[CLASS:IEFrame]") Dim $oHandle = WinGetHandle("[CLASS:IEFrame]") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : WinGetHandle("[CLASS:IEFrame]") = ' & WinGetHandle("[CLASS:IEFrame]") & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Dim $oTitle = WinGetTitle($oHandle) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : WinGetTitle($oHandle) = ' & WinGetTitle($oHandle) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Dim $oIE = _IEAttach($oTitle) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : _IEAttach($oTitle) = ' & _IEAttach($oTitle) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Dim $oButton = _IEGetObjByName($oIE,"upfile") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : _IEGetObjByName($oIE,"upfile") = ' & _IEGetObjByName($oIE,"upfile") & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console _IEAction($oButton,"click")Error Msg:--> IE.au3 V2.4-0 Warning from function _IEAttach, $_IEStatus_NoMatch@@ Debug(9) : _IEAttach($oTitle) = 0>Error code: 7Question 2:Could you also help me how to click "Press" button, which has neither id nor name element?- http://cgi-lib.berkeley.edu/ex/fup.htmlThank you in advance!
PsaltyDS Posted December 3, 2011 Posted December 3, 2011 Use the URL type in _IEAttach(). You don't have to find the button, but it is the Submit action for the form. So you can just use _IEFormSubmit(). If you must find something without a name or id, you can select it by 0-based index. Like this: #include <IE.au3> _IEErrorHandlerRegister() Global $sURL = "http://cgi-lib.berkeley.edu/ex/fup.html" Global $oIE = _IEAttach($sURL, "url") Global $oButton = _IEGetObjByName($oIE, "upfile") _IEAction($oButton, "click") MsgBox(64, "Wait", "Click OK to continue") ; Submit form $oForm = _IEFormGetCollection($oIE, 0) ; Get first form _IEFormSubmit($oForm) ; Or find the input by 0-based index and click $oPress = _IETagNameGetCollection($oForm, "input", 2) ; Get third input tag _IEAction($oPress, "click") 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
vpn Posted December 3, 2011 Author Posted December 3, 2011 Hi PsaltyDS, Thank you for the working sample! it really help me a lot! But, I actually have further questions. Could you please help me on this? Question 1: I made a modification to the src. Now I use ControlGetText("[CLASS:IEFrame]", "", "Edit1") to get the URL in order to get URL dynamically. It works, but I have no idea why it's "Edit1"? Isn't that something like [ToolbarWindow32;INSTANCE2]? Window Info tool does not detect "Edit1." So where does it come from? Question 2: In the src, you suggested me to use _IEAttach($sURL, "url"). It works. But, I can not understand why since following Function Reference confuses me a lot in comparison to what you did. - http://www.autoitscript.com/autoit3/docs/libfunctions/_IEAttach.htm Could you please explain a bit more? Question 3: Now I added select file section to the src. And, it does not work. But, the strange thing is that it actually works if I run this section from separate .exe by creating another .au3 with only select file section and compile. Why it does not work as a single file just like the src you can see here? #include <IE.au3> _IEErrorHandlerRegister() WinActivate("[CLASS:IEFrame]") Global $sURL = ControlGetText("[CLASS:IEFrame]", "", "Edit1") #region Global $sURL = "http://cgi-lib.berkeley.edu/ex/fup.html" Global $oIE = _IEAttach($sURL, "url") Global $oButton = _IEGetObjByName($oIE, "upfile") _IEAction($oButton, "click") #region MsgBox(64, "Wait", "Click OK to continue") Sleep(2000) ; Select File _WinWaitActivate("[CLASS:#32770]","") WinActivate("[CLASS:#32770]","") ControlSetText("[CLASS:#32770]", "","[CLASS:Edit; INSTANCE:1]","test.txt") ControlClick("[CLASS:#32770]", "","[CLASS:Button; INSTANCE:2]") ; Submit form WinActivate("[CLASS:IEFrame]") $oForm = _IEFormGetCollection($oIE, 0) ; Get first form _IEFormSubmit($oForm) #region --- Internal functions Au3Recorder Start --- Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc #endregion --- Internal functions Au3Recorder End --- Thanks!
PsaltyDS Posted December 10, 2011 Posted December 10, 2011 A1: That is ClassNameNN, which is the control ID plus instance number. See help file under control identification and you can see them with AU3Info. A2: I don't know what your question is about the example script. A3: Your main script is probably blocked (waiting for something to finish or return). Check on using f_wait = false in the function that calls the pop-up. (See help file.) (Posted from my phone.) 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
vpn Posted December 12, 2011 Author Posted December 12, 2011 Hi PsaltyDS,Thank you for your kindness.A3: Your main script is probably blocked (waiting for something to finish or return). Check on using f_wait = false in the function that calls the pop-up. (See help file.)I really feel I am not smart but ...you refer to following function correct?http://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_GetOverlappedResult.htmMay I have simple sample how to use this function?Thanks.
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