Applescript to insert location in Open/Save dialog box

983 views
Skip to first unread message

Chris Cairns

unread,
Sep 16, 2009, 10:54:14 AM9/16/09
to Blacktree: Quicksilver
This is an old script. Somehow, it has not found a place in the
"Pages" section. So I am posting it along with description. I hope it
works in Snow Leopard.


Insert location in Open/Save dialog box
Description:
Inserts location of file/folder in Quicksilver's first pane to Open/
Save dialog boxes of applications

Where to Save:
[~/Library/Application Support/Quicksilver/Actions]

Usage:
[Instructions on how to use the script]
When you see the open dialog box or the save dialog box, bring the
desired file/folder in Quicksilver's first pane, press tab and run
this script

Code:
[the script code]
http://dl.getdropbox.com/u/872430/open_save.scpt

Rob McBroom

unread,
Sep 16, 2009, 1:47:28 PM9/16/09
to blacktree-...@googlegroups.com
On Sep 16, 2009, at 10:54 AM, Chris Cairns wrote:

> This is an old script. Somehow, it has not found a place in the
> "Pages" section. So I am posting it along with description. I hope it
> works in Snow Leopard.

I'd love to have this, but it doesn't seem to work. It brings up the
dialogue to enter the path, but never enters it or hits "Go". I tried
increasing the delay, but that doesn't seem to be it. Probably
something with the "panel" code, but I don't know enough to fix that.

--
Rob McBroom
<http://www.skurfer.com/>

Chris Cairns

unread,
Sep 16, 2009, 1:51:26 PM9/16/09
to Blacktree: Quicksilver

>
> I'd love to have this, but it doesn't seem to work. It brings up the  
> dialogue to enter the path, but never enters it or hits "Go". I tried  
> increasing the delay, but that doesn't seem to be it. Probably  
> something with the "panel" code, but I don't know enough to fix that.
>
> --
> Rob McBroom
> <http://www.skurfer.com/>
Which OS are you using? Which application did you try to use the
script in?
It works fine in Leopard.

Rob McBroom

unread,
Sep 16, 2009, 3:40:36 PM9/16/09
to blacktree-...@googlegroups.com
On Sep 16, 2009, at 1:51 PM, Chris Cairns wrote:

> Which OS are you using? Which application did you try to use the
> script in?
> It works fine in Leopard.

Sorry. I assume everyone's using the newest stuff all the time. I'm on
10.6.1. I tried it in TextMate and the AppleScript Editor itself.
Seems to be the same result in both Open and Save dialogues.

I'm using Quicksilver β56a7 (3825). I copied and modified the script
to just display the path to make sure it was coming in from QS and it
is there.

More of an FYI. I wasn't suggesting anyone needs to spend time on it
now.

Rob McBroom

unread,
Sep 16, 2009, 3:47:50 PM9/16/09
to blacktree-...@googlegroups.com
I stripped out the references to "sheets". It seems to work now under
Snow Leopard. I tried both Open and Save and tried it in iTunes (a
Carbon app).

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
try
set value of text field 1 to filePath
delay 0.1
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 open

Jon Stovell (a.k.a. Sesquipedalian)

unread,
Sep 17, 2009, 3:47:51 PM9/17/09
to Blacktree: Quicksilver
Can someone running Leopard confirm whether Rob's updated version
still works for them?

Chris Cairns

unread,
Sep 17, 2009, 10:32:14 PM9/17/09
to Blacktree: Quicksilver


On Sep 18, 12:47 am, "Jon Stovell (a.k.a. Sesquipedalian)"
<jonstov...@gmail.com> wrote:
> Can someone running Leopard confirm whether Rob's updated version
> still works for them?
>

No, it won't work. If you want one script, you may have to use

-- (Leopard)
if (system attribute "sysv") = 4183 then
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
....
end if

--- (Snow Leopard, not tested)
if (system attribute "sysv") > 4183 then
.....

Jon Stovell (a.k.a. Sesquipedalian)

unread,
Sep 18, 2009, 12:36:36 PM9/18/09
to Blacktree: Quicksilver
Hmm. In my tests on Snow Leopard, the original version works just fine
in both Carbon and Cocoa apps. I'm going to post the original for now,
pending more information.

Rob, can you please give me step by step instructions on how to
reproduce the bug he encountered?

Rob McBroom

unread,
Sep 18, 2009, 1:12:55 PM9/18/09
to blacktree-...@googlegroups.com
On Sep 18, 2009, at 12:36 PM, Jon Stovell (a.k.a. Sesquipedalian) wrote:

> Rob, can you please give me step by step instructions on how to
> reproduce the bug he encountered?

No surprises I don't think.

* I place the script in ~/Library/Application Support/Quicksilver/
Actions
* Open TextEdit (a new document comes up by default)
* hit ⌘S to Save
* invoke Quicksilver
* navigate to a folder
* ⇥ to the next pane
* choose the open_save action
* hit ↩

All I ever get is the "Go to the folder" prompt, empty. I'll attach a
screenshot, but I don't know how well Google Groups handles that.

Screen shot 2009-09-18 at 12.57.29 PM.png

Chris Cairns

unread,
Sep 18, 2009, 1:22:22 PM9/18/09
to blacktree-...@googlegroups.com
FYI, no problems in Leopard when I followed the above steps. I also
checked the UI elements for TextEdit. Everything's fine.

Chris Cairns

unread,
Sep 18, 2009, 1:29:47 PM9/18/09
to blacktree-...@googlegroups.com
To Rob,

open textedit
press Cmd+S to save
press Cmd+Shift+G

now, open script editor and paste this script

tell application "System Events"
tell process "TextEdit"
tell window 1
tell sheet 1
get UI elements
end tell
end tell
end tell
end tell

I want to see the result of this applescript.

Rob McBroom

unread,
Sep 18, 2009, 4:25:08 PM9/18/09
to blacktree-...@googlegroups.com
On Sep 18, 2009, at 1:29 PM, Chris Cairns wrote:

> I want to see the result of this applescript.
>

I got an error because access for assistive devices wasn't enabled.
After enabling it, I got the result below. You probably won't be
surprised to know that the open_save script also works unmodified now.
So, that was the problem. I usually run with that enabled anyway, just
forgot to re-enable it after installing Snow Leopard.

My modified version also seems to work still. I wonder if a version
that works in both cases is preferable, but maybe it doesn't work on
Leopard?

Result:
{group 1 of sheet 1 of window "Untitled" of application process
"TextEdit" of application "System Events", button "Save" of sheet 1 of
window "Untitled" of application process "TextEdit" of application
"System Events", button "Cancel" of sheet 1 of window "Untitled" of
application process "TextEdit" of application "System Events",
checkbox 1 of sheet 1 of window "Untitled" of application process
"TextEdit" of application "System Events", text field 1 of sheet 1 of
window "Untitled" of application process "TextEdit" of application
"System Events", static text "Save As:" of sheet 1 of window
"Untitled" of application process "TextEdit" of application "System
Events", static text "Where:" of sheet 1 of window "Untitled" of
application process "TextEdit" of application "System Events", pop up
button 1 of sheet 1 of window "Untitled" of application process
"TextEdit" of application "System Events", sheet 1 of sheet 1 of
window "Untitled" of application process "TextEdit" of application
"System Events"}

Jon Stovell (a.k.a. Sesquipedalian)

unread,
Sep 18, 2009, 8:41:26 PM9/18/09
to Blacktree: Quicksilver
> My modified version also seems to work still. I wonder if a version  
> that works in both cases is preferable, but maybe it doesn't work on  
> Leopard?

I think it is probably safer to stick with the original version. The
modified version worked without GUI scripting enabled because it did
not check to see where the keystrokes were being sent, which is not
safe. Try opening TextEdit and then running the modified version
without a save panel open, and you will see what I mean. :)

David Rees

unread,
Apr 10, 2013, 8:43:14 PM4/10/13
to blacktree-...@googlegroups.com, jonst...@gmail.com
I'm trying to get this working with QS 1.0 on 10.8.2. Can someone tell me what am I missing?
Thanks,
dave

using terms from application "Quicksilver"
on get direct types
return {"NSFilenamesPboardType"}
end get direct types
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
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
end using terms from


Jon Stovell

unread,
Apr 10, 2013, 9:20:12 PM4/10/13
to blacktree-...@googlegroups.com
You've got an "on open" handler inside the "using terms from" block. Try changing it to an "on open file" handler, as described on the wiki athttp://qsapp.com/wiki/AppleScript_Actions

David Rees

unread,
Apr 11, 2013, 10:13:32 AM4/11/13
to blacktree-...@googlegroups.com
Sorry, should have listed that I also tried the following for those two lines. Still nothing was happening.

on open files theFiles
set filePath to POSIX path of item 1 of theFiles

Now, both variations are working. Very strange. I think I perhaps forgot to restart Quicksilver to get the new script signature (maybe I tried a Force Rescan instead). I updated http://qsapp.com/wiki/AppleScripts to have the install instructions and to clearer on the need to restart (install instructions had been moved to the authoring page).

I also added the script to wiki at http://qsapp.com/wiki/Select_File_In_Dialog.

d

Lucas Garron

unread,
Apr 11, 2013, 2:27:38 PM4/11/13
to Blacktree Quicksiler Mailing List
One useful thing is to try to remove the delays in the script. This makes it faster, and has never caused problems for me on Mountain Lion.

»Lucas Garron


--
You received this message because you are subscribed to the Google Groups "Quicksilver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blacktree-quicks...@googlegroups.com.
To post to this group, send email to blacktree-...@googlegroups.com.
Visit this group at http://groups.google.com/group/blacktree-quicksilver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

David Rees

unread,
Apr 12, 2013, 11:23:47 AM4/12/13
to blacktree-...@googlegroups.com
Yes, on my 2012 MacBook Pro I switched them to 0.1 I hesitated to take them off on the wiki though, just in case they are needed for some.

d
You received this message because you are subscribed to a topic in the Google Groups "Quicksilver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blacktree-quicksilver/NwYiLiPt3NQ/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to blacktree-quicks...@googlegroups.com.

Lucas Garron

unread,
Apr 18, 2013, 9:42:59 PM4/18/13
to Blacktree Quicksiler Mailing List
If your script is the default action on a folder for the letter "s", you can also press "Cmd-Shift-S" instead of the last three steps. ;-)

(Or if it isn't, you can create a trigger using the "Quicksilver Selection" proxy.)

»Lucas Garron


On Thu, Apr 18, 2013 at 1:03 PM, ar <rmne...@gmail.com> wrote:
Hi,

I'm a little late to this party, but maybe I have something that can help.

If you're using Default Folder X (which I highly recommend) this super simple AppleScript should do the trick:

on open theFolder
    tell application
"Default Folder X Helper"
       
if IsDialogOpen then
           
SwitchToFolder theFolder
       
end if
   
end tell
end open

I've been using this for years and still works perfectly with QS 1.0.0 (4000):
- Open/Save Dialog Box
- Call up QS
- Find your destination folder
- Tab
- Call up this Script
- Enter

I don't remember exactly where I got it from, but I think parts of it are straight from the DF Dev.

a.

David Rees

unread,
Apr 19, 2013, 11:53:08 AM4/19/13
to blacktree-...@googlegroups.com
Thanks for reminding me about that shortcut Igarron!

ar, Default Folder X sounds very cool, but now that I have QS working I'm not sure it adds enough for me over QS's awesome folder/file search.

QS team, I think it would make sense to add this functionality into default QS. Its crazy useful.

d
You received this message because you are subscribed to a topic in the Google Groups "Quicksilver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blacktree-quicksilver/NwYiLiPt3NQ/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to blacktree-quicks...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages