Nova Posted November 7, 2006 Posted November 7, 2006 Im trying to write a script that waits for an Internet Explorer window to exist and as soon as it does redirect it to a webpage of my choice. Why isnt the follwing code doing just that? #include <IE.au3> Opt("WinTitleMatchMode", 2) while(1) If WinExists("- Microsoft Internet Explorer") Then $oIE = _IEAttach ("- Microsoft Internet Explorer") _IENavigate ($oIE, "www.autoitscript.com") EndIf sleep(10) WEnd
AceLoc Posted November 7, 2006 Posted November 7, 2006 (edited) Opt("WinTitleMatchMode", 2) HotKeySet("{F2}", "_Exit") $a = "- Microsoft Internet Explorer" Do Sleep(10) Until WinExists($a) ControlSend($a, "", "Edit1", "www.autoitscript.com{ENTER}") Func _Exit() WinKill($a) Exit EndFunc If you really want the IE way, Then i will figure it out for you Edited November 7, 2006 by AceLoc [quote name='AceLoc']I gots new sunglasses there cool.[/quote]
GaryFrost Posted November 7, 2006 Posted November 7, 2006 (edited) Opt("WinTitleMatchMode", 2) $a = "- Microsoft Internet Explorer" Do Sleep(10) Until WinExists($a) ControlSend($a, "", "Edit1", "www.autoitscript.com{ENTER}") Edited November 7, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
AceLoc Posted November 7, 2006 Posted November 7, 2006 Doesnt work gafrost [quote name='AceLoc']I gots new sunglasses there cool.[/quote]
Nova Posted November 7, 2006 Author Posted November 7, 2006 gafrost the code you posted gives focus to an open Internet Explorer Window but it dosent redirect it to www.autoitscript.com. Is it working on your computer?
AceLoc Posted November 7, 2006 Posted November 7, 2006 (edited) gafrost the code you posted gives focus to an open Internet Explorer Window but it dosent redirect it to www.autoitscript.com.Is it working on your computer?Whats wrong with mines ? Edited November 7, 2006 by AceLoc [quote name='AceLoc']I gots new sunglasses there cool.[/quote]
GaryFrost Posted November 7, 2006 Posted November 7, 2006 gafrost the code you posted gives focus to an open Internet Explorer Window but it dosent redirect it to www.autoitscript.com.Is it working on your computer?try it with this thread open and change the title to Redirectnot sure why it won't work with the other in it. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
GaryFrost Posted November 7, 2006 Posted November 7, 2006 This seems to work better #include <IE.au3> Opt("WinTitleMatchMode", 2) $Title = "- Microsoft Internet Explorer" $hwnd = WinGetHandle($Title) while(1) If WinExists($hwnd) Then WinActivate($hwnd) $oIE = _IEAttach ($hwnd, "HWND") _IENavigate ($oIE, "www.autoitscript.com") ExitLoop EndIf sleep(10) WEnd SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
AceLoc Posted November 7, 2006 Posted November 7, 2006 (edited) Still doesnt work Gafrost but you gave me an idea this one works perfectly: #include <IE.au3> Opt("WinTitleMatchMode", 2) $a = "- Microsoft Internet Explorer" Do Sleep(10) Until WinExists($a) $b = WinGetHandle($a) WinActivate($B) $c = _IEAttach ($b, "HWND") _IENavigate ($c, "www.autoitscript.com") Although my first script is way faster Edited November 7, 2006 by AceLoc [quote name='AceLoc']I gots new sunglasses there cool.[/quote]
Nova Posted November 7, 2006 Author Posted November 7, 2006 @AceLoc you code dosent accomplish what I asked it simply concatenates whatevers int the address bar with a new url. Plus I really dont like controlSend. If I can avoid it by any means I do. @Gafrost, I cant be anymore specific with the title of Internet Explorer Windows, I need this to work for all Internet Explorer Windows, Checking if the string "- Microsoft Internet Explorer" is contained in the Title of the Window is pushing it already.
GaryFrost Posted November 7, 2006 Posted November 7, 2006 @AceLoc you code dosent accomplish what I asked it simply concatenates whatevers int the address bar with a new url. Plus I really dont like controlSend. If I can avoid it by any means I do.@Gafrost, I cant be anymore specific with the title of Internet Explorer Windows, I need this to work for all Internet Explorer Windows, Checking if the string "- Microsoft Internet Explorer" is contained in the Title of the Window is pushing it already.POST #8 worked for me SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
AceLoc Posted November 7, 2006 Posted November 7, 2006 @Gafrost which version of autoit do you use at the moment? @Nova did you see this one already? #include <IE.au3> Opt("WinTitleMatchMode", 2) $a = "- Microsoft Internet Explorer" Do Sleep(10) Until WinExists($a) $b = WinGetHandle($a) WinActivate($B) $c = _IEAttach ($b, "HWND") _IENavigate ($c, "www.autoitscript.com") [quote name='AceLoc']I gots new sunglasses there cool.[/quote]
DaleHohm Posted November 8, 2006 Posted November 8, 2006 Just a note about the title issue... it turns out that IE browser adds a customized string to the title that is unrelated to the <TITLE> if the document inside. The string by default is " - Microsoft Internet Explorer" but it can be changed, for example to " - Microsoft Internet Explorer provided by Yahoo!". Working with the HWND as Gary suggests is the best way to deal with this. I certainly understand the utility of being able to use the title returned by AutoIt in _IEAttach and I've been thinking about ways that it would make sense. I can see that the string is stored in the registry in the pod "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Window Title" and it is obviously prepended with " - " and added to the document title to create the window title. So, you could also grab that registry value, prepend " - " and use a substring function to pull out the title for comparison... 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
John Posted November 8, 2006 Posted November 8, 2006 I agree with Nova that that script should have worked. I did some investigating and there are several variants but it boils down to the way this script acts. ObjEvent("AutoIt.Error", "_err") $o_Shell = ObjCreate("Shell.Application") $o_ShellWindows = $o_Shell.Windows () For $o_window In $o_ShellWindows MsgBox(0,"Window Title", $o_window.document.title) ; Loops through windows with titles then throws requested action with object error. Next Func _err() MsgBox(0,"Err","Object Error") ; Never called EndFunc I've tried; If $o_window.document.title .... string($o_window.document.title) I found no way to trap this error. I'm thinking this qualifies as a bug.... Nova I got URL match mode to work when using "HTTP" as the string. AutoIt Ver. 3.1.1.132 Win 98 SE
user52 Posted December 1, 2006 Posted December 1, 2006 Still doesnt work Gafrost but you gave me an idea this one works perfectly: #include <IE.au3> Opt("WinTitleMatchMode", 2) $a = "- Microsoft Internet Explorer" Do Sleep(10) Until WinExists($a) $b = WinGetHandle($a) WinActivate($B) $c = _IEAttach ($b, "HWND") _IENavigate ($c, "www.autoitscript.com") Although my first script is way faster worked for me! thanks
DaleHohm Posted December 1, 2006 Posted December 1, 2006 worked for me! thanks The new beta T2.0-6 found here also contains a "windowtitle" mode for _IEAttach that will allow you to use the full window title in your match criteria.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
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