How can you make an applescript display dialog window be the front-most window

I wrote an AppleScript that I compiled as an application and it contains a "display dialog" command essentially saying "OK to proceed" - you're supposed to click on the OK button and it then goes about it's business. However, whenever that script is run the dialog box generated is *always* hidden so it looks like things have hung. The dialog box can't be revealed via Expose and, curiously nothing in my hidden-by-default dock is bouncing although when I reveal the dock the AppleScript icon for the app is indeed bouncing. How can I make the "display dialog" command in my AppleScript do the obvious thing i.e. display the darn dialog box?

MacBook Pro 16″, macOS 14.7

Posted on Mar 9, 2025 08:08 AM

Reply
3 replies

Mar 9, 2025 09:53 AM in response to Mick_M

In Sonoma 14.7.4, the AppleScript display dialog is not topmost in the window display hierarchy and will be occluded by the frontmost application. There is no AppleScript solution to avoid this on Sonoma short of writing your own display or alert window in AppleScript/Objective-C and using the window level constant NSFloatingWindowLevel to force that window above all other windows.


In macOS Sequoia, a standard AppleScript display dialog window remains above all other windows by default.



Mar 10, 2025 04:58 AM in response to Mick_M

It could very well be that the Apple developers supporting AppleScript finally woke up in Sequoia and realized that they weren't setting the NSWindow object's level to NSFloatingWindowLevel to force the display dialog to be topmost. One line of added or changed code to fix this level issue.


Same reason that if you opened a scanned (but not OCR'd PDF) in Apple's Preview in Sonoma, and chose the Export… option, you would see for the first time, an Embed Text option. Selecting that and saving the exported PDF would OCR the PDF text to enable text searches in the PDF. Apple enhanced that further in Sequoia. Apple never told the user community that beginning with Sonoma, they added this (by another name) OCR feature to Preview.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How can you make an applescript display dialog window be the front-most window

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.