dingo Posted February 4, 2007 Share Posted February 4, 2007 I've written a script that nav's to a website; logs in; navs to a page and then gets the bodytext and parses it and writes out the results; nav's to a log off page, clicks an image to log off; closes the browser; and exits. All of this works perfectly on the computer on which I have AutoIT installed. But when I copy the exe over to another of my computers that doesn't have AutoIT installed and run it I get the following result: After the log in a page with the bodytext opens in a new tab (IE 7 on both machines) and then opens the same page in the orignal tab and continues on that original tab to completiton and then closes that tab. What remains is the browser with the second tab (now the only tab) still open. My goal was to run the script, open IE do its thing, close IE and exit. Can anyone PLEASE spot what I'm doing wrong? I've played with this for an entire day and can't seem to get past this problem. Running on WinXP SP 2, IE7 Thanks! dingo The relevant part of the script is below: CODE;------------------------------------------------------------------ ; Create a browser window and navigate to IBD login ; Attach: No ; Visible: Yes ; Wait: Yes ; TakeFocus: Yes ;------------------------------------------------------------------ $oIE = _IECreate("about:blank", 0, 1, 1, -1) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Can't Open Signin URL") Exit EndIf Sleep (4000) $sTargetURL = $cIBD_LogIn _IENavigate($oIE, $sTargetURL, 1) $sCurrentURL = _IEPropertyGet($oIE, "locationurl") If $sCurrentURL <> $sTargetURL Then Msgbox(16, $cAppName & " Error ", "Can't Open Signin URL" & @CRLF & @CRLF _ & "Target URL: " & $sTargetURL & @CRLF _ & "Actual URL: " & $sCurrentURL) Exit EndIf ;------------------------------------------------------------------ ; get pointers to the Signin form and username and password fields ;------------------------------------------------------------------ $o_form = _IEFormGetObjByName($oIE, "forLogIn") $o_login = _IEFormElementGetObjByName($o_form, "htmUserName") $o_password = _IEFormElementGetObjByName($o_form, "htmPassword") ;------------------------------------------------------------------ ; Set field values and submit the form ;------------------------------------------------------------------ _IEFormElementSetValue($o_login, $sUserName) _IEFormElementSetValue($o_password, $sPassword) _IEFormSubmit($o_form) ;Msgbox(16, $cAppName, "Pause") ;------------------------------------------------------------------ ; Load the list of tickers ; Wait: Yes ;------------------------------------------------------------------ $sTargetURL = $cIBD100 _IENavigate($oIE, $sTargetURL, 1) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Can't Open IBD100 URL") Exit EndIf $sCurrentURL = _IEPropertyGet($oIE, "locationurl") If $sCurrentURL <> $sTargetURL Then Msgbox(16, $cAppName & " Error ", "Can't Open IBD100 URL" & @CRLF & @CRLF _ & "Target URL: " & $sTargetURL & @CRLF _ & "Actual URL: " & $sCurrentURL) Exit EndIf ;------------------------------------------------------------------ ; Scrape the data and write the tickers out to a file ; Mode: Write mode (erase previous contents) ;------------------------------------------------------------------ $hFileHandle = FileOpen($cOutPutFileName, 2) If $hFileHandle = -1 Then MsgBox(16, $cAppName & " Error ", "Can't Create " & $cOutPutFileName & " File") Exit EndIf $sText = _IEBodyReadText($oIE) $aLines = StringSplit($sText, @LF) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Split Didn't Work") Exit EndIf For $indx = 7 To 106 $sTicker = StringMid($aLines[$indx], 38, 8) FileWriteLine($hFileHandle, StringStripWS($sTicker, 2)) Next FileClose($hFileHandle) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Can't Close " & $cOutPutFileName & " File") Exit EndIf ;------------------------------------------------------------------ ; Nav back to a page where we can sign out ; Wait: Yes ;------------------------------------------------------------------ $sTargetURL = $cIBD_SignOut _IENavigate($oIE, $sTargetURL, 1) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Can't Open Sign Out URL") Exit EndIf $sCurrentURL = _IEPropertyGet($oIE, "locationurl") If $sCurrentURL <> $sTargetURL Then Msgbox(16, $cAppName & " Error ", "Can't Open Sign Out URL" & @CRLF & @CRLF _ & "Target URL: " & $sTargetURL & @CRLF _ & "Actual URL: " & $sCurrentURL) Exit EndIf ;------------------------------------------------------------------ ; Sign Off by clicking the Sign Out Image ; Mode: Use img url ; Index: Optional ; Wait: yes ;------------------------------------------------------------------ _IEImgClick($oIE, $cIBD_SignOutImg, "src", 0, 1) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Can't Click Sign Out Image") Exit EndIf ;------------------------------------------------------------------ ; Close Browser ;------------------------------------------------------------------ _IEQuit($oIE) Exit Link to comment Share on other sites More sharing options...
dingo Posted February 4, 2007 Author Share Posted February 4, 2007 Well.. after some more investigating I've discovered that its prolly not the script doing this. When I reproduce the navigation manually on the misbehaving computer it exibits the same behavior. So, it looks like something has run amok on that machine. BTW I should have thanked DaleHohm for his fantastic UDF!! It sure takes the hassle outta working with the DOM. And major thanks for all of you that worked on AutoIT!! d I've written a script that nav's to a website; logs in; navs to a page and then gets the bodytext and parses it and writes out the results; nav's to a log off page, clicks an image to log off; closes the browser; and exits. All of this works perfectly on the computer on which I have AutoIT installed. But when I copy the exe over to another of my computers that doesn't have AutoIT installed and run it I get the following result: After the log in a page with the bodytext opens in a new tab (IE 7 on both machines) and then opens the same page in the orignal tab and continues on that original tab to completiton and then closes that tab. What remains is the browser with the second tab (now the only tab) still open. My goal was to run the script, open IE do its thing, close IE and exit. Can anyone PLEASE spot what I'm doing wrong? I've played with this for an entire day and can't seem to get past this problem. Running on WinXP SP 2, IE7 Thanks! dingo The relevant part of the script is below: CODE;------------------------------------------------------------------ ; Create a browser window and navigate to IBD login ; Attach: No ; Visible: Yes ; Wait: Yes ; TakeFocus: Yes ;------------------------------------------------------------------ $oIE = _IECreate("about:blank", 0, 1, 1, -1) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Can't Open Signin URL") Exit EndIf Sleep (4000) $sTargetURL = $cIBD_LogIn _IENavigate($oIE, $sTargetURL, 1) $sCurrentURL = _IEPropertyGet($oIE, "locationurl") If $sCurrentURL <> $sTargetURL Then Msgbox(16, $cAppName & " Error ", "Can't Open Signin URL" & @CRLF & @CRLF _ & "Target URL: " & $sTargetURL & @CRLF _ & "Actual URL: " & $sCurrentURL) Exit EndIf ;------------------------------------------------------------------ ; get pointers to the Signin form and username and password fields ;------------------------------------------------------------------ $o_form = _IEFormGetObjByName($oIE, "forLogIn") $o_login = _IEFormElementGetObjByName($o_form, "htmUserName") $o_password = _IEFormElementGetObjByName($o_form, "htmPassword") ;------------------------------------------------------------------ ; Set field values and submit the form ;------------------------------------------------------------------ _IEFormElementSetValue($o_login, $sUserName) _IEFormElementSetValue($o_password, $sPassword) _IEFormSubmit($o_form) ;Msgbox(16, $cAppName, "Pause") ;------------------------------------------------------------------ ; Load the list of tickers ; Wait: Yes ;------------------------------------------------------------------ $sTargetURL = $cIBD100 _IENavigate($oIE, $sTargetURL, 1) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Can't Open IBD100 URL") Exit EndIf $sCurrentURL = _IEPropertyGet($oIE, "locationurl") If $sCurrentURL <> $sTargetURL Then Msgbox(16, $cAppName & " Error ", "Can't Open IBD100 URL" & @CRLF & @CRLF _ & "Target URL: " & $sTargetURL & @CRLF _ & "Actual URL: " & $sCurrentURL) Exit EndIf ;------------------------------------------------------------------ ; Scrape the data and write the tickers out to a file ; Mode: Write mode (erase previous contents) ;------------------------------------------------------------------ $hFileHandle = FileOpen($cOutPutFileName, 2) If $hFileHandle = -1 Then MsgBox(16, $cAppName & " Error ", "Can't Create " & $cOutPutFileName & " File") Exit EndIf $sText = _IEBodyReadText($oIE) $aLines = StringSplit($sText, @LF) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Split Didn't Work") Exit EndIf For $indx = 7 To 106 $sTicker = StringMid($aLines[$indx], 38, 8) FileWriteLine($hFileHandle, StringStripWS($sTicker, 2)) Next FileClose($hFileHandle) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Can't Close " & $cOutPutFileName & " File") Exit EndIf ;------------------------------------------------------------------ ; Nav back to a page where we can sign out ; Wait: Yes ;------------------------------------------------------------------ $sTargetURL = $cIBD_SignOut _IENavigate($oIE, $sTargetURL, 1) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Can't Open Sign Out URL") Exit EndIf $sCurrentURL = _IEPropertyGet($oIE, "locationurl") If $sCurrentURL <> $sTargetURL Then Msgbox(16, $cAppName & " Error ", "Can't Open Sign Out URL" & @CRLF & @CRLF _ & "Target URL: " & $sTargetURL & @CRLF _ & "Actual URL: " & $sCurrentURL) Exit EndIf ;------------------------------------------------------------------ ; Sign Off by clicking the Sign Out Image ; Mode: Use img url ; Index: Optional ; Wait: yes ;------------------------------------------------------------------ _IEImgClick($oIE, $cIBD_SignOutImg, "src", 0, 1) If @Error Then Msgbox(16, $cAppName & " Error: " & @Error, "Can't Click Sign Out Image") Exit EndIf ;------------------------------------------------------------------ ; Close Browser ;------------------------------------------------------------------ _IEQuit($oIE) Exit Link to comment Share on other sites More sharing options...
DaleHohm Posted February 5, 2007 Share Posted February 5, 2007 Thanks for saying thanks :-) You're welcome. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble 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