how can i get the url of the open window in IE

i thought that getURL would get the url of the open window, but it doesnt seem to work.

Here is my 4 lines


tell application "Internet Explorer"
	set thisis to GetURL of window
	display dialog thisis with icon 5
end tell

have tried without of window but still wont work, instead it wopens
cwin or somesort of website.

Any ideas?

Yes. Normally I’d reply: read the dictionary. But dictionaries are hard to read and Microsoft can’t follow standards well enough to write a useful dictionary, so…

Well, let’s see. The IE dictionary reads:


GetURL: Open the URL (and optionally save it to disk)
	GetURL string  -- URL to open

That’s clear. GetURL opens the (URL) string passed to it.

IE’s dictionary – at least in my script editor – doesn’t show the getwindowinfo record, which it should.


tell application "Internet Explorer"
	GetWindowInfo 1
end tell

Provided IE has a window open, that will return the URL and title.

IE’s Applescript support is abysmal and won’t improve. For anything useful, you need to use Javascript.

That’s because GetWindowInfo isn’t a record, it’s an event in the Web Browser Suite.

IE’s dictionary is pretty screwy by normal AppleScript standards although even in its dire state it beats Safari - go figure.

GetWindowInfo requires an integer as parameter, and 1 is a unique identifier for the FIRST window opened in the current IE’s session. If you close such page and open a new one, it will be the window 2. Consequently, your code will throw an error, since you closed the first window.
For safety’s sake, you must ask usually for the frontmost window, which is allways the number -1.

“abysmal”? Hmmm… True, but all browsers’ dictionaries are the same stuff, and IE has been allways the most robust collection of commands… Netscape’s applescript support was/is absolutelly buggy…
Anyway, you are true. This dictionary is a sh*t and JavaScript rocks for DOM scripting… :wink:

GetWindowInfo is a event. The data it returns, the record for GetWindowInfo (that is, the GetWidowInfo record) is not documented as separate entry in the dictionary, which it should be. The header for GetWindowInfo in the dictionary states: “Returns a window info record (URL/Title) for the specified window” but that ‘window info record’ is not documented.

Yikes. Thanks. I haven’t [apple] scripted IE in years and missed this. I thought, like some other programs, that the current windows were numbered starting with 1. My mistake (and Microsoft’s).

mgh
[/quote]

This is because English is lovely… You can use “record” in the regular life of an actress, a radio employee, applescripter, database programmer, normal guy, singer, athlete… As a noun (masculine or feminine), as a verb or adjective. :wink:

Most probably this is a bug in the “aete” parser of the Script Editor. I’ve heard that dictionaries in OS X are very problematic. Though the structure or DOM of a dictionary should be allways the same, it is not allways the same. And you can now keep your old aete in the resource fork, in a .rsrc or in a .plist file into a package… I’m not sure if this is the problem, but it must be an error somewhere in the methods described by Apple to create an aete resource, or great anarchy between the aete developers…