Applescript newbie here…
Have an OS9 program (WordPerfect 3.5e) which opens a web browser to view a selected html link. The kicker is that it doesn’t use OS9’s web browser preference under the control panel. WP uses its own preference file to select the desired web browser. The problem is that WP can only see OS9 apps, and I would like to use Safari which is OSX. What I would like to do is create an OS9 applescript which takes the passed argument from WP and then opens Safari with that URL. My problem is that I don’t know to code applescript to grab an external argument under OS9.
If WP’s command were executed from the command line, the command might look something like: Safari http://www.thelink.com
In Safari’s code that would follow, I would grab the first argument as the link and open it.
But how is this done in an applescript? Can this be done with applescripts? Is there another way that I should do this?
Any help and insight is greatly appreciated.
-Jonathan
After several hours of applescripting and searching the Internet, this is a workable kludge I have created.
It seems that for a clean solution, I would need to create a full OS9 application that would take in an argument as the URL and then start Safari. With my limited knowledge of OS9 programming this isn’t an option for now.
I thought I might be onto a solution with the OSX CLI. I found exampled on how to pass command line arguments to an applescript handler, but ran into the problem of using the command line from classic. Is there a way to call a unix script from classic?
So I took what I had working and made a script. I could get WP to open a URL with iCab (classic web browser). I then created a script which copied the URL from iCab to Safari. The stay open script starts WP and then waits for iCab to run. When it does it copies the link to Safari and closes iCab. Finally when WP closes the script closes.
Appreciate any critiques or insight into how this could be done better.
-Jonathan
property initialized : false
property URLLink : "http://"
on idle
tell application "Finder"
if process "iCab" exists then
if initialized is false then
set initialized to true
return 2
else
tell application "iCab"
set URLLink to item 1 of (GetWindowInfo 1)
end tell
if URLLink is "about:blank" then
return 2
else
tell application "iCab" to quit
tell application "Safari"
open location URLLink
end tell
end if
set initialized to false
end if
else
set initialized to false
end if
if process "Corel WordPerfect" exists then
else
quit me
end if
end tell
return 1
end idle
on run
tell application "Corel WordPerfect"
activate
end tell
end run
Found a better solution using the AutoType additions. Basically WP calls an applescript that uses AutoType to copy the link to the clipboard and then it passes the link to Safari from the clipboard. Works very well.
The code turned out to be pretty simple, just had to know what to call.
-Jonathan
property URLLink : "http://"
tell application "Corel WordPerfect"
activate
Do Script "Grab URL"
AutoType "C" given «class HOLD»:"command"
AutoType "`return"
end tell
tell application "Finder"
set URLLink to the clipboard
end tell
tell application "Safari"
activate
open location URLLink
end tell