Created
April 10, 2019 01:35
-
-
Save rppig42/eb20337790cf17bb0d2c664d52351d5d to your computer and use it in GitHub Desktop.
休眠时注销Mac微信,以避免其手机消息禁音
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
script = [[ | |
tell application "WeChat" to activate | |
tell application "System Events" | |
tell process "WeChat" | |
key code 43 using {command down} | |
end tell | |
end tell | |
tell application "System Events" | |
tell process "WeChat" | |
tell window "General" | |
click button "Log Out" of window "General" of application process "WeChat" of application "System Events" | |
end tell | |
end tell | |
end tell | |
delay 1 | |
tell application "System Events" | |
tell process "WeChat" | |
tell window "General" | |
click button "Log Out" of sheet 1 of window "General" of application process "WeChat" of application "System Events" | |
end tell | |
end tell | |
end tell | |
]] | |
function logoutWechat(eventType) | |
if (eventType == hs.caffeinate.watcher.screensDidSleep) then | |
print("screensDidSleep") | |
hs.applescript(script) | |
elseif (eventType == hs.caffeinate.watcher.screensDidLock) then | |
--锁屏时似乎无法进行屏幕操作 | |
--print("screensDidLock") | |
--hs.applescript(script) | |
end | |
end | |
caffeinateWatcher = hs.caffeinate.watcher.new(logoutWechat) | |
caffeinateWatcher:start() | |
我这边直接quit不能生效的原因知道了, 因为我装了防撤回插件...
So all this does is quit WeChat?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
直接退出微信就退出登录了,我这里有效