Created
November 15, 2019 05:39
-
-
Save moyashi/ad9342024b3da3fb789826bc4c73ae24 to your computer and use it in GitHub Desktop.
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
toggleInstantHotspot = [[ | |
tell application "System Events" | |
tell process "SystemUIServer" | |
tell menu bar 1 | |
set menuBarItems to (every menu bar item whose description begins with "Wi-Fi") | |
if (count of menuBarItems) is greater than 0 then | |
set wifiMenuBarItem to item 1 of menuBarItems | |
click wifiMenuBarItem | |
--接続中か判定 | |
set menuItemDisconnects to (every menu item of menu 1 of wifiMenuBarItem whose name ends with "との接続を解除") | |
if (count of menuItemDisconnects) is greater than 0 then | |
click item 1 of menuItemDisconnects | |
return | |
end if | |
repeat with i in every menu item of menu 1 of wifiMenuBarItem | |
try | |
if (value of attribute "AXValueDescription" of i ends with " インターネット共有.") then | |
click i | |
exit repeat | |
end if | |
end try | |
end repeat | |
end if | |
end tell | |
end tell | |
end tell | |
]] | |
hs.hotkey.bind({"cmd"}, "F1", function() | |
hs.osascript.applescript(toggleInstantHotspot) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment