Jump to content

Go to Here (updated version)


Recommended Posts

Go to Here (updated version)

 

Download here

 

Quickly switch the selected path in a MacOS Open/Save dialog based on an Alfred selection.

 

(This is an updated version of the workflow from this topic, based in part on some very helpful suggestions from the community. Starting a new topic so that the link can be updated here in this first post.)

 

For setup, usage, and credits, see the repo link.

Link to comment

If anyone is using MacOS in a non-English language, I'd like to know if the workflow works or fails. There might need to be edits to some properties in the AppleScript.

 

There may also be issues where the workflow doesn't properly detect Open/Save dialogs. If that happens, or if there are any other issues or suggestions, feel free to let me know.

Link to comment

@paulw do you ever imagine your path not being a folder? I ask because you might consider tweaking your file filter with "public.folder" as your file type.

 

image.thumb.png.af58974ce96eb97b2854497441eb109c.png

 

 

I've also remove the need for an argument so it show recents folders without having to search. Also under the limit and sort I've also made some tweaks there as well. Just an FYI.

Link to comment
7 hours ago, sepulchra said:

do you ever imagine your path not being a folder? I ask because you might consider tweaking your file filter with "public.folder" as your file type.

Could you explain this a bit more? As is, the workflow will accept non-folder items and the Open/Save dialog will point to the parent folder of the item, as far as I can tell.

 

7 hours ago, sepulchra said:

I've also remove the need for an argument so it show recents folders without having to search.

I'm a little stumped on this as well. Removing the checkmark for "with space" doesn't permit me to show recent folders without a search. Explain?

 

7 hours ago, sepulchra said:

Also under the limit and sort I've also made some tweaks there as well.

I'd be interested to know if there are any that you feel everyone would want.

 

Thanks for your input!

Link to comment

I've updated the workflow to detect some edge cases. Now the Applescript uses the button text ("Open" or "Save) to detect Open/Save dialogs. I've also added configuration options in case the button text is different for users with non-English system settings. Link is in the first post (and here).

Link to comment
5 hours ago, paulw said:

Could you explain this a bit more? As is, the workflow will accept non-folder items and the Open/Save dialog will point to the parent folder of the item, as far as I can tell.

 

I understand what you meant now. Yes, sometimes I can think of a file name where I may want to save or open something, but not remember the folder name. Allowing files as a path permits selecting their parent folder.

 

Currently, if a file path is selected in a Save dialog, the file name for the new file is replaced with that of the selected file. I'll update the workflow so that if a file path is selected, the dialog opens the parent folder, and preserves the default new file name.

Link to comment
13 hours ago, paulw said:

Could you explain this a bit more? As is, the workflow will accept non-folder items and the Open/Save dialog will point to the parent folder of the item, as far as I can tell.

 

I didn't realize it functioned that way. In my brain, when I have a save dialog open, I'm always looking for a folder so I just expected that to be the only option.

 

13 hours ago, paulw said:

 

I'm a little stumped on this as well. Removing the checkmark for "with space" doesn't permit me to show recent folders without a search. Explain?

 

If you don't require an argument in a file filter (by unchecking "with space") you don't have to enter a search term. If you hit the space bar it will list items by the parameters setup in limit and sort. This is what mine looks like:

 

image.thumb.png.c0716a737d32fc8578839ad019cd94f2.png

 

If I choose last 3 days -- it shows me recent items. That may be too limiting for some as it does restrict the search. This is definitely something individual users can modify. If you leave it with "Any Date" you can still search the entire search scope. That might be the better way to go.

 

Link to comment
El 6/10/2024 a las 22:23, Paulw dijo:

Si alguien está usando MacOS en un idioma que no sea inglés, me gustaría saber si el flujo de trabajo funciona o falla. Es posible que tenga que haber ediciones en algunas propiedades de AppleScript.

 

También puede haber problemas en los que el flujo de trabajo no detecte correctamente los diálogos de apertura/guardar. Si eso sucede, o si hay algún otro problema o sugerencia, no dude en hacérmelo saber.

I don't know if it's because the system language is Spanish or if I am not using this workflow correctly, but it doesn't work for me. However, I can still use @ahmadt's workflow without any issues. Any suggestions?"

Captura de pantalla 2024-06-14 a las 16.23.44.png

Captura de pantalla 2024-06-14 a las 16.24.00.png

Link to comment
2 hours ago, sepulchra said:

If you don't require an argument in a file filter (by unchecking "with space") you don't have to enter a search term. If you hit the space bar it will list items by the parameters setup in limit and sort. This is what mine looks like:

Oh ok, thank you. I was missing the "hit the space bar" part. When I use that, I see that there are extraneous files that I don't care about, so I see the use of setting input to folders only if you go that route. I think it makes the most sense to do what you suggested—limit File Filter to folders and uncheck "with space". Then if someone wants to select a folder based on a file, they can simply select the file first in Alfred, then use the File Action "Go to Here". 

 

2 hours ago, sepulchra said:

If I choose last 3 days -- it shows me recent items. That may be too limiting for some as it does restrict the search. This is definitely something individual users can modify. If you leave it with "Any Date" you can still search the entire search scope. That might be the better way to go.

I agree. If that only limited the search scope when not entering a specific search term, that might be fine. But limiting the entire search by default I think is to much.

 

Thanks for your feedback!

Link to comment
Posted (edited)
21 minutes ago, 2pilvic said:

I don't know if it's because the system language is Spanish or if I am not using this workflow correctly, but it doesn't work for me. However, I can still use @ahmadt's workflow without any issues. Any suggestions?"

Hey @2pilvic, in the most recent couple of releases, I added configuration options for other languages. If you haven't already, can you make sure you're using the most recent version and then go to "Configure Workflow..." 

 

image.png.092635712aa2296650e3edfa4ad7c56d.png

 

then edit the fields for "Open" and "Save" button text to match your language: "Abrir" (I think?) and "Guardar"—whatever the button text is in your language, without quotation marks.

 

image.thumb.png.0b65a5f3920fb3edbffe09bc0762c1cb.png

 

Please let me know if that works!

Edited by paulw
clarification
Link to comment

Thank you for the precision. I have already adopted the terms to the system language. In TextEdit or Safari, the workflow works correctly; however, in LibreOffice (which I regularly use for editing documents and spreadsheets), it curiously always repeats the previously used address from the workflow in another application. No matter how many times I select other folders, it always repeats the last one that worked. However, in 'Debugger Running,' I see that it writes the requested address without any error, but it still doesn't change it in the window

Link to comment
4 hours ago, paulw said:

Oh ok, thank you. I was missing the "hit the space bar" part. When I use that, I see that there are extraneous files that I don't care about, so I see the use of setting input to folders only if you go that route. I think it makes the most sense to do what you suggested—limit File Filter to folders and uncheck "with space". Then if someone wants to select a folder based on a file, they can simply select the file first in Alfred, then use the File Action "Go to Here". 

@sepulchra On second thought—I'm getting a lot of not-useful folders when using the space bar. As a default for this workflow, I think it would be better to let users select a file or folder in Alfred or using some other workflow and then to use the "Go to Here" file action from there. That would enable much more nuanced filtering based on whatever the other workflow (such as uses.

Link to comment

@2pilvic It turns out that LibreOffice was blocking cmd-V in the "Go to:" dialog. I've changed the workflow, and it should work now.

 

Go to Here v2.3.2:

 

- at least one app (LibreOffice) blocks cmd-V in the "Go to:", so instead of pasting the path, the workflow simulates the delete key and then simulates typing the path.
- there's a config available for changing the simulated typing speed, if needed for your system
- workflow tidied and refactored
- second delay added to prevent glitches in input
- default delay reduced to 250ms

Link to comment
Posted (edited)

Go to Here v2.4.1

 

Important: This release removes the List Filter where you may have stored favorite/default paths for use with the workflow. Be sure to make note of the paths you may have stored there before installing. You can replicate that function and more now that this workflow accepts calls for an External Trigger:

  1. In a separate workflow, add a List Filter, File Filter, or Script Filter. The workflow needs to output a file or folder path.
  2. Add a Call External Trigger Output for outputting the path.
  3. In the settings for that output, click “Workflow Triggers…” and choose the trigger for this workflow.
Edited by paulw
changed to v2.4.1 from v2.4.0 because of minor edit
Link to comment
Hace 11 horas, Paulw dijo:

Ir a aquí v2.4.1

 

Importante: Esta versión elimina el filtro de lista donde puede haber almacenado las rutas favoritas/predeterminadas para su uso con el flujo de trabajo. Asegúrese de tomar nota de las rutas que puede haber almacenado allí antes de instalarlas. Puede replicar esa función y más ahora que este flujo de trabajo acepta llamadas para un activador externo:

  1. En un flujo de trabajo separado, agregue un filtro de lista, un filtro de archivo o un filtro de script. El flujo de trabajo necesita mostrar una ruta de archivo o carpeta.
  2. Añade una salida de disparo externo de llamada para generar la ruta.
  3. En la configuración de esa salida, haga clic en "Activadores de flujo de trabajo..." y elija el activador para este flujo de trabajo.

The workflow now works perfectly, also in LibreOffice. Thank you very much.

Link to comment
  • 3 weeks later...
21 hours ago, yinan said:

Very useful and nice workflow, I used to do a file search and then drag the file into the dialog, now it is even more convenient.

Thanks, glad you find it useful!

Link to comment
Posted (edited)

Thanks for all your work with this @paulw. This seems much more stable than my current solution (which fails enough to put me off using it.)

 

One thing though, when I try running the `gtf` mode, I get no result and the Alfred debug console gives the following output:

 

```

[21:15:23.621] ERROR: Go to Here[Script Filter] Code 1: /Users/nathan/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/A171A74F-24C9-43A4-92B8-0D750069485E:264:269: execution error: Can’t make «class fvtg» of «class brow» id 23238 of application "Finder" into type alias. (-1700)
[21:15:27.634] Go to Here[Script Filter] Queuing argument '(null)'
[21:15:27.807] Go to Here[Script Filter] Script with argv '(null)' finished
[21:15:27.817] ERROR: Go to Here[Script Filter] Code 1: /Users/nathan/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/E761A13B-5BD5-4761-8D05-E673322E4FBE:264:269: execution error: Can’t make «class fvtg» of «class brow» id 23238 of application "Finder" into type alias. (-1700)

```

 

Just thought I should let you know :)

 

I'm using Alfred 5.5 [2257] 

Workflow version v2.4.2 

MacOS 14.5 on M2 Mac Studio

 

 

Edited by Floating.Point
updated the error code
Link to comment

I updated code for gtf script filter to solve above problem.

 

set output to ""

tell application "Finder"
    set windowList to windows
    repeat with i from 1 to count of windowList
        set windowItem to item i of windowList
        try
            set windowName to name of target of windowItem
            set windowPath to POSIX path of (target of windowItem as alias)
            set output to output & "{ \"uid\": \"" & i & "\", \"title\": \"Go to Here:\",\"subtitle\": \"" & windowName & "\", \"arg\": \"" & windowPath & "\" },"
        on error
            -- Handle error (skip this window)
        end try
    end repeat
end tell

if output is not "" then
    set output to text 1 thru -2 of output -- remove the trailing comma
end if

set alfredJSON to "{ \"items\": [" & output & "] }"
return alfredJSON

 

Link to comment

Nice workflow but one issue for "does the app have a dialog window?". This step seems took a lot of time and use experience stuck a little bit

 

[09:33:52.975] Go to Here[Automation Task] Running task 'Identify Front App' with no arguments
[09:33:53.220] Go to Here[Automation Task] Processing complete
[09:33:53.226] Go to Here[Automation Task] Passing output 'Microsoft Outlook' to Run Script
[09:33:56.904] STDERR: Go to Here[Run Script] error
[09:33:56.916] Go to Here[Run Script] Processing complete

Edited by cage.chung
Link to comment

@Floating.Point I hadn't noticed this issue. Can you tell me in what circumstances it happens? Always? For certain Finder windows or selections? @TomBenz thanks for contributing the fix. I'll implement it in a new release. But still curious how/when the issue arises.

 

17 hours ago, cage.chung said:

Nice workflow but one issue for "does the app have a dialog window?". This step seems took a lot of time and use experience stuck a little bit

 

[09:33:52.975] Go to Here[Automation Task] Running task 'Identify Front App' with no arguments
[09:33:53.220] Go to Here[Automation Task] Processing complete
[09:33:53.226] Go to Here[Automation Task] Passing output 'Microsoft Outlook' to Run Script
[09:33:56.904] STDERR: Go to Here[Run Script] error
[09:33:56.916] Go to Here[Run Script] Processing complete

@cage.chung Thanks for your report. Can you provide some details please? Does this delay always happen for you? With certain apps or with any app? Is it affected by how many windows the front app has open?

 

If the front application has many windows, the script will take more time cycling through them to find the first one with an Open/Save dialog, which could take a bit more time. If this is the root of the problem, I'm open to suggestions for adjusting the script to work more quickly.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...