Re: Is there a way to keep a floating window open?
Re: Is there a way to keep a floating window open?
- Subject: Re: Is there a way to keep a floating window open?
- From: "David B. Gustavson" <email@hidden>
- Date: Thu, 5 Jan 2006 11:40:10 -0800
Thanks, Kai!
This is exactly what I needed.
I did use Growl meanwhile, and it kind of works, but had cosmetic
problems like the window size being too small for some of the lines I
wanted displayed so they wrapped awkwardly, and there was no way to
change that that I could find.
Your solution has the advantage of not needing any non-AppleScript
extra stuff. It would be nice if it could install its helper app
itself, but saving a script app in Applications isn't hard to
document for a manual install.
Thank you very much, and also for the explanatory material you included.
Is there a way to control or affect the position of the display
dialog, or to put something in its title bar?
Dave
At 4:26 AM +0000 1/5/06, kai wrote:
On 2 Jan 2006, at 20:43, David B. Gustavson wrote:
I'd like to display some text that is updated occasionally by an
AppleScript, in a floating window that hangs around until I close
it. My present workaround is to use
display dialog "Mail last fetched at: " & return & lasttime giving up after 4
to display the info briefly, but that's not really satisfactory.
I'm running the script in Eudora, and Eudora waits for the script
to exit before it continues checking the mail. If I could make it
run in a separate thread I could let it display longer without
holding up progress, but I don't know if it's possible to make that
happen.
Running the script in a script editor environment acts more the way
I'd like, i.e. separate thread/task, but is awkward in other ways.
Nearly missed this one, David - so apologies for the delayed response.
The issue here is that 'display dialog' produces an
application-modal dialog, which prevents the user from doing
anything else within the owning application (apart, perhaps, from
selecting or moving a window or two). Since the main purpose of an
AppleScript dialog/alert is to check with the user before
continuing, execution is normally suspended until the required
input/response is received:
-----------
repeat with n from 1 to 10
say n
if n is 5 then
display dialog "I'm waiting..."
end if
end repeat
-----------
However, by switching ownership of the dialog to some other
application, you should be able to free up the application you're
currently targeting, so that the script can continue. A likely
"subcontractor" might be a readily available app (obviously one able
to display a dialog/alert), such as Finder or System Events - as
long as it's not likely to be called for the rest of your script.
To make sure the script doesn't expect a response from this second
application, use an ignoring application responses statement:
-----------
repeat with n from 1 to 10
say n
if n is 5 then ignoring application responses
tell application "System Events" to display dialog
"Sorry, can't stop..."
end ignoring
end repeat
-----------
A further refinement of this approach is to create your own,
dedicated application for the purpose. You only need a short script,
something like this:
-----------
to show_message(m, t)
activate
display dialog m buttons {"OK"} default button 1 giving up after t
if t is 0 or t > 60 then return quit
tell application "System Events" to set process "Message"'s
visible to false
end show_message
-----------
Save this as a stay-open application. (Not essential, but for
frequent messages, a stay-open app will be generally more responsive
- which is why a quit statement is included above.) As you may have
noticed, I saved this example as "Message".
To call the Message application, simply add the following snippet to
your script at the appropriate point, modifying the text of the
message as required (and following that with an integer, to indicate
the seconds before giving up):
-----------
ignoring application responses
tell application "Message" to show_message("Stage 3 complete.", 5)
end ignoring
-----------
For the final message in a series of several, the time delay can be
set to 0 (so that the last dialog can stay open indefinitely) - or
to an interval greater than the upper limit specified in the app (in
this instance, one minute). In either case, the app will quit when
the final dialog is dismissed:
-----------
ignoring application responses
tell application "Message" to show_message("Final stage
complete. Drinks all round!", 300)
end ignoring
-----------
---
kai
--
--David B. Gustavson, tel:650/961-0305 fax:208/475-7525
1946 Fallen Leaf Lane, Los Altos, CA 94024-7206 email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden