Page 1 of 1

Sending LB location to "open" dialog box

Posted: Tue Jul 08, 2014 5:42 pm
by sabdal
This seems like a simple question, but I can't figure out how to do it.

1. I have an application open with an active "open" or "save" dialog box.
2. In the older version of launch bar, I could invoke LB and navigate to the folder I wanted to either open or save a file from the preview application (#1 above)
3. Then I'd hit "shift-command-c" and it would paste the location that was active in LB into the dialog box into the GO TO FOLDER of the open app, and I could just hit "enter" to save.
4. Shift-command-c doesn't do anything anymore.

You still can drag-drop from launch bar into the dialog box and it will open that location in the open app dialog...but who wants to use the mouse with LB? not me....

Re: Sending LB location to "open" dialog box

Posted: Tue Jul 08, 2014 6:36 pm
by iRounak
LB help states this:
The Open dialog of Carbon applications (such as Word, Photoshop, Eudora, etc.) unfortunately doesn’t support the forward-slash keyboard shortcut. It only works in Save dialogs. This is a shortcoming of the OS X Carbon frameworks.

It does not work with Carbon apps and I cannot be bothered to check whether a given app is Carbon or Cocoa, I have been using the script since my Quicksilver days:

Code: Select all

on open theFile
   tell application "LaunchBar" to hide
   set filePath to quoted form of (POSIX path of theFile)
   set filePath to text 2 thru -2 of filePath
   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
         tell sheet 1
            try
               set value of text field 1 to filePath
               delay 0.5
               click button "Go"
            on error theError -- Carbon apps don't support setting the field directly, so type out the path.
               keystroke filePath
               delay 1
               keystroke return
            end try
         end tell
      end tell
   end tell
end open


Usage:
When the open/save dialog is opened:
Bring up the desired folder in LB
tab
select the above script
return