加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

终端 – 将进度条添加到AppleScript中“执行shell脚本”的对话框

发布时间:2020-12-15 22:02:53 所属栏目:安全 来源:网络整理
导读:我有一个我正在使用AppleScript编写的应用程序将圣伯纳德重定向LaunchDaemon移动到当前用户的目录,以便用户可以访问家中的任何网站,但让他们在回到学校之前将其放回原处.这样做的原因是,在学校,iPrism阻止学校不希望你去的任何网站,但当学生在家时,圣伯纳德L
我有一个我正在使用AppleScript编写的应用程序将圣伯纳德重定向LaunchDaemon移动到当前用户的目录,以便用户可以访问家中的任何网站,但让他们在回到学校之前将其放回原处.这样做的原因是,在学校,iPrism阻止学校不希望你去的任何网站,但当学生在家时,圣伯纳德LaunchDaemon阻止了相同的网站,我认为没有必要这样做.

无论如何,我想在一个对话框中添加一个进度条,该对话框显示删除应用程序的shell脚本的输入.谁知道怎么做?

(我也想在显示对话框“删除…”按钮“”上没有任何按钮,而只是有进度条.这可能吗?)

这是代码:

display alert "You may have to restart your computer after using this tool!" buttons {"Ok"} default button 1

set question to display dialog "RMR (Remove My Redirect)

Are you unable to go to a website at home because of that annoying St. Bernard Redirect?

If the answer is Yes,then RMR is your solution! Simply Choose Remove to remove it,and Replace to put it back." buttons {"Remove","Replace","Erase Evidence"} default button 3
set answer to button returned of question

if answer is equal to "Remove" then do shell script "mv /Library/LaunchDaemons/com.stbernard.rfcd.plist ~/"

if answer is equal to "Replace" then do shell script "mv ~/com.stbernard.rfcd.plist /Library/LaunchDaemons/"

if answer is equal to "Erase Evidence" then set question to display dialog "Are you sure? RMR will be deleted forever." buttons {"Yes","No"} default button 2
set answer to button returned of question

if answer is equal to "No" then do shell script "echo"

-- Progress bar goes on the below dialog

if answer is equal to "Yes" then ?
    tell application "Terminal"
        display dialog "Removing..." buttons ""
        do shell script "srm -rf ~/Downloads/RMR.app; history -c; killall Terminal"
        delay 20
        quit
    end tell

提前感谢任何可以提供帮助的人!

解决方法

MacOS X 10.10或更高版本的Applescript具有进度条的内置术语.对于applet,它在对话框中运行进度指示器.在脚本编辑器中,它显示在状态栏中.适应这个术语:

set n to 10

set progress total steps to n
set progress description to "Script Progress"
set progress additional description to "This should be helpful"

repeat with i from 1 to n
    delay 1
    set progress completed steps to i
end repeat

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读