Re: Simple newbie question
Re: Simple newbie question
- Subject: Re: Simple newbie question
- From: KOENIG Yvan <email@hidden>
- Date: Wed, 14 May 2008 11:18:41 +0200
If we want a generic script which may be used with different apps we
may edit it this way:
my switch("Stickies", "TextEdit")
on switch(theApp1, theApp2)
tell application "Finder" to set flag to theApp1 is in (get name of
every process)
if flag then
tell application theApp1 to quit
tell application theApp2 to quit
else
tell application theApp1 to activate
tell application theApp2 to activate
end if
end switch
on run, it gives:
tell application "Finder"
get name of every process
end tell
tell application "System Events"
get name of every process
{"loginwindow", "WacomTabletDriver", "Dock", "TabletDriver",
"Finder", "System Events", "StuffItAVRDaemon", "RapidoWriteService",
"Sidekick", "UniversalAccess", "Mail", "Safari", "Numbers", "Script
Editor", "SystemUIServer"}
end tell
tell some application
activate
current application
end tell
tell application "Stickies"
activate
end tell
tell some application
activate
current application
end tell
tell application "TextEdit"
activate
end tell
or
tell application "Finder"
get name of every process
end tell
tell application "System Events"
get name of every process
{"loginwindow", "WacomTabletDriver", "Dock", "TabletDriver",
"Finder", "System Events", "StuffItAVRDaemon", "RapidoWriteService",
"Sidekick", "UniversalAccess", "Mail", "Safari", "Numbers", "Script
Editor", "SystemUIServer", "Stickies", "TextEdit"}
end tell
tell application "Stickies"
quit current application
end tell
tell application "TextEdit"
quit current application
end tell
I tried an alternate version:
my switch("Stickies", "TextEdit")
on switch(theApp1, theApp2)
tell application "Finder" to if theApp1 is in (get name of every
process) then
tell application theApp1 to quit
tell application theApp2 to quit
else
tell application theApp1 to activate
tell application theApp2 to activate
end if
end switch
but, on run it does:
tell application "Finder"
activate
activate
end tell
or
tell application "Finder"
get name of every process
end tell
tell application "System Events"
get name of every process
{"loginwindow", "WacomTabletDriver", "Dock", "TabletDriver",
"Finder", "System Events", "StuffItAVRDaemon", "RapidoWriteService",
"Sidekick", "UniversalAccess", "Mail", "Safari", "Numbers", "Script
Editor", "SystemUIServer", "Stickies", "TextEdit"}
end tell
tell application "Finder"
quit application "Stickies"
"Erreur dans Finder : Impossible d’obtenir application \"Stickies
\"."
I don't understand why it behaves this way but I must take care of
this behavior.
Yvan KOENIG (from FRANCE mercredi 14 mai 2008 11:17:42)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden