Re: User Scripts
Re: User Scripts
- Subject: Re: User Scripts
- From: Andreas Grosam <email@hidden>
- Date: Fri, 16 Jan 2009 17:06:20 +0100
On 16.01.2009, at 02:43, Philip Aker wrote:
On 2009-01-15, at 11:00:32, Andreas Grosam wrote:
how can I ensure that an application launched from a user script
will be put to the foreground and becomes the active application,
which possibly opens a modal dialog when it starts up?
I call this simple script:
#!/bin/sh
$HOME/Applications/DiffMerge.app/Contents/MacOS/DiffMerge -
nosplash "%%%{PBXFilePath}%%%"
The app not always launches in the foreground or is behind a Xcode
editor window, and it also does not always become the active
application. That is, Xcode still might be the active application,
but the launched tool may be in the foreground.
When started, the app opens a modal dialog - which might be the
culprit. Without causing the app to open a modal dialog at its
start up, all seems working well: it is put to the foreground and
it also becomes the active application.
I would like to use the command open instead, however, with open
it seems it is not possible to pass program arguments.
How can I accomplish this in an easy way?
Try this:
#!/bin/sh
$HOME/Applications/DiffMerge.app/Contents/MacOS/DiffMerge -nosplash
"%%%{PBXFilePath}%%%"
/usr/bin/osascript -e 'tell application "DiffMerge" to activate'
Thanks for the tip using AppleScript. Unfortunately, it won't work
(yet). The problem now is, that two instances of DiffMerge will be
launched. I guess, the problem is that the AppleScript runtime
performs the "activate" command before the former process is actually
established. So, a hack would be to insert a sleep() before the
osascript command.
But this would also not solve my needs completely: there might be
cases where one or more instances of DiffMerge are already running.
The user script should ensure that exactly that DiffMerge instance
will be put to the foreground which has been launched in this script.
I would prefere a pure Apple Script solution. However, the app
DiffMerge is not scriptable - that is only the basic commands and
built-in osascript commands will work. For instance this apple script
snippet
‘launch application "DiffMerge"‘ works perfectly. If I were able to
pass program arguments, and also get a PID (in order to refere to
this app later) -- that would be great.
Andreas
Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@
Democracy: Two wolves and a sheep voting on lunch.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden