Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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"
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
set searchBar to (click at {xClickPosition, yClickPosition})
if class of searchBar = text field then
set focused of searchBar to true
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