Sign in to follow this  
Followers 0
shogun

Launch URL in CURRENT Window

12 posts in this topic

Hi,

I have found this "(RunWait(@ComSpec & ' /c start http://www.google.com', '', @SW_HIDE)" in many, many places here.

It works perfectly to open the URL in a NEW window.

I have searched myself out looking for a way to modify this line so that it opens the URL in the CURRENT browswer window.

Does anyone happen to have an answer to my dilema handy?

TIA - Herb

Share this post


Link to post
Share on other sites



Check out the _IE functions in the help file, specifically IEAttach


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

FYI - The version of AutoIt I had on hand does not have the _IE items.

I downloaded the current version and it looks to me like _IENAVIGATE is the solution for me.

I still haven't got it to work, but seems like I am on the right track now.

edit: Thanks "someone" - we were typing at the same time.

Edited by shogun

Share this post


Link to post
Share on other sites

OK, I read thru every page with _IENavigate on it, and found one thread that applies. The last post was from the original poster saying he had figured it out -- but he didn't bother to post the solution that he figured out :)

I came up with this:

#include <IE.au3>
$oIE = _IECreate ("about:blank", 1)
_IENavigate ($oIE, "www.google.com")

It works if I am at my homepage "about:blank", but if I am on any other page, it opens a new page when I click on the autoit exe.

If anyone knows what I need to do to make this work from any page, please do tell.

tia

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Blech sorry was typing while talking. Just try _IEAttach see how it works for ya

Edited by someone

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

@someone: I fooled with _IEAttach earlier and couldn't get any positive results .... not saying that isn't the key mind you, just that I didn't figure it out.

@Marlo: Thanks, your method works from any page, but it opens a new tab instead of opening the URL in the current tab ... a step above opening a whole new window I guess heh

Share this post


Link to post
Share on other sites

I coulda sworn you could just do _IEAttach("")... anyway, you can use $oIE = _IEAttach("", "instance") which will use the first instance of an IE window.


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

I coulda sworn you could just do _IEAttach("")... anyway, you can use $oIE = _IEAttach("", "instance") which will use the first instance of an IE window.

Ahh sweet success :)

I edited the code I pasted above with what you pasted above so it looks like this now:

#include <IE.au3>
$oIE = _IEAttach("", "instance")
_IENavigate ($oIE, "www.google.com")

Works perfectly - thank you very much!

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I used the word "perfectly" prematurely. Though this works very well, it isn't perfect. Additionally, after getting the code shown on this thread to work, I added more code to make three separate files that automatically log me into three sites I visit regularly. Here is my current code:

#include <IE.au3>
#NoTrayIcon
$oIE = _IEAttach("", "instance")
_IENavigate ($oIE, "my url")
$sUsername = "my username"
$sPassword = "my password"
$sPincode = "my pin"
$oForm = _IEFormGetCollection ($oIE, 0)
$oUsername = _IEFormElementGetObjByName ($oForm, "Username")
$oPassword = _IEFormElementGetObjByName ($oForm, "Password")
$oPincode = _IEFormElementGetObjByName ($oForm, "Pincode")
$oLoginbutton = _IEFormElementGetObjByName($oform, "logout")
_IEFormElementSetValue ($oUsername, $sUsername)
_IEFormElementSetValue ($oPassword, $sPassword)
_IEFormElementSetValue ($oPincode, $sPincode)
_IEFormSubmit($oform)

The problem is when I have more than one tab open. If I have more than one tab open and click on one of these "shortcuts", it activates on the first tab even though its not visible, instead of the current tab.

So I once again am back to trying to find a way to make the activity occur on the CURRENT Internet Explorer window.

Any further advice will be greatly appreciated.

Thanks

Edited by shogun

Share this post


Link to post
Share on other sites

Hey sorry I didn't realize you were still having a problem... try this method....

Use wingethandle to retrieve the handle and then use _ieattach with that. wingethandle will return the most recent instance of the window. I don't have IE7 to test, but I believe it will return the object of the most recent tab. By most recent, I mean most recently activated, not created.

#include <IE.au3>

$HWND = WinGetHandle("[CLASS:IEFrame]")
;MsgBox(0, "Title", WinGetTitle($HWND))
$oIE = _IEAttach($HWND, "HWND")
MsgBox(0, "Title", _IEPropertyGet($oIE, "title"))

You may have to change the class, or play around with the matching. Definitely let me know if this works.


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

Thanks for your input someone, but all I can get to return is data on the first tab regardless of which tab is in focus or how many are open.

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