quicksilver/applescript_open_and_save_selection.txt · Last modified: 2005/11/02 06:22 by 66.114.77.246


About

AppleScript to highlight the current Quicksilver selection in the front app's open or save dialog.

Usage

Save applescript to an Actions folder in QS App Support (~/Library/Application Support/Quicksilver/Actions/).

Relaunch Quicksilver.

When in an open/save dialog, activate, qs, select a file or folder, and use this action.

Known Issues

  • Cannot be used to select applications
  • Cannot be used to select files in a Carbon dialog. Both are bugs in the Open/Save dialog.

Any workarounds would be appreciated.

Requirements

  • Quicksilver
  • UI Scripting must be enabled

Source Code

on open theFile
	set filePath to POSIX path of theFile
	tell application "System Events"
		set theApplication to application processes whose frontmost is true
		set target to item 1 of theApplication
		set target to a reference to front window of target
		tell target to keystroke "g" using {command down, shift down} -- Activate goto field
		delay 0.1
		if ((count target's sheets) > 0) then set target to front sheet of target -- Open panels use a sheet
		tell target
			try
				set value of text field 1 to filePath
				click button "Go"
			on error theError -- Carbon apps don't support setting the field directly, so type out the path.
				keystroke filePath
				keystroke return
			end try
		end tell
	end tell
end open

Credits

Written by Alcor

Disclaimer

This add-on may be freely distributed. It is not guaranteed to work and you use it at your own risk. Post suggestions in the forums.