Skip to content

Instantly share code, notes, and snippets.

@ochubey
Last active February 8, 2017 15:23
Show Gist options
  • Save ochubey/b760e7fae71e704f2dcb087c5d5d956d to your computer and use it in GitHub Desktop.
Save ochubey/b760e7fae71e704f2dcb087c5d5d956d to your computer and use it in GitHub Desktop.
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