gpt4 book ai didi

macos - 如何解锁我的电脑并通过 applescript 显示屏幕?

转载 作者:行者123 更新时间:2023-12-01 09:57:47 25 4
gpt4 key购买 nike

我每天早上运行一个“唤醒”脚本来打开一个 youtube 播放列表。但是它没有显示在屏幕上,因为我的计算机在闲置几分钟后会自动锁定。

我正在使用从另一个问题中获得的以下脚本

tell application "System Events"
tell security preferences
set require password to wake to false
end tell
end tell

tell application "ScreenSaverEngine" to quit

但它实际上并没有让我的电脑屏幕打开。我必须按一个键/移动鼠标。它实际上使我的计算机无法使用,只有最前面的应用程序的菜单有效,必须重新启动。也许它没有正确解锁?

最佳答案

我在 10.10.2 上测试过这个,它解锁了屏幕。

首先,您需要下载我编写的名为 MouseTools 的免费程序。它用你的鼠标做事,在这种情况下,我们可以使用 MouseTools 来移动你的鼠标,这将解锁屏幕。 Get MouseTools here .然后系统事件可以输入您的密码并完成解锁屏幕。然后,您需要在您的计算机上输入 MouseTools 的路径以及用于在脚本顶部解锁计算机的密码。

请注意,代码获取当前鼠标位置并将其向上和向右移动 1 个像素以解锁屏幕。祝你好运。

-- input your values in these variables
set pword to "my password"
set mousetools to (path to home folder as text) & "path:to:MouseTools"

-- get the current mouse location and add a pixel to each coordinate
set currentLocation to paragraphs of (do shell script quoted form of POSIX path of mousetools & " -location")
set newX to ((item 1 of currentLocation) as number) + 1
set newY to ((item 2 of currentLocation) as number) - 1

-- move the mouse
do shell script quoted form of POSIX path of mousetools & " -x " & (newX as text) & " -y " & (newY as text)

delay 1

-- keystroke your password
tell application "System Events"
keystroke pword
delay 1
keystroke return
end tell

关于macos - 如何解锁我的电脑并通过 applescript 显示屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21995122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com