如何使用osascript或AppleScript的在OS X中显示模式窗口 [英] How to display modal window using osascript or AppleScript in OS X

查看:2782
本文介绍了如何使用osascript或AppleScript的在OS X中显示模式窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何显示模式(所有应用程序,视窗)窗口中使用osascript或AppleScript的在OS X 10.6.8及更高版本。

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

下面的脚本我做的:

#!/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.

如何解决以下问题?

推荐答案

我最近写了一个脚本来监视我的MacBook电池的时候它得到了低。为了确保我没有错过我做了警戒以下...

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

在code将继续重新显示消息,即使我不小心点击其他地方得到它在另一个窗口埋葬。

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

希望有所帮助。

这篇关于如何使用osascript或AppleScript的在OS X中显示模式窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆