Page 1 of 1

[Applescript] Open/Save Dialog

Posted: Mon Oct 26, 2009 11:24 am
by iRounak
I know there is Cmd+Shift+C
Reason for the script:
1. viewtopic.php?f=4&t=3438
2. you don't have to type "/"
3. It is faster in case of Cocoa apps since it places the location instead of typing it like when we use Cmd+Shift+C
3. It will work in Carbon apps also
Credit for the script goes to a Quicksilver user who wrote this first. (I only added two lines to make it work with LB)

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

Re: [Applescript] Open/Save Dialog

Posted: Mon Dec 07, 2009 5:40 am
by dbyler
I'd love for this to work but unfortunately it's just beeping at me when I try to run the script. I don't have time to debug in detail, but it's failing at the System Events section (it retrieves the file path fine). Anyone have a quick fix?

Thanks.

Re: [Applescript] Open/Save Dialog

Posted: Mon Dec 07, 2009 8:13 am
by iRounak

Code: Select all

tell applicaiton LaunchBar to hide

works for some LaunchBar users and does not work for others.
Is your LaunchBar icon visible in the dock? Hide it by going to Preferences>>Advanced