Benzi Posted April 18, 2017 Share Posted April 18, 2017 (edited) I have re-implemented ctwise's excellent implementation of the Menu Search workflow in Swift. This version is ever so slightly faster (at least on my machine ) - YMMV. Requires OSX 10.7+ ↓ Download Refer Github README page for up-to-date information. Usage Type m in Alfred to list menu bar items for front most application You can filter menu items by name, or do a fuzzy search. E.g m new tab will match the menu item New Tab m cw will match the menu item Close Window Setup Note that Accessibility must be enabled for Alfred in order for this to work correctly. For example, in macOS Sierra, this is configured using the Security and Privacy preference pane, under the Privacy tab with the Accessibility section selected. Alfred must be included in the list of apps allowed to control your computer. This step is required for the workflow to generate the list of menu items, and also click on a specific menu item. Here's a snapshot of what the preference pane might look like in macOS Sierra. Edited December 10, 2022 by Benzi Update with latest download links, and repo. xilopaint, zeitlings, bivalvegruff and 11 others 9 5 Link to comment
raguay.customct Posted April 18, 2017 Share Posted April 18, 2017 You need to recompile using static linking. It's requiring a dynalib that I don't have: Code 6: dyld: Library not loaded: @rpath/libswiftAppKit.dylib Referenced from: /Users/raguay/Dropbox (Personal)/Richard/rag/Alfred/Sync/Alfred.alfredpreferences/workflows/user.workflow.85FE278A-FF20-4A2A-919E-8DE7DC7D1C62/./menu Reason: image not found Link to comment
Benzi Posted April 18, 2017 Author Share Posted April 18, 2017 2 hours ago, raguay.customct said: You need to recompile using static linking. It's requiring a dynalib that I don't have: Ah I see. I will update it shortly. Lecter 1 Link to comment
Benzi Posted April 18, 2017 Author Share Posted April 18, 2017 11 hours ago, raguay.customct said: You need to recompile using static linking. It's requiring a dynalib that I don't have: Code 6: dyld: Library not loaded: @rpath/libswiftAppKit.dylib Referenced from: /Users/raguay/Dropbox (Personal)/Richard/rag/Alfred/Sync/Alfred.alfredpreferences/workflows/user.workflow.85FE278A-FF20-4A2A-919E-8DE7DC7D1C62/./menu Reason: image not found I updated the workflow - could you re-download and check if possible? Link to comment
Lecter Posted April 18, 2017 Share Posted April 18, 2017 Great workflow! And I appreciate the rename. By the way, it might be helpful to increment the version number each time you update it. Link to comment
TheDonk Posted April 19, 2017 Share Posted April 19, 2017 Doesn't work on Vivaldi (the browser). Not that the previous one did either. Besides that, it looks good. A very handy idea. Link to comment
raguay.customct Posted April 19, 2017 Share Posted April 19, 2017 Thanks. It is working now. What framework are you using for the automation. I love that it is getting services too! Link to comment
Benzi Posted April 19, 2017 Author Share Posted April 19, 2017 8 hours ago, Lecter said: Great workflow! And I appreciate the rename. By the way, it might be helpful to increment the version number each time you update it. Duly noted. Wil do. Lecter 1 Link to comment
Benzi Posted April 19, 2017 Author Share Posted April 19, 2017 4 hours ago, raguay.customct said: Thanks. It is working now. What framework are you using for the automation. I love that it is getting services too! Nothing out of the ordinary - just the default AX... accessibility stuff from Apple. PS: The code is included in the workflow (also Github); mostly a port of @ctwise's objC code into Swift. Link to comment
raguay.customct Posted April 19, 2017 Share Posted April 19, 2017 Okay. I've been using Scriptarian, but I can't get it to produce stack binaries. Link to comment
Benzi Posted April 20, 2017 Author Share Posted April 20, 2017 v1.1.0 - Added Fuzzy Text Matching for Menus If you have a menu item New Tab, then typing m nt in Alfred will match New Tab, since n and t matches the first letters of the menu text. TheDonk 1 Link to comment
cands Posted April 20, 2017 Share Posted April 20, 2017 This is great, thank you! I think the menu search workflow is one of the most powerful workflows. On my system (macOS 10.12.4, Alfred 3.3.2) your new implementation is quite much faster, and adding the power of fuzzy search makes it even more useful. Link to comment
targumanu Posted April 20, 2017 Share Posted April 20, 2017 Great workflow! Definitely faster than the original one. Thank you! However, to make it even faster, I suggest applying the following Run Behavior settings to the script filter: Queue Mode: Terminate previous script Queue Delay: Immediately after each character typed I also found the icons a bit too dark to my taste and replaced them with the ones attached, if anyone wants them. Benzi 1 Link to comment
Benzi Posted April 20, 2017 Author Share Posted April 20, 2017 v1.2 - Fully native menu clicking, removed AppleScript based solution Well, I removed the AppleScript part of the workflow that automates the actual menu clicking, and replaced it with native code. (This is slightly faster, but not perceptibly so.) Also, @targumanu's suggestion to terminate previous script for the run behaviour is now the default setting. artdev 1 Link to comment
artdev Posted April 21, 2017 Share Posted April 21, 2017 (edited) Thanks! It seems that it works much better than the previous AppleScript-based workflow that I used. It would be nice if you could distribute workflow via packal or github releases, it's easier to track updates ? Edited April 21, 2017 by artdev Link to comment
Nhat Posted April 21, 2017 Share Posted April 21, 2017 Thanks for the excellent workflow. You made it really snappy and a joy to use Link to comment
Benzi Posted April 22, 2017 Author Share Posted April 22, 2017 3 hours ago, nhat said: Thanks for the excellent workflow. You made it really snappy and a joy to use You're welcome. Although you might want to re-download because I've tried to make it even more snappier v1.4 - Caching Menu results are cached for a very short duration, resulting in even faster filtering of menu items. Check it out! cands, xilopaint, dunkaroo and 1 other 4 Link to comment
dunkaroo Posted April 22, 2017 Share Posted April 22, 2017 (edited) @BenziLove your work, but I ran into problem that only some of the menu item is available. Somehow the workflow didn't get all the item. Most noticeable in "Edit" menu. It there a way to troubleshoot? I am on Sierra with workflow version 1.4 for example in "safari", "copy" "paste" doesn't work (in fact non of the app can get "copy", "paste" to show up) Also possible exclude the menu item from the "apple menu icon"? it clutter up the result (not a big deal really) Thanks !! Edited April 22, 2017 by dunkaroo Link to comment
Benzi Posted April 22, 2017 Author Share Posted April 22, 2017 (edited) @dunkaroo That's a bit odd. edit - see my post after this one as well Troubleshooting A - What gets displayed when you type in "m copy" into Alfred? Is it 'No menu items'? B - Can you access Alfred's cache folder? In my case it is /Users/benzi/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.folded-paper.menu-bar-search/ You will need to change that path with your username. In the cache folder, two files will be created for every app once you trigger Menu Search for that app. For example, for TextEdit, it would be: com.apple.TextEdit.items.txt com.apple.TextEdit.txt Can you check if these files get created and if so share me the contents of these two text files? For this step, the Script Filter must have the default settings. C - If you can edit the workflow, change the Script Filter command to the following, one option at a time and see if it makes any difference: # option 1 ./menu -query "{query}" # option 2 ./menu -async -query "{query}" D - Delete all files from your cache folder and try again E - Try downloading the latest version (see below) and see if it makes any difference. Ignoring Apple menu items If you re-download and install v1.4.4, I have included a new option to ignore the Apple menu items. You need to edit your workflow manually include this setting as it is not switched on by default. Open up the Script Filter, and change: ./menu -async -cache 10 -query "{query}" to ./menu -async -cache 10 -no-apple-menu -query "{query}" This should prevent apple menu items from showing up. Edited April 22, 2017 by Benzi Link to comment
Benzi Posted April 22, 2017 Author Share Posted April 22, 2017 (edited) @dunkaroo ALSO You need to have text selected in the app for the Copy to show up / and something pasteable in the clipboard for Paste to appear. This is because the menu search only searches and displays actionable menu items. You cannot copy if nothing is selected. Edited April 22, 2017 by Benzi Link to comment
dunkaroo Posted April 23, 2017 Share Posted April 23, 2017 (edited) @BenziI fix the problem by changing Alfred preference. Back to default "standard mode" being able to fuzzy search on menu item is so freaking awesome, THANK YOU so much !! Edited April 23, 2017 by dunkaroo Benzi 1 Link to comment
cands Posted April 26, 2017 Share Posted April 26, 2017 (edited) I also experienced one case where not all menu items were found, using the app BibDesk. The old menu bar search workflow, as part of the workflow "Key Clue" finds some menu items that are not shown by this new workflow (showing "No menu items"), e.g. the items that are subcommands to the "Copy As" item. Sorry but I did not have time to go through steps B-D outlined above (I have the latest version so step E is done) now, but wanted to quickly inform you about this. Edited April 26, 2017 by cands Link to comment
Benzi Posted April 26, 2017 Author Share Posted April 26, 2017 1 hour ago, cands said: I also experienced one case where not all menu items were found, using the app BibDesk. The old menu bar search workflow, as part of the workflow "Key Clue" finds some menu items that are not shown by this new workflow (showing "No menu items"), e.g. the items that are subcommands to the "Copy As" item. Sorry but I did not have time to go through steps B-D outlined above (I have the latest version so step E is done) now, but wanted to quickly inform you about this. @cands Thanks for reporting this. I have downloaded BibDesk (Version 1.6.10 (4171)) and can reproduce the issue with the Copy As... menu. I'll try to see if I can figure out why this is happening. Link to comment
Benzi Posted April 26, 2017 Author Share Posted April 26, 2017 @cands BibDesk (programatically) reports all menus items under "Copy As..." to be inactive and disabled always. This is the reason why menu search is not able to pick up the sub menu items. One workaround possible to to display all menu items (enabled or not) - but this means that if a menu item is truly disabled, actioning that from Alfred will not have any effect, and you will not be able to know beforehand if the item is indeed disabled or not. The workflow will blindly list all available menu item entries. If you download and update the workflow to version 1.5.4, I have included some environment variables to control the default menu listing. In your case, because of BibDesk, you may want to set the value of "-show-disabled" to true. Note that this will affect all menus across all apps. I'll attempt to come up with a better solution, but not very hopeful at the moment. artdev and cands 2 Link to comment
alwaysaugust Posted April 28, 2017 Share Posted April 28, 2017 Alfred Text Service has Accesibility rights set but I get this when I try to trigger this workflow http://snpy.in/CpVxLW any suggestions? 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