如何使 Mac 终端弹出/警报?苹果脚本? [英] How do I make a Mac Terminal pop-up/alert? Applescript?

查看:48
本文介绍了如何使 Mac 终端弹出/警报?苹果脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够让我的程序显示警报、通知,以及显示我的自定义文本的任何内容.这是怎么做到的?另外,是否可以用几个按钮来设置一个变量?

I want to be able to have my program display an alert, notice, whatever that displays my custom text. How is this done? Also, is it possible to make one with several buttons that sets a variable?

类似于批处理:echo msgbox""<a.vbs&a.vbs

推荐答案

使用osascript.例如:

osascript -e 'tell app "Finder" to display dialog "Hello World"' 

用您想要的任何应用程序替换Finder".请注意,如果该应用程序是后台的,对话框也会出现在后台.要始终显示在前台,请使用系统事件"作为应用程序:

Replacing "Finder" with whatever app you desire. Note if that app is backgrounded, the dialog will appear in the background too. To always show in the foreground, use "System Events" as the app:

osascript -e 'tell app "System Events" to display dialog "Hello World"'

阅读更多关于 MacOS X 提示.

这篇关于如何使 Mac 终端弹出/警报?苹果脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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