Last active
February 8, 2017 15:23
-
-
Save ochubey/b760e7fae71e704f2dcb087c5d5d956d 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
on run argv | |
tell application "Simulator" to launch | |
set inTime to current date | |
repeat | |
tell application "System Events" | |
if "Simulator" is in (get name of processes) then exit repeat | |
end tell | |
if (current date) - inTime is greater than 10 then exit repeat | |
delay 0.2 | |
end repeat | |
tell application "Simulator" to activate | |
set inTime to current date | |
repeat | |
tell application "System Events" | |
if visible of process "Simulator" is true then exit repeat | |
end tell | |
if (current date) - inTime is greater than 10 then exit repeat | |
delay 0.2 | |
end repeat | |
set wantChecked to ("0" is not (item 1 of argv)) | |
tell application "System Events" | |
tell process "Simulator" | |
tell menu bar 1 | |
tell menu bar item "Hardware" | |
tell menu 1 | |
tell menu item "Keyboard" | |
tell menu 1 | |
set isChecked to (value of attribute "AXMenuItemMarkChar" of menu item "Connect Hardware Keyboard") as string | |
if isChecked is "✓" then | |
click menu item "Connect Hardware Keyboard" | |
end if | |
end tell | |
end tell | |
end tell | |
end tell | |
end tell | |
end tell | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment