Jump to content

Redirect open IE Window


Nova
 Share

Recommended Posts

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
Link to comment
Share on other sites

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 :whistle:

Edited by AceLoc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Link to comment
Share on other sites

Opt("WinTitleMatchMode", 2)

$a = "- Microsoft Internet Explorer"
Do
    Sleep(10)
Until WinExists($a)
ControlSend($a, "", "Edit1", "www.autoitscript.com{ENTER}")
Edited 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.

 

Link to comment
Share on other sites

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 :whistle:? Edited by AceLoc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Link to comment
Share on other sites

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 Redirect

not 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.

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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 :whistle:

Edited by AceLoc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

@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.

 

Link to comment
Share on other sites

@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]

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 4 weeks later...

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 :lmao:

worked for me! thanks ;)
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...