cmux Posted February 27, 2012 Share Posted February 27, 2012 Hi All,Firstly, apologies if this has been covered somewhere on this forum. I have searched high and low both here, other forums and googled the hell out of it.I have a script that among other things, pulls a text file containing a list of URLs into an array and then opens each one in a new tab in Internet Explorer.The problem is that some of my URLs contain an ampersand '&' and so when the script reads the variable that contains such a URL, it stops where the '&' is and so the web page is not displaye/rendered correctly.Here is the code in question:Func _OpenURLs() If Not _FileReadToArray("c:\Capture\retailURLs.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] ;Msgbox(0,'Record:' & $x, $aRecords[$x]) ;$command = 'START "" ' $url = $aRecords[$x] _RunDos("START " & $url) Sleep(1000) ; Set Internet to full screen mode Send("{F11}") Next EndFuncThe "retailURLs.txt" contain 40+ URLs, all on their own line. An example resembles something like this:http://servername/ReportServer?%2fReportName%2fReport+Screen+Reports%2fRPT_ProductsMissingDistributionByStateByCategory&rs:Command=Render&rc:Toolbar=false&rs:ClearSession=trueI have tried substituting the "&' with "%26" and also trying to add '"' before an after the variable, which usually works in situations like this. I think it has got something to do with the fact that I am using the DOS command "START" to call the URLs into Internet Explorer.Any thoughts and comments will be appreciated.Cheers Link to comment Share on other sites More sharing options...
Guest Posted February 27, 2012 Share Posted February 27, 2012 See if this works for you. Func _OpenURLs() Local $aRecords If Not _FileReadToArray("c:CaptureretailURLs.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] ;Msgbox(0,'Record:' & $x, $aRecords[$x]) ;$command = 'START "" ' $url = $aRecords[$x] If IsDeclared("oIEx") Then _IENavigate($oIEx, $url) Else Local $oIEx = _IECreate($url) ; Set Internet to full screen mode Send("{F11}") EndIf Next EndFunc Link to comment Share on other sites More sharing options...
wakillon Posted February 27, 2012 Share Posted February 27, 2012 Try like this #Include <File.au3> #include <IE.au3> Global Const $navOpenInNewTab = 0x0800 Global $aRecords, $oIE _OpenURLs() Func _OpenURLs() If Not _FileReadToArray('c:CaptureretailURLs.txt',$aRecords) Then MsgBox(4096,'Error', ' Error reading log to Array error:' & @error) Exit EndIf _IEErrorNotify ( False ) For $x = 1 to $aRecords[0] ConsoleWrite ( '$aRecords[' & $x & '] : ' & $aRecords[$x] & @Crlf ) If $aRecords[$x] Then If Not IsObj ( $oIE ) Then $oIE = _IECreate ( $aRecords[$x] ) Else __IENavigate ( $oIE, $aRecords[$x], 1, $navOpenInNewTab ) EndIf EndIf Next WinMove ( _IEPropertyGet ( $oIE, 'hwnd' ), '', 0, 0, @DesktopWidth, @DesktopHeight ) ; WinSetState ( _IEPropertyGet ( $oIE, 'hwnd' ), '', @SW_MAXIMIZE ) _IEErrorNotify ( True ) EndFunc AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
cmux Posted February 28, 2012 Author Share Posted February 28, 2012 Thanks both of you for your responses!@wakillon Ive been playing with your script and have been reading the help topics on _IECreate and _IENavigate (__IENavigate is unsupported... Didn't even know it existed!) The first goal has been achieved, that the full URL including the ampersand ('&') is opened in Internet Explorer, however the _IECreate does not recognise that my page has loaded completley or something. For example, if I use www.google.com or www.autoitscript.com, even http://www.google.com.au/?=&#hl=en&gs_nf=1&cp=2&gs_id=7&xhr=t&q=%26%26&pf=p&output=search&sclient=psy-ab&pbx=1&oq=%26%26&aq=0&aqi=g4&aql=&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=3a9fd4bda99ebf6b&biw=1600&bih=1199 , the script moves onto the next URL. How do I get create/navigate to open in a new tab and move to the next URL regardless of whether it thinks the page is loaded or not? Link to comment Share on other sites More sharing options...
cmux Posted February 28, 2012 Author Share Posted February 28, 2012 Global Const $navOpenInNewTab = 0x0800 Global Const $navOpenInBackgroundTab = 0x1000 Global $aRecords, $oIE ; Init HotKeySet("{F12}", "EndScript") ; if F12 key is pressed, run the code function "EndScript" _OpenURLs() _Main() Func _OpenURLs() If Not _FileReadToArray('c:CaptureretailURLs.txt',$aRecords) Then MsgBox(4096,'Error', ' Error reading Retail Screen URLs into Array error:' & @error) Exit EndIf _IEErrorNotify ( False ) For $x = 1 to $aRecords[0] ConsoleWrite ( '$aRecords[' & $x & '] : ' & $aRecords[$x] & @Crlf ) If $aRecords[$x] Then If Not IsObj ( $oIE ) Then ; $oIE = _IECreate ( $aRecords[$x] ) $oIE = _IECreate ( "about:blank" ) Else __IENavigate ( $oIE, $aRecords[$x], 1, $navOpenInNewTab) EndIf EndIf Next WinMove ( _IEPropertyGet ( $oIE, 'hwnd' ), '', 0, 0, @DesktopWidth, @DesktopHeight ) ; WinSetState ( _IEPropertyGet ( $oIE, 'hwnd' ), '', @SW_MAXIMIZE ) _IEErrorNotify ( True ) $oIE = _IEAttach ( "Blank Page" ) ; MsgBox(0, "The URL", _IEPropertyGet ($oIE, "locationurl")) Send("^{TAB}") Send("^{w}") Send("{F11}") EndFunc Exit Ok! I have got a work around. I use the background tab method and also call the first page as "about:blank" and then close that tab once all the tabs are opened. Now all I need to do is to work out how to get rid of that pesky right hand side scroll bar! Link to comment Share on other sites More sharing options...
wakillon Posted February 28, 2012 Share Posted February 28, 2012 Ok! I have got a work around. I use the background tab method and also call the first page as "about:blank" and then close that tab once all the tabs are opened. Now all I need to do is to work out how to get rid of that pesky right hand side scroll bar!Try to add $oIE.document.body.scroll = "no" AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
cmux Posted February 29, 2012 Author Share Posted February 29, 2012 Try to add $oIE.document.body.scroll = "no"Thanks, I actually did try that however it did not work for me. Can you suggest where it should go? Does it work for you? Link to comment Share on other sites More sharing options...
wakillon Posted February 29, 2012 Share Posted February 29, 2012 Thanks, I actually did try that however it did not work for me. Can you suggest where it should go? Does it work for you?I'm on IE7 and it doesn't work, may be you too? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
cmux Posted February 29, 2012 Author Share Posted February 29, 2012 I tried it on 7 and then upgraded it to 8. The box is a virtual XP SP3 machine running on VMware (ESX). Oh well, looks like I may need to rewrite this part of the script (again!), as this is to be used for digital signage. The same page opens in Mozilla without the scrollbar however there are not the same functions built in to autoIt. Link to comment Share on other sites More sharing options...
cmux Posted February 29, 2012 Author Share Posted February 29, 2012 Just found this page. Looks like there are some UDFs for firefox that could be of use. 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