Jump to content

Automation Task - Menubar item in Front App not triggering "Tags..."


Recommended Posts

Trying to trigger File > Tags... for finder via this but it's not working for some reason. I tried using `Tags...` and `Tags…` (ellipsis with ⌥+;)

 

Alfred 5.5 2257

macOS 14.4.1

 

log:

 

```

23:08:49.493] Label Colour Tag[Automation Task] Running task 'Click Menubar Item in Front App' with no arguments
[23:08:49.710] ERROR: Label Colour Tag[Automation Task] Task Error (1): /Users/user/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/Automation Tasks/417bcd70c5bad56358be1184939e45491ef292a7c831177fa5e4123d341a9bed: execution error: Error: Error: Can't get object. (-1728)

```

 

image.thumb.png.d8bfbb8e642f073d717c6aaa8179386d.png

 

 

image.thumb.png.fc7931fbb17433e8a2b84a9c029a1e3b.png

Link to comment

Just an observation: The Menu Bar Search workflow can't find the "Tags..." item either. It looks like you've run into an inconsistency with this particular menu item.  Both the Automation Task and the Menu Bar Search workflow failing to interact with it suggests this simply might be an outlier in its behaviour.

 

Aaand some probing seems to confirm it. Apparently the item doesn't even exist 🥲

 

on run argv
	tell application "System Events"
		set finderProcess to a reference to (first application process whose name is "Finder")
		set fileMenuBar to (a reference to menu 1 of menu bar item "File" of menu bar 1 of finderProcess)
		--set tagsMenuItem to (first menu item of fileMenuBar whose name begins with "Tags") -- no match
		set allMenuItems to menu items of fileMenuBar
		--set probablyTagsMenuItem to item 39 of allMenuItems -- Should be "Tags..." but fails
		--click probablyTagsMenuItem -- no effect
		--return

		set allMenuItemsCount to count of allMenuItems
		repeat with i from 1 to allMenuItemsCount 
			set menuItem to item i of allMenuItems -- Get the menu item at index i
			set theName to name of menuItem as text
			display dialog theName & " - Number: " & (i as text)
		end repeat
	end tell
end run

 

Link to comment

While there is something funky with this menu item (thank you @zeitlings and @Stephen_C for the confirmations), note that the Automation Task is also misconfigured. Apple cares about correct typography, so entries never end in ... (three periods) but with (one ellipsis, ⌥ + . on my keyboard layout).

Link to comment
2 minutes ago, vitor said:

While there is something funky with this menu item

Yes…

2 minutes ago, vitor said:

Apple cares about correct typography, so entries never end in ... (three periods) but with

I tried that and that didn't seem to work either: so I suspect "funky” may be the correct analysis. 😀

 

Stephen

Link to comment
Posted (edited)

Sorry badly phrased…what I meant was approaching tags from a different angle and exploring what Automation Tasks can do with them. I didn't mean searching for tags, as such!

 

Stephen

Edited by Stephen_C
Link to comment

I think nobody can really help unless, instead of picking on isolated problems, you tell us exactly what you're trying to achieve in general terms. Just describe it in plain English without reference to Alfred's functionality and maybe someone will be able to come up with an idea to assist.

 

Stephen

Link to comment
59 minutes ago, andy4222 said:

Being able to add/remove tags on a file

That part is surely relatively straightforward by using a Universal Action (or, indeed, a File Action) linked a relevant Automation Task (List Tags, Add Tags, Clear Tags, Remove Tags, Set Tags—as appropriate).

 

1 hour ago, andy4222 said:

with autocomplete functionality if the tag already was added previously.

I've not had the chance to think that through but it must be possible to create either a text file or even an SQLite database of tags you have used against which a comparison might be run. However, that's obviously the icing on the cake. I can't see any significant problem with the first step above, however.

 

Stephen

Link to comment

This is extremely quick and basic but indicates what can be done at the base level:

CleanShot2024-06-01at09_08.43@2x.thumb.png.f68431893247f00e2b5168514a47d2fc.png

 

Note:

  1. I don't use tags so set something up just to experiment.
  2. The Large Type Outputs are solely to show what has happened. Notifications would be rather more sophisticated.

Stephen

Link to comment

My simple workflow requires slight refinement when removing all tags, as here:

CleanShot2024-06-01at11_24.01@2x.thumb.png.74d5e6de3fccdc5eb0ed1babbb291597.png

 

The Conditional is testing for whether {query} is empty. Of course when all tags are cleared the Large Type Output won't display because there'll be nothing to display.

 

Stephen

Link to comment

Thanks @Stephen_C. I think autocomplete is the important feature here - everything else can be achieved with the Label Colour Tag workflow from the gallery.

 

Like you mentioned, I could dump these tags to a text file and offer them every time in add/remove flows. I'm thinking how can I action on a new item that does not exist in the ones offered by script/list filter.

 

options shown via script filter from text file:

Screenshot_2024-06-01_at_19_29_40.thumb.jpg.86b8b8ab9c1cbbb3b8123adf1b69e426.jpg

 

 

new item that doesn't exist in the filter

 

image.thumb.png.9dc7781d3db119f58d788993130f680b.png

Link to comment
3 hours ago, andy4222 said:

I'm curious how is Hazel (file automation app) getting the list of tags automatically from macOS.


They’re the only ones who can answer that, I encourage you to ask!

 

Hazel runs all the time in the background, so for example they could periodically (or in response to file system events) check tags applied to files and update the database. Or they could be using some feature from macOS which shows that information for free without feeding it back to apps (that interface looks quite similar to a Finder search). Or they could be using a private API. Or they’re using a solution I and the other users who looked at it haven’t found or thought about.

 

Lots of possibilities, all of them speculation, several of them wouldn’t work in this context, none of them can be confirmed except by the source.

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...