有没有办法在applescript应用程序仍在运行时禁用强制退出?
我制作了一个假的病毒来尝试我的朋友:p,但我想知道是否有代码在应用程序完成之前禁用命令选项转义功能。我只想让他们体验我实验的整个过程,而不让他们中途放弃。谢谢 :编辑-这只是一个简单的脚本,我想我可以给我的朋友看,但我只是不想让他们在开始几秒钟后强制退出,他们仍然可以完全控制他们的mac电脑 显示对话框“玩MagroXELA的游戏”按钮{“玩”、“退出”}默认按钮1 如果返回结果的按钮为“播放”,则 第五集 嘟嘟声5有没有办法在applescript应用程序仍在运行时禁用强制退出?,applescript,quit,Applescript,Quit,我制作了一个假的病毒来尝试我的朋友:p,但我想知道是否有代码在应用程序完成之前禁用命令选项转义功能。我只想让他们体验我实验的整个过程,而不让他们中途放弃。谢谢 :编辑-这只是一个简单的脚本,我想我可以给我的朋友看,但我只是不想让他们在开始几秒钟后强制退出,他们仍然可以完全控制他们的mac电脑 显示对话框“玩MagroXELA的游戏”按钮{“玩”、“退出”}默认按钮1 如果返回结果的按钮为“播放”,则 第五集 嘟嘟声5 display dialog "Virus is downloading."
display dialog "Virus is downloading." buttons "Stop" default button "Stop" with title "Malware Initiating" with icon 2
delay 2
set volume 5
do shell script "say -v Zarvox Virus has Down loaded Successfully"
delay 2
do shell script "say -v Zarvox Wifi terminated"
beep 1
--
-- Toggle Airport Power On and Off
--
if (offset of "On" in (do shell script "networksetup -getairportpower en1")) > 0 then
do shell script "networksetup -setairportpower en1 off"
end if
tell application "Finder"
activate
open application file "Activity Monitor.app" of folder "Utilities" of folder "Applications" of startup disk
open application file "AirPort Utility.app" of folder "Utilities" of folder "Applications" of startup disk
open application file "Boot Camp Assistant.app" of folder "Utilities" of folder "Applications" of startup disk
open application file "Bluetooth File Exchange.app" of folder "Utilities" of folder "Applications" of startup disk
open application file "Disk Utility.app" of folder "Utilities" of folder "Applications" of startup disk
open application file "Keychain Access.app" of folder "Utilities" of folder "Applications" of startup disk
open application file "Terminal.app" of folder "Utilities" of folder "Applications" of startup disk
open application file "System Information.app" of folder "Utilities" of folder "Applications" of startup disk
end tell
tell application "Finder"
activate
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
make new Finder window
set target of Finder window 1 to startup disk
set target of Finder window 1 to startup disk
open application file "Terminal.app" of folder "Utilities" of folder "Applications" of startup disk
set target of Finder window 1 to startup disk
set target of Finder window 1 to folder "Applications" of startup disk
end tell
delay 6
tell application "DigitalColor Meter" to quit
tell application "Grab" to quit
tell application "Network Utility" to quit
tell application "System Information" to quit
tell application "Terminal" to quit
tell application "Keychain Access" to quit
tell application "Disk Utility" to quit
tell application "Bluetooth File Exchange" to quit
tell application "Boot Camp Assistant" to quit
tell application "AirPort Utility" to quit
tell application "Activity Monitor" to quit
tell application "App Store" to quit
tell application "iTunes" to quit
tell application "Finder"
repeat while window 1 exists
close window 1
end repeat
delay 2
set volume 5
do shell script "say -v Alex YOU GOT TROLLED HUH HUH HUH HUH"
delay 2
do shell script "say -v Zarvox Wifi activated"
--
-- Toggle Airport Power On and Off
--
if (offset of "On" in (do shell script "networksetup -getairportpower en1")) > 0 then
do shell script "networksetup -setairportpower en1 off"
else
do shell script "networksetup -setairportpower en1 on"
end if
delay 4
您可以使用命令行工具“osascript”执行任何applescript代码。正在运行的命令行工具不会显示在强制退出菜单中,因此此方法应该适合您。例如,假设这是您的applescript
tell application "TextEdit" to activate
delay 5
tell application "TextEdit" to quit
下面是如何使用osascript运行该脚本
set theCode to "tell application \"TextEdit\" to activate
delay 5
tell application \"TextEdit\" to quit"
do shell script "echo " & quoted form of theCode & " | osascript > /dev/null 2>&1 &"
所以基本上,您所要做的就是将applescript代码转换为文本,然后将其发送到osascript,如图所示
祝你好运。你也可以这样做:
内容的目录。在该文件夹中将有一个名为Info.plist
之前的文件末尾添加此代码:
LSBackgroundOnly
因此,文件的最后四行如下所示:
<key>LSBackgroundOnly</key>
<true/>
</dict>
</plist>
LSBackgroundOnly
保存文件,就可以开始了。您可以关闭文本编辑器并双击应用程序
此属性导致OS X以后台进程的形式运行应用程序,后台进程不会显示在Dock中,也不会显示在Force Quit窗口中。当然,您仍然可以使用活动监视器强制退出应用程序
请注意,此属性不允许任何用户交互,如显示对话框
或选择文件夹
(如果在AppleScript编辑器中打开应用程序,则必须重复此步骤,因为每次保存时脚本编辑器都会覆盖Info.plist)我们肯定不会帮助您阻止某人重新控制其计算机。为什么我们要相信你,你只会给你的朋友一个无害的脚本?我发布这个脚本是为了展示它的功能,只是认为会有一个脚本禁用强制退出,甚至只是从强制退出菜单中隐藏应用程序。我不想让他们失去对电脑的控制确实有办法做到这一点。虽然你发布的脚本看起来不太危险,但是你仍然可以使用我给你的信息来制作另一个非常邪恶的脚本。当他的Mac电脑开始打开几个应用程序和许多窗口时,有人会失去对它的控制。嗯,我想是的,但我现在使用学校的Mac电脑还有几年,直到我完成学业,所以如果我因此弄乱了他们的Mac电脑,我将承担全部责任。我不打算把它用于邪恶的脚本,我只是这个应用程序的新手脚本:P但我明白你的意思,我会试试看。谢谢:)是的,我几个小时前才发现,除了使用LSUIelement,谢谢你的帮助。顺便说一句,“请注意,此属性不允许任何用户交互,如显示对话框或选择文件夹”,这是什么意思。LSBackground和LSUIelement都很相似,但我可以看到显示对话框并可以单击按钮。@AlexDylanMagri AppleScript有时在显示对话框时会显示消息“UI不允许”退出应用程序,这正是我的意思。如果我或任何答案已经解决了你的问题,请考虑点击复选标记。这向更广泛的社区表明,你已经找到了一个解决方案,并给回答者和你自己带来了一些声誉。没有义务这么做。好的,谢谢,我点击了复选标记,因为我相信其他人会发现这很有用。谢谢你。这个网站也是新的
<key>LSBackgroundOnly</key>
<true/>
</dict>
</plist>