SHARE
TWEET

Untitled

a guest Apr 19th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. script = [[
  2.     tell application "WeChat" to activate
  3.  
  4.     tell application "System Events"
  5.         tell process "WeChat"
  6.             key code 43 using {command down}
  7.         end tell
  8.     end tell
  9.  
  10.     tell application "System Events"
  11.         tell process "WeChat"
  12.             tell window "General"
  13.                 click button "Log Out" of window "General" of application process "WeChat" of application "System Events"
  14.             end tell
  15.         end tell
  16.     end tell
  17.  
  18.     delay 1
  19.  
  20.     tell application "System Events"
  21.         tell process "WeChat"
  22.             tell window "General"
  23.                 click button "Log Out" of sheet 1 of window "General" of application process "WeChat" of application "System Events"
  24.             end tell
  25.         end tell
  26.     end tell
  27.  
  28. ]]
  29.  
  30. function logoutWechat(eventType)
  31.     if (eventType == hs.caffeinate.watcher.screensDidSleep) then
  32.         print("screensDidSleep")
  33.         hs.applescript(script)
  34.     elseif (eventType == hs.caffeinate.watcher.screensDidLock) then
  35.         --锁屏时似乎无法进行屏幕操作
  36.         --print("screensDidLock")
  37.         --hs.applescript(script)
  38.     end
  39. end
  40.  
  41. caffeinateWatcher = hs.caffeinate.watcher.new(logoutWechat)
  42. caffeinateWatcher:start()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top