How to change colors of Finder Tags?
Desired Workflow
The macro should do a menu item click "Ablage->Tags ..." and from there I would go on choose a color...
Question
Hi everyone,
I wanted to create a simple macro to create and change colors of Finder Tags since I often change colors of files depending on the state of the mix-session for example.
I'm able to click "Ablage" but when I want to click "Ablage->Tags ..." I always get a "cant find menu item".
I tried a million ways to spell it. Didn't help. It works with other menu item clicks though. Then I thought to trie it another way by only click item "Ablage" and then do a mouse absolute position click to the colors shown in the menu...wich works as long as the menu stays the same in height:) Wich of course changes for example depending on if you have one or multiple tabs open. So, not an option.. Any suggestions? It cant be that hard..
I saw someone had a PT-Finder-Color Package in the shop, but I`m not able to download it.
Best
Stephan
Command Info
ID: user:ckya9uwbu0003y210p87ohzov:ckyu6kp8a0001qa10a074lmgu
Name: Finder Tag Blue
Source
sf.ui.finder.menuClick({
menuPath: ["Ablage","Tags ..."],
looseMatch: false,
targetValue: "Toggle",
forceClick: false,
});
Links
User UID: FkWDGiXolNSwiDxmwVrCwXWH7dz2
Feedback Key: sffeedback:FkWDGiXolNSwiDxmwVrCwXWH7dz2:-MuG_O6edx7COBk5pzLh
- Christian Scheuer @chrscheuer2022-01-26 10:44:53.160Z
Hi Stephan,
macOS probably uses the single-character ellipsis character for the three dots, so not "...", but "…".
- SStephan Vester @Stephan_Vester
Hi Christian,
thanks for your answer!!
I didnt know about this single-character ellipsis. Learned something:)You are right...for every other menu click in the finder with "…". (For example "Darstellung" "Symbolleiste anpassen …"
But unfortunately it doesn`t work for "Ablage" "Tags …" Weird!
What is different to that menu button?
Any idea!Best
Stephan- SStephan Vester @Stephan_Vester
?
Christian Scheuer @chrscheuer2022-01-26 12:06:13.792Z
Hi Stephan,
I did some digging and it looks like macOS hides the "Tags..." label from that specific menu item. And even if I invoke the menu item directly, it doesn't react like it would if you click it manually :/
Christian Scheuer @chrscheuer2022-01-26 12:12:42.186Z
I got this pretty hacky thing semi-working here - maybe it'll work for you as well
sf.ui.finder.getMenuItem('File').elementClick(); sf.wait({ intervalMs: 200 }); var tagsButton = sf.ui.finder.getMenuItem('File').children.first.children.allItems.find(c => c.children.first.fullRole === 'AXRadioGroup'); var tagsButtonFrame = tagsButton.frame; var oldPos = sf.mouse.getPosition().position; try { sf.mouse.setPosition({ position: { x: tagsButtonFrame.x + 15, y: tagsButtonFrame.y + 34, }, }); sf.mouse.click({ position: { x: tagsButtonFrame.x + 15, y: tagsButtonFrame.y + 34, }, }); sf.wait({ intervalMs: 500 }); } finally { sf.mouse.setPosition({ position: oldPos, }); }
- SStephan Vester @Stephan_Vester
Oh wow,
Fast!thanks again!
I just copied and pasted it...
I dont understand every bit of the code since I´m still with macros:) But it seems you did kind of the same what I tried before by automating a mouseclick. (Right?).. Wich doesn
t always work because the menu changes depending on how many tabs you have open for example..Cheers
StephanChristian Scheuer @chrscheuer2022-01-26 14:16:50.736Z
Yes it uses a mouse click but it bases where it clicks on where the Tags field is located so it should work :)
samuel henriques @samuel_henriques
Not sure if I it helps, I use this apple script.
/** * @param {'unset'|'orange'|'red'|'yellow'|'blue'|'purple'|'green'|'grey'} color */ function setColorAppleScript(color) { sf.system.execAppleScript({ script: ` property unset : 0 property orange : 1 property red : 2 property yellow : 3 property blue : 4 property purple : 5 property green : 6 property grey : 7 tell application "Finder" repeat with f in selection as alias list set label index of f to ${color} end repeat end tell ` }); } setColorAppleScript("orange")
Christian Scheuer @chrscheuer2022-01-26 16:57:21.076Z
Nice!
- SStephan Vester @Stephan_Vester
Hey Christian,
yes of course it works. Sorry, maybe I didnt select a file at one point yesterday..:) Not sure why it didn
t always work. Now it does!And also thanks Samuel!
Do you guys see any way of toggling the color?:) For example a file is marked as red and I want to change it to green.
The best scenario for me would be to have the colors on the deck and then be able to toggle the colors as I would with the mouse.Cheers
Stephan