문제

How to display modal(over all apps, windows) window using osascript or AppleScript in OS X 10.6.8 and later.

Here a script I do:

#!/bin/bash

osascript -e 'tell app "System Events" to display dialog "My Dialog" buttons {"OK"} default button 1 with title "My Dialog" with icon caution'

The problem is that it's not modal.

How to fix the following issue?

도움이 되었습니까?

해결책 2

I wrote a script recently to monitor my macbook battery when it got low. To make sure I didn't miss the alert I did the following...

repeat while true
    me activate
    set userResp to display dialog ¬
        "Yes or No?" as text buttons {"No", "Yes"} ¬
        default button "Yes" with icon caution ¬
        with title "Question" giving up after 5
end repeat

The code will keep redisplaying the message even if I accidentally click elsewhere and it gets buried under another window.

Hope that helps.

다른 팁

You can use the "display notification" command to place a notification above all other windows (and into Notification Center,) but you can’t block the user from using their computer.

display notification "Message"

Another way to get the user’s attention is to say something.

say "Message"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top