本文介绍了如何在 OS X 中使用 osascript 或 AppleScript 显示模态窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 OS X 10.6.8 及更高版本中使用 osascript 或 AppleScript 显示模式(在所有应用程序、窗口上)窗口.
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
即使我不小心点击了其他地方,代码也会继续重新显示消息,并将其隐藏在另一个窗口下.
The code will keep redisplaying the message even if I accidentally click elsewhere and it gets buried under another window.
希望有所帮助.
这篇关于如何在 OS X 中使用 osascript 或 AppleScript 显示模态窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!