Newbie Help with System Events, Dialog Box, & Finder Interaction

I wrote a set of applescripts that throw up a dialog box using the level of “System Events” because I want the dialog box to show up in front of everything. I also have it set with a timeout to make sure that the dialog box can “hang” while I’m doing what the information in the dialog box is telling me to do. I can’t use other levels like the “Finder” or the name of the Applescript application itself or else it won’t throw it up to the top level of system events (i.e. put it in front of whatever else I’m doing). And if I use the “finder” to throw up the dialog box it locks me out from doing other things with the finder, which I don’t want.

The three wierdest things that have been happening:

  1. When I look at three finder windows open in list view with my “Get Clear On Projects” script. If I try to change the name of a file in one of those finder windows it will highlight the file name, not allow me to see the name of the file, and then it does wierd things in the other windows even though I haven’t clicked in them. I don’t think this is because of the scripts but because of some wierd interaction with the OS, System Events, Finder, or something.

  2. If I “control-click” or “right-click” on a file name when this dialog box that has been thrown up by System Events pops up I’ll often get “hanging” with a spinning rainbow ball or the Applescript application will freeze.

  3. The way I’m using this dialog box is to help tell me what to do on my mac. It waits for me to do it. And then I click okay and move on to the next thing. Unfortunately as I am doing things the dialog box will disappear behind windows and I then have to go find it again to move to click okay and move to the next thing. I wish Apple would make it so that regardless of what level a dialog box is at you could “command-tab” to it. Or see it with Expose or something.

At any rate, I would REALLY appreciate any feedback, suggestions, or tips with this. Any help would be welcomed. And if you would like to try my scripts and see what they’re doing you can find them here:!

Thanks so much,

Todd V


No need to trigger System Events.

tell application (path to «constant afdregfp» as string) to ¬
	display dialog ¬
		"my pretty dialog" with icon 0 ¬
		buttons {" Vu "} giving up after 20

Will do the trick.

«constant afdregfp» isthe raw format for " frontmost application".
I coded this way for old systems.

Yvan KOENIG (from FRANCE samedi 14 octobre 2006 06:53:44)

EDIT: Yvan’s path to frontmost… solution - which got posted while I was typing - is simpler than my suggestion. Oh, well.


That 87.9 MB download isn’t going to be very fast, so I’ll jump ahead to a couple of suggestions.

If you want to be able to command tab back to your dialog, tell your application to display the dialog. Try this:

Open a new document in script editor and save the blank script as an application named “Dialog” - you need an existing application or when you try to compile you’ll get “Where is application Dialog?”

Then, put this in to the application, which is still open in the editor:

tell application "Dialog Test"
	display dialog "one"
	display dialog "two"
end tell

Save it again and run the application. You’ll be able to command tab back to the dialog, but Expose won’t work.

Or you could open text documents, and set the size and posistion on your desktop to make them less obtrusive, followed by dialog so you could click a button to move to the next step. Seems an inelegant way to do it, though.

--It's just an example so it doesn't open an existing file.
tell application "TextEdit"
	make new document
	set bounds of window 1 to {0, 22, 400, 400}
end tell

Okay, the download finished (while I typed very slowly) and I looked in the package to get a rough idea of what you are doing.

Maybe this is should be an AppleScript Studio project?