I'd like to implement an action that moves emails to the mailbox that Apple Mail suggests (which is usually correct) but presents a floating menu if Apple Mail does not suggest anything. The lack of a suggestion can be determined by looking at the menu (there is a deactivated menu item called "Move to predicted mailbox" under "Message"). Similar patterns (menu items changing names based on the app's status) occur in, e.g., Zoom.
It would be great if there was a way to determine if a menu item exists and if it is activated. That functionality must exist internally (to activate menu items). It could be exposed as an Advanced Condition or a Javascript API function (in which case it could be combined with the "If Java Script Returns True" Condition Action).
Thanks a lot.
I can expose this in Apple Script / Java Script, so you could use it with the "If Java Script Returns True" condition. I'l add it with one of the next versions.
Any updates on this? I have been following the release notes but did not see anything. It may have not been included in the notes.
unfortunately not yet but should be ready soon. I'll post here once it's there
Great, thanks. Holding my breath .
I have added it in 4.458, however I have not tested it much yet.
tell application "BetterTouchTool"
get_menu_item_details "Edit;Redo"
end tell
async function someJavaScriptFunction() {
return await get_menu_item_details("View;Show Live View");
}
=>
{"available": true, "enabled": true, "checked": false}
Looks like it is working -- thanks a lot. Is accessing menu items by pattern or position supposed to work (it does not seem like they do).
that should work, it is using the same logic as the „trigger menubar menu item“ action . I’ll have a look tomorrow!
Hi @Andreas_Hegenberg,
Thanks for implementing this. Functionally, it does exactly what it needs to. Unfortunately, it often takes a really long time (more than ten seconds) to return a result. I have an action that checks if Apple Mail suggests/predicts a folder to move a mail to and, if not, presents a menu to select one. Here is the javascript I use to check if Apple Mail predicts a folder:
async function someJavaScriptFunction() {
try{
let status = await get_menu_item_details("Message;Move to Predicted Mailbox");
let parsed = JSON.parse(status)
return !parsed.available
} catch {
return false
}
}
As this is meant to run interactively, waiting for half a minute for each of these is a no-go. Any ideas?
thanks so much,
Holger
more than 10 seconds is weird. In case something gets blocked inside of BTT the timeout would be 5 seconds.
It could also be Mail taking a long time to respond, but that would also be weird.
Could you maybe post the full example? (or send to andreas@folivora.ai) Then I could try it here.