Advertisement
Guest User

Untitled

a guest
Apr 30th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. on BTdevice_connected(theDevice)
  2.     try
  3.         set theData to do shell script "system_profiler SPBluetoothDataType"
  4.         set {TID, text item delimiters} to {text item delimiters, theDevice}
  5.         set theData to text item 3 of theData
  6.         set text item delimiters to "Connected: "
  7.         set theData to word 1 of text item 2 of theData
  8.         set text item delimiters to TID
  9.         return theData is "Yes"
  10.     on error
  11.         return false
  12.     end try
  13. end BTdevice_connected
  14.  
  15.  
  16. mm2_init()
  17.  
  18. on inited(a) --초기화 확인
  19.     if a is true then --초기화 되었고
  20.         if BTdevice_connected("Magic Mouse 2") is true then --마우스가 연결되어있다면
  21.             display dialog "a"
  22.             delay 30 --360초동안 대기
  23.             inited(true)
  24.         else --마우스 연결이 해제되었다면
  25.             inited(false) --
  26.         end if
  27.     else --마우스 연결 해제시
  28.         mm2_init() --재초기화 필요
  29.     end if
  30. end inited
  31.  
  32. on mm2_init() --지터치 초기화, 마우스 상태 확인
  33.     if BTdevice_connected("Magic Mouse 2") is true then
  34.         tell application "Jitouch"
  35.             quit
  36.         end tell
  37.         do shell script "open ~/Library/PreferencePanes/Jitouch.prefPane/Contents/Resources/Jitouch.app"
  38.         inited(true)
  39.     else
  40.         display dialog "b"
  41.         delay 10
  42.         mm2_init()
  43.     end if
  44. end mm2_init
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement