Hello,
I am trying to write a script where I run multiple instances of Safari (Safari 1, Safari 2 etc.) and I want to be able to refer to the one I am currently working with (the active one) as active_Safari (so for example set active_Safari to "Safari 1"). The problem is that I always get an error when I try to put down the variable instead of the usual way to refer to an application. Here is my script below:
When I run this, I always get this error, and I don't get it when I replace the variable with "Safari 1"...is it not possible to use variables as placeholders for applications?
System Events got an error: Can't get application "Safari 1".
on Change_active_Safari(num)
return "Safari " & (num as string)
end Change_active_Safari
set active_Safari to Change_active_Safari(1)
--following code checks if Safari 1 has loaded its page
delay 0.5
tell application "System Events" to tell application (active_Safari as string)
activate
if (name of window 1) begins with "Contacting" or (name of window 1) begins with "Loading" then
else
--tell application "Extra Suites" to say "done"
end if
end tell
(*
When I run this, I get:
System Events got an error: Can't get application "Safari 1".
But if I replace active_Safari variable with the name of the app itsel ("Safari 1") I get no error.
*)