Sign in to follow this  
Followers 0
Maximon

Open link in new window

7 posts in this topic

Hello, guys!

I need to open link in new window or tab, but do it from my current window, else while doing _IECreate() I loose the session.

Something like right mouse button click - how can I do it, please help!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello, guys!

I need to open link in new window or tab, but do it from my current window, else while doing _IECreate() I loose the session.

Something like right mouse button click - how can I do it, please help!

WinActivate('[CLASS:IEFrame]')
WinWaitActive('[CLASS:IEFrame]')
Send('^t') ;new tab
ControlSetText('[CLASS:IEFrame]', "", '[CLASS:Edit; INSTANCE:1]', 'http://www.autoitscript.com/')
;~ ControlClick('[CLASS:IEFrame]', "", '[CLASS:ToolbarWindow32; INSTANCE:3]', 1)
Send('{ENTER}')

Cheers, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Here's a solution that does not use Send:

#include <IE.au3>
$oIE = _IE_Example()
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
    If String(_IEPropertyGet($oLink, "innertext")) = "user forum" Then
        $oLink.target = "_blank"
        _IEAction($oLink, "click")
    EndIf
Next

Watch out for pop-up blockers that may block the new window.

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

Share this post


Link to post
Share on other sites

Dale - thanks, but in IE6 your solution doesn't work, it opens link in the same window

FireFox - looks good, but if I have few instances of IE, INSTANCE:1 opens new window from first one.

How can I get my current window number?

Share this post


Link to post
Share on other sites

WinActive and WinGetHandle?

try it. not sure as i haven't worked with any IE code so far.

Share this post


Link to post
Share on other sites

OK, I found.

It should be done before:

WinActivate(_IEPropertyGet($myIE,"hwnd"))

Also ControlSetText didn't work in my IE, so I did it another way:

$IEhandle = WinGetHandle('[CLASS:IEFrame; ACTIVE]')
$ie2 = _IEAttach ($IEhandle, "HWnd")
_IENavigate($ie2, $link)

Share this post


Link to post
Share on other sites

Dale - thanks, but in IE6 your solution doesn't work, it opens link in the same window

I can think of no reason for this to be the case with IE6. Nothing has changed in that DOM behavior to my knowledge. Can you verify that this works as you say in IE6 and works as I say in more recent IE versions? Did you run the code just as I supplied it to test or are you basing your feedback on an attempt to adapt my example to your code?

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0