• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Is there a way to keep a floating window open?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a way to keep a floating window open?


  • Subject: Re: Is there a way to keep a floating window open?
  • From: kai <email@hidden>
  • Date: Thu, 5 Jan 2006 04:26:35 +0000


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


_______________________________________________ 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
  • Follow-Ups:
    • Re: Is there a way to keep a floating window open?
      • From: "David B. Gustavson" <email@hidden>
References: 
 >Re: How do you get a stay-open applet to quit? (From: has <email@hidden>)
 >Is there a way to keep a floating window open? (From: "David B. Gustavson" <email@hidden>)

  • Prev by Date: Saving Safari documents as html?
  • Next by Date: Re: mounting ejected volumes
  • Previous by thread: Is there a way to keep a floating window open?
  • Next by thread: Re: Is there a way to keep a floating window open?
  • Index(es):
    • Date
    • Thread