Nad Posted December 17, 2009 Posted December 17, 2009 Hi, Could anyone please let me know how can I open a IE InPrivate window and send an address to it? Does it have different properties? Or AutoIT can not access it at all? All my attempts are failed. I tried this script #include <IE.au3> $oIE = _IECreate ("") Send ("^+P") Sleep (100) $oIE1 = _IEAttach ("", "instance", 2) _IENavigate ($oIE1, "http://website.com") Thanks in advance. Cheers Nad
Nad Posted January 11, 2010 Author Posted January 11, 2010 Wow it seems no one interested in inPrivate windows on IE. Well I was too new to find it out by myself. Here is the script if any one interested $oIE = _IECreate ("") Send ("^+P") Sleep (1000) Send("http://google.com") send("{ENTER}") Since this is a inPrivate window created by pressing CTRL+SHIFT+P on IE, I do not know how to get the handler of that window. So could not get _IEAttach and _IEGetObjByName functions to work. Anyone to give me a clue? Thanks guys in advance Nad
DaleHohm Posted January 11, 2010 Posted January 11, 2010 Here's something to get you started... not sure if there is a COM method to create the private window... perhaps as a flag to Navigate2, but I haven't looked. #include <IE.au3> $oIEtmp = _IECreate ("") Send ("^+P") Sleep (4000) $oIE = _IEAttach("InPrivate") _IELoadWait($oIE) _IENavigate($oIE, "http://google.com") 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
Moderators SmOke_N Posted January 11, 2010 Moderators Posted January 11, 2010 (edited) I couldn't find anything on Navigate2 like Dale suggested there might be ( But then again, I don't know as much as he does when it comes to it ).This may help, however there's not much error checking involved, and I'm not quite sure how reliable it would be if you had multiple instances running.expandcollapse popup#include <IE.au3> Global $oIE = _IEInPrivateCreate("www.google.com", 2) If @error Then If @error = 2 Then ProcessClose(@extended) Exit 1 EndIf _IELoadWait($oIE) _IENavigate($oIE, "www.yahoo.com") Func _IEInPrivateCreate($s_url, $i_timeout = -1) ; Simple version, you can add all the other stuff if you like ($i_timeout is in secs). Local $s_random = "about:InPrivate " & Random(1000000, 99999999, 1) & "-" & Random(1000000, 99999999, 1) If $s_url = "" Then $s_url = "about:InPrivate" Local $i_pid = Run('"' & @ProgramFilesDir & '\Internet Explorer\iexplore.exe" -private "' & $s_random & '"') If $i_pid = 0 Then Return SetError(1, 0, 0) If StringInStr("|default|-1|", "|" & $i_timeout & "|") Then $i_timeout = 0 Local $h_wnd, $o_shell, $o_shell_wins, $i_timer If $i_timeout > 0 Then $i_timer = TimerInit() While 1 If $i_timeout And TimerDiff($i_timer) / 1000 > $i_timeout Then Return SetError(2, $i_pid, 0) EndIf $h_wnd = WinGetHandle($s_random) If $h_wnd Then ExitLoop Sleep(10) WEnd $o_shell = ObjCreate("Shell.Application") If IsObj($o_shell) Then $o_shell_wins = $o_shell.Windows For $o_shell_win In $o_shell_wins ; IE.au3 checks for IWebBrowser as well as IWebBrowser2 with __IEIsObjType ; This fails with my outlook with "hwnd" property ; So if its 100% neccessary, you'll need to find a work around If String(ObjName($o_shell_win)) = "IWebBrowser2" Then If $o_shell_win.hwnd = $h_wnd Then Return SetError(0, $i_pid, $o_shell_win) EndIf EndIf Next EndIf Return SetError(3, $i_pid, 0) EndFuncEdit:Added timeout param, and @extended ( with anything other than @error = 1 ) will return the pid of the ie exe.Edit2:Was using the url and .LocationURL for hwnd verification, however, if there's a redirect this would fail.Using __IEIsObjType() fails when using outlook, so I am just using ObjectName() + IWebBrowser2 Edited January 11, 2010 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Nad Posted January 12, 2010 Author Posted January 12, 2010 (edited) Here's something to get you started... not sure if there is a COM method to create the private window... perhaps as a flag to Navigate2, but I haven't looked. #include <IE.au3> $oIEtmp = _IECreate ("") Send ("^+P") Sleep (4000) $oIE = _IEAttach("InPrivate") _IELoadWait($oIE) _IENavigate($oIE, "http://google.com") Dale Thanks Dale and SmOke_N, I've just implemented my code by using "instance" instead of using the title (it didn't work for me) Here is the code if someone interested. This script will put fake votes on a protected online voting system. Yah yah I know I'm being cheeky. Well... its fun. #include <IE.au3> $oIE = _IECreate ("") For $i = 1 to 500 Step 1 Send ("^+P") Sleep (1000) Send("http://website/") send("{ENTER}") sleep(5000) $oIE1 = _IEAttach ("", "instance", 2) $oID = "radioObjectID" ;got this using fire bug $oSubmitID = "buttonObjectID" ;got this using fire bug $oMR = _IEGetObjByName($oIE1, $oID, 0) $oMR.checked = True $oSubmit = _IEGetObjByName ($oIE1, $oSubmitID) _IEAction ($oSubmit, "click") sleep(2000) _IEQuit ($oIE1) sleep(1000) Next Edited January 12, 2010 by Nad
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