Deed123 Posted November 2, 2010 Posted November 2, 2010 Hi Everyone, I am new to AutoIT. Please help me to solve this problem. Thank you in advance. I want insert some data to the application and save it. When click the OK button,a windows internet exporer window pop up. I try to close the window automatically,but it can not work.Please help me. This is my code: #Include <GuiRichEdit.au3> #include <IE.au3> $oIE = _IECreate ("http://mywebsite.com") ;--------------page1-------- $o_form0 = _IEFormGetCollection ($oIE, 0) $o_poid = _IEFormElementGetObjByName ($o_form0, "name1") if @error then msgbox(0, "ERROR", "Form is not the one I expected") exit(1) EndIf _IEFormElementSetValue ($o_poid, $poid) $o_enterby = _IEFormElementGetObjByName ($o_form0, "name2") if @error then msgbox(0, "ERROR", "Form is not the one I expected") exit(1) EndIf _IEFormElementSetValue ($o_enterby, '') $o_SearchButton = _IEFormElementGetObjByName ($o_form0, "name3") if @error then msgbox(0, "ERROR", "Form is not the one I expected") exit(1) EndIf _IEAction ($o_SearchButton, "click") ; Click on "Search" button sleep(3000); ;-------page 2----------- $o_form2 = _IEFormGetCollection ($oIE, 0) $o_duedate = _IEFormElementGetObjByName ($o_form2, "name4") if @error then msgbox(0, "ERROR", "Form is not the one I expected") exit(1) EndIf _IEFormElementSetValue ($o_duedate, $duedate) $o_OKButton = _IEFormElementGetObjByName ($o_form2, "name5") if @error then msgbox(0, "ERROR", "Form is not the one I expected") exit(1) EndIf _IEAction ($o_OKButton, "click") ; Click on "OK" button sleep(3000); ; when it click the OK button, a window pop up.I use the following code to close the window, but it can not work. $oSubmit = _IEGetObjByName($oIE, "name6") $hwnd = _IEPropertyGet($oIE,"hwnd") _IEAction ($oSubmit,"focus") ControlSend ($hwnd,"", "[CLASS:Internet Explorer_server;INSTANCE:0]","{ENTER}") WinWait("Windows Internet Explorer","This Action-----") ControlClick("Windows Internet Explorer","This Action----","[Class:button;TEXT:OK;INSTANCE:0]") ;the javascript pop up window .......... <td colspan='13' rowspan='2' nowrap='nowrap' valign='top' align='left'> <span class='PSHYPERLINK' > <a name='name6' id='name6' tabindex='66' href="javascript:submitAction_win1(document.win1,'name6');" class='PSHYPERLINK' title="Defaults Panel" >Defaults</a></span><!-- PO_PNLS_WRK_GOTO_DEFAULTS --> </td> .................. Hope you can understand my problem. Thank your help
PsaltyDS Posted November 3, 2010 Posted November 3, 2010 I try to close the window automatically,but it can not work.Please help me. This is my code: ; ... ControlSend ($hwnd,"", "[CLASS:Internet Explorer_server;INSTANCE:0]","{ENTER}") WinWait("Windows Internet Explorer","This Action-----") ControlClick("Windows Internet Explorer","This Action----","[Class:button;TEXT:OK;INSTANCE:0]") Instance numbers are 1-based, so "INSTANCE:0" is invalid. Instance is also optional, so if there is only one button with the text "OK" in it, don't bother to include instance at all: ControlClick("Windows Internet Explorer","This Action----","[CLASS:Button; TEXT:OK]") Try that first. Since it is an IE popup, there is also the possibility that it is an HTML dialog box (like a little web page with HTML elements, rather than a regular window with controls). You can find out for sure by examining the popup with the AutoIt Window Info Tool (AU3Info.exe). 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
lxxl Posted November 4, 2010 Posted November 4, 2010 (edited) hi guys i have question regarding the ControlClick("Windows Internet Explorer i have same situation but the popup is only some times jump, so when i dont have popup script will wait will die ... coz no popup ;D any suggestion ? heh ControlSend("Windows Internet Explorer", "", "", "{enter}") to the trick edit 2 nope ... its fail Edited November 4, 2010 by lxxl
PsaltyDS Posted November 4, 2010 Posted November 4, 2010 You would need to have a loop that checks for either the popup or the indication that it went on without the popup. If the popup shows, it is handled and the exit loops. If the continuation is detected the loop just exits to stop watching for the popup. You can also add if neither condition occurs within a max timeout it handles the error. Note that for ControlSend() to work it must uniquely match the window. If you have an IE browser open and also a popup from IE, then "Windows Internet Explorer" might not be unique enough to hit the right one. 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
lxxl Posted November 5, 2010 Posted November 5, 2010 You would need to have a loop that checks for either the popup or the indication that it went on without the popup. If the popup shows, it is handled and the exit loops. If the continuation is detected the loop just exits to stop watching for the popup. You can also add if neither condition occurs within a max timeout it handles the error. Note that for ControlSend() to work it must uniquely match the window. If you have an IE browser open and also a popup from IE, then "Windows Internet Explorer" might not be unique enough to hit the right one. well i did it ;D If Not WinActive("Windows Internet Explorer","") Then WinActivate("Windows Internet Explorer","") WinWaitActive("Windows Internet Explorer","",2) sleep(2000) Send("{space}") and now its works like i need ;D
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