Skip to content

Instantly share code, notes, and snippets.

@cprovatas
Last active January 15, 2018 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cprovatas/5cc63ade5295d99cbaa3bf7b7ad5d4d5 to your computer and use it in GitHub Desktop.
Save cprovatas/5cc63ade5295d99cbaa3bf7b7ad5d4d5 to your computer and use it in GitHub Desktop.
Make file navigator search bar active in Xcode 7,8,9
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
tell application "Xcode" to activate
if is_running("Xcode") then
tell application "System Events"
tell application "Xcode"
if (count of windows) < 1 then
log "No windows found"
return
end if
set windowFrame to the bounds of the window 1
set yOrigin to item 2 of windowFrame
set height to item 4 of windowFrame
set xOrigin to item 1 of windowFrame
set yClickPosition to (height + yOrigin) - 35
set xClickPosition to (xOrigin + 55)
end tell
try
set searchBar to (click at {xClickPosition, yClickPosition})
if class of searchBar = text field then
set focused of searchBar to true
else
key code 53 # resign first responder if control will block shortcut
keystroke "0" using command down # open file navigator pane
delay 0.25
set focused of (click at {xClickPosition, yClickPosition}) to true
end if
end try
end tell
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment