ehrlund Posted March 24, 2013 Share Posted March 24, 2013 Hey, I've been trying to convert this launchbar script into an Alfred Workflow. The script is meant to take the current selection of Alfred, and activate the window behind, open the "Go To Folder" dialogue, paste in the path and press enter. I got it working in the AppleScript Editor, but for some reason I can't get it to perform on through Alfred. It even opens up the "Go To Folder" dialogue but stops there each time. Do you guys have any ideas? on alfred_script(q) set filePath to POSIX file of q 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 set target to a reference to front sheet of target delay 0.5 tell target to keystroke "g" using {command down, shift down} -- Activate goto field tell target try set value of text field 1 to filePath delay 0.5 key code 36 -- simulate pressing the Enter key end try end tell end tell end alfred_script Link to comment
Carlos-Sz Posted March 24, 2013 Share Posted March 24, 2013 1. I think line 3 should be... set filePath to POSIX file q …without the of 2. Can you please give us a link to download and try the workflow? Link to comment
Carlos-Sz Posted March 24, 2013 Share Posted March 24, 2013 (edited) OK. I made a workflow and tested it only with AppleScript Editor. Here is the code that worked: —-The save as dialog uses text as input and UNIX path as far as I can tell set filePath to POSIX path of q as text 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 set target to a reference to front sheet of target delay 0.5 tell target to keystroke "g" using {command down, shift down} -- Activate goto field delay 0.5 tell target set value of text field 1 to filePath delay 0.5 key code 36 -- simulate pressing the Enter key end tell end tell I removed the “try” part of the code to better debug it… Your final code of course may add them back. Finally, you can write AppleScript directly using Language "/usr/bin/osascript”. Edited March 24, 2013 by Carlos-Sz Link to comment
jdfwarrior Posted March 24, 2013 Share Posted March 24, 2013 Thanks for the assistance Carlos Link to comment
ZeroFill Posted June 9, 2013 Share Posted June 9, 2013 (edited) Was anyone able to make a working workflow they could share? I've been scratching my head trying to get the correct combination of events. Just wondering, is it possible to drill down to a location using Alfred's system browser then change the location in the dialog box? Thanks Edited June 9, 2013 by ZeroFill Link to comment
Carlos-Sz Posted June 9, 2013 Share Posted June 9, 2013 Was anyone able to make a working workflow they could share? I've been scratching my head trying to get the correct combination of events. Just wondering, is it possible to drill down to a location using Alfred's system browser then change the location in the dialog box? Thanks I’ve added similar feature but with a different approach in two of my workflows (the first one is also a feature in the second one): Default Folder Recent Finder Items Link to comment
rounak Posted September 5, 2016 Share Posted September 5, 2016 (edited) Was anyone able to make a working workflow they could share? I've been scratching my head trying to get the correct combination of events. Just wondering, is it possible to drill down to a location using Alfred's system browser then change the location in the dialog box? Thanks @Carlos-Sz : Nice work! Good demonstration of many ways with which this can be done with Alfred. @<others> I know its an old thread. But I also came here looking for this and I believe so will others. A simple File Action is what is called for. I possess no special workflow skills, but still, I am posting the solution for those who cannot create this workflow: https://www.dropbox.com/s/55534rd0c5wpxhl/open_save_dialog.alfredworkflow?dl=0 How to use? Bring up any file/folder in Alfred type your shortuct for action Action and run this workflow which is currently named "Send To Open or Save dialog". I personally believe (and I have nothing against what anyone else's approach is): 1. Alfred's File Search is neatly organised. 2. Single quote easily gets me to the folder/file I need to. 3. There is no need to over-complicate things by adding new keywords and then performing actions to get to the item which you could have easily got to by typing single quote in the first place. The more the keywords, the more the complications (naming pattern, length etc) in using them. 4. When 2 shall not remain true, then and only then, create Favorites folder, otherwise you are slowing yourself down instead of doing things quickly. Thanks. Edited September 5, 2016 by rounak deanishe 1 Link to comment
patgilmour Posted May 25, 2017 Share Posted May 25, 2017 On 9/5/2016 at 0:08 AM, rounak said: @Carlos-Sz : Nice work! Good demonstration of many ways with which this can be done with Alfred. @<others> I know its an old thread. But I also came here looking for this and I believe so will others. A simple File Action is what is called for. I possess no special workflow skills, but still, I am posting the solution for those who cannot create this workflow: https://www.dropbox.com/s/55534rd0c5wpxhl/open_save_dialog.alfredworkflow?dl=0 How to use? Bring up any file/folder in Alfred type your shortuct for action Action and run this workflow which is currently named "Send To Open or Save dialog". I personally believe (and I have nothing against what anyone else's approach is): 1. Alfred's File Search is neatly organised. 2. Single quote easily gets me to the folder/file I need to. 3. There is no need to over-complicate things by adding new keywords and then performing actions to get to the item which you could have easily got to by typing single quote in the first place. The more the keywords, the more the complications (naming pattern, length etc) in using them. 4. When 2 shall not remain true, then and only then, create Favorites folder, otherwise you are slowing yourself down instead of doing things quickly. Thanks. Any chance of a fix to the DropBox link? Link to comment
oldflattop Posted July 9, 2018 Share Posted July 9, 2018 (edited) Hello dreamers. For anyone coming here still looking for this, so was I, and I managed to create something which does exactly what I want. Here it is: https://drive.google.com/file/d/1NQyB4u58QWxC8BR-9VgBmy2MEioGuQ2m/view?usp=sharing It has two triggers. Either you search for a file the normal way (pressing space), then action it and pick "Paste path into dialog box" or You start a custom file search using "p", then just press enter when you've found your file/folder and voila. Hope this helps someone! Love Paul makesmefeel.com Edited July 9, 2018 by oldflattop Link to comment
Xiao Posted August 7, 2019 Share Posted August 7, 2019 Thanks oldflattop! My previous 'Go To Here' workflow stops working after Alfred 4 upgrade. This one work great! Link to comment
Floating.Point Posted November 10, 2021 Share Posted November 10, 2021 I'd become pretty reliant on this workflow, but it recently broke when I upgraded to Monterey. So I just hacked together a little macro to replicate the functionality. https://github.com/NeighNeighNeigh/Alfred-paste-path-into-dialog odapg 1 Link to comment
LeeHW Posted February 23, 2022 Share Posted February 23, 2022 This broke for me on Monterey too, but I managed to fix it by swapping out the RunNSAppleScript action for a plain RunScript action, and making very slight tweaks to the script just because the way the query is passed in is very slightly different. At least... I'm not much of a coder, but it seems to be working for me... on run argv set theQuery to item 1 of argv tell application "Finder" to set the clipboard to theQuery as text 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 set target to a reference to front sheet of target delay 0.5 tell target to keystroke "g" using {command down, shift down} -- Activate goto field delay 0.2 tell target delay 0.2 tell application "System Events" to keystroke "v" using {command down} -- simulate pressing the Enter key key code 36 end tell end tell return theQuery end run Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now