阻止对话框阻止用户注销?

发布于 2024-10-29 09:01:24 字数 131 浏览 4 评论 0原文

我们有一个用 applescript 编辑器制作的简单 .app,当用户登录时会弹出一个显示对话框。问题是许多用户忽略该框并且不按“确定”将其关闭。如果它保持打开状态,将阻止用户注销计算机。

有什么方法可以防止对话框阻止注销过程吗?

We have a simple .app made with applescript editor that pops up a display dialog box when a user logs in. The problem is that many users ignore the box and don't press "ok" to close it. If it's left open it will prevent the user from logging off the computer.

Is there any way to prevent the dialog box from holding up the log off process?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

草莓酥 2024-11-05 09:01:24

我能想到的两件事:1)你可以在对话框上放置一个“放弃”命令,以便在一段时间后自动关闭,例如5秒......

display dialog "Hello" giving up after 5

或者你可以自己编写一个注销脚本。当用户注销时将运行此脚本。像这样的东西会起作用。

tell application "System Events"
    if exists process "ApplicationName" then
        set itExists to true
    else
        set itExists to false
    end if
end tell

if itExists then
    tell application "ApplicationName" to activate
    tell application "System Events" to keystroke return
end if

谷歌搜索“logout hook”来查找如何在注销时运行脚本。

2 things I can think of: 1) you can put a "giving up after" command on the dialog box so that it's automatically dismissed after a time, for example 5 seconds...

display dialog "Hello" giving up after 5

Or you can write yourself a logout script. This script will be run when a user logs out. Something like this would work.

tell application "System Events"
    if exists process "ApplicationName" then
        set itExists to true
    else
        set itExists to false
    end if
end tell

if itExists then
    tell application "ApplicationName" to activate
    tell application "System Events" to keystroke return
end if

Google for "logout hook" to find how to run a script at logout.

小巷里的女流氓 2024-11-05 09:01:24

我想问一下,为什么不直接修改 AppleScript 代码以在 5 分钟后自动关闭对话框呢?这肯定比“黑客”硬注销系统更容易。

display dialog "Hello World" buttons "Ok" giving up after (5 * 60)

例如,此对话框将在 5 分钟后自动关闭。正如您在问题中指出的那样,足够长的时间供用户阅读它,如果他们真的关心它,而其他人无论如何都会忽略它。

May I rather ask, why you don't just modify the AppleScript code to close the dialog box automatically after, let's say, 5 minutes? This will be definitely easier than "hacking" a hard log-off into the system.

display dialog "Hello World" buttons "Ok" giving up after (5 * 60)

This dialog will auto-close after 5 minutes for example. Long enough for users to read it, if they really care about it and the other ones ignore it anyway, as you pointed out in your question.

时光暖心i 2024-11-05 09:01:24

不幸的是,显示对话框总是需要用户采取行动才能消失,除非您使用“之后放弃”让通知自行消失,而他们不一定会阅读它。

假设您需要他们阅读它,并且如果您可以控制它将要运行的计算机,则可以使用 咆哮以显示您的通知。

在我看来,您可以将显示对话框放入空闲处理程序中,如果它们实际上单击“确定”,则脚本退出;如果他们不单击“确定”,请使用其他答案中所述的“放弃”,使其在您想要的几秒后消失,然后在下一个空闲时再次弹出。这可能非常烦人,并且如果他们碰巧在对话框启动时注销,仍然存在阻止注销的风险。

on idle
    --display the alert for 7 seconds
    display alert "Very Important Message" giving up after 7
    if the button returned of the result is "ok" then
        quit
    end if

    --idle for 90 seconds
    return 90
end idle

Unfortunately, display dialog always requires action from the user to go away, unless you have the notification go away on its own using “giving up after”, without them necessarily reading it.

Assuming you need them to read it, and if you have control over the computers it’s going to be on, you could use Growl to display your notifications.

It occurs to me you could put the display dialog in an idle handler, and if they actually click “ok” have the script quit; if they don’t click “ok”, use “giving up after” as described in the other answers to make it go away after however many seconds you want and then pop it back up again on the next idle. This could be extremely annoying, and still runs the risk of blocking logout if they happen to log out while the dialog is up.

on idle
    --display the alert for 7 seconds
    display alert "Very Important Message" giving up after 7
    if the button returned of the result is "ok" then
        quit
    end if

    --idle for 90 seconds
    return 90
end idle
画▽骨i 2024-11-05 09:01:24

这对我有用,强制用户注销。完全禁用 Mac OS X 中的“重新登录时重新打开 Windows”和注销确认

tell application "System Events"
    keystroke "Q" using {command down, option down, shift down}
    quit
end tell

This work for me, force user logout. Disable “Reopen Windows When Logging Back In” in Mac OS X Completely and Logout confirmation

tell application "System Events"
    keystroke "Q" using {command down, option down, shift down}
    quit
end tell
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文