Re: Internet Explorer (GetSource) Inconsistently Returns HTML Source Code
Re: Internet Explorer (GetSource) Inconsistently Returns HTML Source Code
- Subject: Re: Internet Explorer (GetSource) Inconsistently Returns HTML Source Code
- From: "Christopher C. Stone" <email@hidden>
- Date: Sun, 7 Jan 2001 03:31:40 -0600
At 07:29 -0700 01/06/01, Dave Moen wrote:
>
Having problems, with getting the HTML Source Code from Microsoft Internet
>
Explorer 5; this Apple Script works most of the time. However, I often get
>
an error message as follows: Finder got an error: Some data could not be
>
read
___________________________________________________________________________
Hello Dave,
>
tell application "Internet Explorer"
>
Activate
>
set vTargetSource to (GetSource 1)
>
tell application "Finder"
>
set the clipboard to vTargetSource
>
end tell
>
end tell
No need to Activate.
No need to Tell Finder to set the Clipboard.
Generally better not to nest Tell Blocks (unless necessary).
Take a look at this:
* Note that my scripts identify applications the way I've renamed them on my machine and may require a minor adjustment to compile on yours.
---------------------------------------------------------------------------
set goFlag to false
tell application "Explorer"
try
set winList to ListWindows
set frntWinSrc to GetSource
set goFlag to true
on error errM number errN
tell me to display dialog errM & return & return & errN
end try
end tell
if goFlag is true then
tell application "BBEdit"
activate
set newDoc to make new text window with properties ,
{contents:frntWinSrc, bounds:{5, 41, 646, 865}}
select insertion point before line 1 of newDoc
end tell
end if
---------------------------------------------------------------------------
If you really need to set the Clipboard:
set the clipboard to frntWinSrc
Keep this line outside of the Explorer Tell Block.
When you set the Clipboard inside a Tell block you need to have the designated application active. I'm very surprised your script works at all (it doesn't for me), because you're trying to set the Clipboard from the Finder.
A tip: Never set the Clipboard unless you have to. Many applications are scriptable and can set the contents of a document directly, as I've done with BBEdit in the script.
My script is going to error-out if:
* There are NO Explorer windows.
* The front window has no source (is blank, or a graphic).
Note also that GetSource needs no parameter when you're getting the source of the front window.
IE's window indexing methodology is a bit funny. You'd expect window 1 to *be* window 1; quite the contrary - run ListWindows and see.
The correct way to use the front window's index is:
tell application "Explorer"
set frontWin to item 1 of (ListWindows)
set s to GetSource frontWin
end tell
Best Regards,
Christopher Stone
______________________________
StoneWorks Computer Consulting
email@hidden