Benzi Posted March 17, 2013 Share Posted March 17, 2013 (edited) Try: on recurseMenu(menustuff) tell application "System Events" return menus of menustuff end tell end recurseMenu Also have a look at this code snippet from GitHub/FreeKalter I dont' know why its written that way with a fixed depth, but the comment says "This script uses UI element scripting to return a list of every menuitem of every menu for every application currently running." Edited March 17, 2013 by Benzi Link to comment
Benzi Posted March 17, 2013 Share Posted March 17, 2013 (edited) Also if you have on recurseMenu(menustuff) tell application "System Events" set menuItems to {} repeat with menu_level1 in every menu of menustuff set level2menus to (name of every menu item of menu_level1 whose name is not missing value) set menuItems to menuItems & (name of menu_level1) & {level2menus} end repeat end tell end recurseMenu It will give you output as: { "Level 1 Menu A" , { "A subitem 1", "A subitem 2", "A subitem 3" } , "Level 2 Menu B", { "B subitem 1", "B subitem 2"} ....and so on } Some code wrangling needed to get it truly recursive. (No idea how fast this will be too...) Edited March 17, 2013 by Benzi Link to comment
tsvoronos Posted March 17, 2013 Share Posted March 17, 2013 This is fantastic. I wonder if it's possible to make a similar File Action wherein you select a Service to act on whatever object you want to act on? Link to comment
Florian Posted March 18, 2013 Share Posted March 18, 2013 Hey guys, I haven't looked into it but here's what happened to this workflow for me recently: On VLC, I used to type "menu subtitles" to get to Video > Subtitles Track > Disable but it recently stopped working. Actually even "menu disable" doesn't work to get it either... It's weird because I still get Video > Subtitles Track > Open File... Any idea? Link to comment
Benzi Posted March 18, 2013 Share Posted March 18, 2013 Hey guys, I haven't looked into it but here's what happened to this workflow for me recently: On VLC, I used to type "menu subtitles" to get to Video > Subtitles Track > Disable but it recently stopped working. Actually even "menu disable" doesn't work to get it either... It's weird because I still get Video > Subtitles Track > Open File... Any idea? Hi Florian, This happens because VLC changes its menu contents based on context. When a file is not open, the Video > Subtitles Track menu is disabled. But, it has the Open File... sub menu item internally (though not accessible from the UI physically). Now if you open a video file that has subtitles that VLC can load, the Disable option gets added to Video > Subtitles Track dynamically. The way the original workflow works is that it caches the contents of the menu items only once. So, if you had VLC open at the time the sub menu items were not present, the menu cache will not have those (and the menu cache is used to search for appropriate commands). Since this depends entirely on the state of the application and when exactly the cache gets created, outcome will be different for different users. (I faced similar issues in Chrome, where a menu item renames from Enter Presentation Mode to Exit Presentation Mode). In short, you need to tell the workflow to re-cache the menu entries. The original workflow does not have that option, but I modified it to include an option "m :refresh" to recreate the cache on demand. You can either download my modified version or you can go to you /tmp folder and delete the cache manually, and then try searching for Disable when VLC has that menu item in place (when using the original version). Hope this helps. (PS this problem is more general, and I see this in many other apps apart from VLC and Chrome...) Link to comment
lmartins Posted March 22, 2013 Share Posted March 22, 2013 This is one of those plugins with the power to change the way you use your mac, making you more productive in the process. I loved that in Quicksilver and i got really excited when I saw this plugin for Alfred. But it's not quite usable still, even with Benzi's version the first load is really slow and caching doesn't seem to persist. Do you guys think it will be possible to improve this in the future? Link to comment
ctwise Posted March 22, 2013 Share Posted March 22, 2013 This is one of those plugins with the power to change the way you use your mac, making you more productive in the process. I loved that in Quicksilver and i got really excited when I saw this plugin for Alfred. But it's not quite usable still, even with Benzi's version the first load is really slow and caching doesn't seem to persist. Do you guys think it will be possible to improve this in the future? Probably, but it's going to require Objective-C coding. I've played around with it, but haven't gotten as far as I need to. Link to comment
Tyler Eich Posted March 22, 2013 Share Posted March 22, 2013 This is one of those plugins with the power to change the way you use your mac, making you more productive in the process. I loved that in Quicksilver and i got really excited when I saw this plugin for Alfred. But it's not quite usable still, even with Benzi's version the first load is really slow and caching doesn't seem to persist. Do you guys think it will be possible to improve this in the future? Yes, Objective-C can search the menu bar is much faster than AppleScript. Quicksilver's menu bar search plugin does this; unfortunately, it is tied to Quicksilver's feedback architecture. I've been tinkering with the Quicksilver plugin's source code, but I haven't quite wrapped my head around Objective-C Link to comment
Florian Posted March 22, 2013 Share Posted March 22, 2013 Do you have a link for the source code? I know Objective-C. If I have time I might try and work on that. Link to comment
Tyler Eich Posted March 22, 2013 Share Posted March 22, 2013 Do you have a link for the source code? I know Objective-C. If I have time I might try and work on that. https://github.com/quicksilver/UIAccess-qsplugin Link to comment
loris Posted March 22, 2013 Share Posted March 22, 2013 Hey guys, I know that it feels nice to do everything possible right inside Alfred, but sometimes you have much better way. In your case you should just add a shortcut to the "Show Help Menu" action, you will then just have to type what you want and hit enter. Much faster and reliable than any AppleScript plugin. What it looks like : http://dl.dropbox.com/u/574568/Screenshots/y5Q3.png Link to comment
lmartins Posted March 22, 2013 Share Posted March 22, 2013 Loris, at this point what you suggest is what im doing, but trust with a trigger action can be much faster. It was like that for me with Quicksilver. Tyler Eich 1 Link to comment
ClintonStrong Posted March 22, 2013 Share Posted March 22, 2013 (edited) Hey guys, I know that it feels nice to do everything possible right inside Alfred, but sometimes you have much better way. In your case you should just add a shortcut to the "Show Help Menu" action, you will then just have to type what you want and hit enter. Much faster and reliable than any AppleScript plugin. What it looks like : http://dl.dropbox.com/u/574568/Screenshots/y5Q3.png From my experience, the Help menu doesn't "learn" which menu items you use the most, unlike Alfred. Just another reason I'd like to see this done in Alfred. Edited March 22, 2013 by Clinton Strong Tyler Eich 1 Link to comment
lmartins Posted March 22, 2013 Share Posted March 22, 2013 That's a good point also: From my experience, the Help menu doesn't "learn" which menu items you use the most, unlike Alfred. Just another reason I'd like to see this done in Alfred. Link to comment
donosaur Posted March 31, 2013 Share Posted March 31, 2013 Is there a way to filter out the results from the '' menu? Link to comment
Benzi Posted March 31, 2013 Share Posted March 31, 2013 Is there a way to filter out the results from the '' menu? I modified this to do that. You can try my version here. Link to comment
lmartins Posted March 31, 2013 Share Posted March 31, 2013 Nice. Still too slow to be usable though. Link to comment
tsvoronos Posted April 1, 2013 Share Posted April 1, 2013 Benzi, sorry to badger, but is there a way for me to modify this to *only* show options from the Services menu? I think that this could potentially be quite useful to people (and it's one of the Launchbar features that Alfred lacks). No worries if you're too busy, but if you point me in the right direction I can *try* to make this work myself. Link to comment
Benzi Posted April 1, 2013 Share Posted April 1, 2013 (edited) Benzi, sorry to badger, but is there a way for me to modify this to *only* show options from the Services menu? I think that this could potentially be quite useful to people (and it's one of the Launchbar features that Alfred lacks). No worries if you're too busy, but if you point me in the right direction I can *try* to make this work myself. Hi, something to start with: from what I could figure out, enumerate.scpt generates the menu content list which the Ruby script then parses out and generates a menu structure. If you modify enumerate.scpt to just output the menu contents of the Services menu, it should technically work... Below is a modified version that just outputs the Services menu (not very strong with AppleScript, there might be a better way to do this....) on run argv tell application "System Events" set _app to item 1 of (every process whose frontmost is true) set _app_name to name of _app tell _app set menuExists to menu bar 1 exists if (menuExists) then tell menu bar 1 set _services_item to item 1 of (every menu item of (item 1 of (every menu of item 1 of (item 2 of (every menu bar item)))) whose title is "Services") set _services_stuff to entire contents of _services_item try || of _services_stuff -- Deliberate error. on error stuff -- Get the error message end try return stuff end tell end tell end tell end run Edited April 1, 2013 by Benzi Link to comment
Guest urtlnomis Posted April 16, 2013 Share Posted April 16, 2013 Hi guys, I have a bit of experience with AppleScript and I wanna help. First question, do we have a proper github repo? Seem like everybody is just posting stuff from their dropbox. @ctwise and @Benzi (I guess..)? Link to comment
Benzi Posted April 16, 2013 Share Posted April 16, 2013 Hi guys, I have a bit of experience with AppleScript and I wanna help. First question, do we have a proper github repo? Seem like everybody is just posting stuff from their dropbox. @ctwise and @Benzi (I guess..)? Check out @ctwise's enhanced version that uses ObjC to get the menu contents - its much faster than this version. @ctwise's GitHub repo is here (whole bunch of workflows) Link to comment
Guest urtlnomis Posted April 16, 2013 Share Posted April 16, 2013 Nice, this is awesome, thanks so much! Link to comment
40-02 Posted January 21, 2014 Share Posted January 21, 2014 Great workflow. Is it possible to make it suggest keyboard shortcut for found command? For example I'm typing m new tab in chrome: And it suggests in brackets that shortcut for it is "⌘T" It would be great:) Link to comment
jvdneut Posted January 21, 2014 Author Share Posted January 21, 2014 The "2.0" workflow that I linked to in the first post has been doing just that recently. See: http://www.alfredforum.com/topic/1993-menu-search/page-4 40-02 1 Link to comment
bivalvegruff Posted October 8, 2019 Share Posted October 8, 2019 This broke with Catalina. I'm getting an error message saying that Apple can't verify that it doesn't contain sabotage software and that the developer has to update its "app" (workflow). xilopaint 1 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