Jump to content

MenuBar as context menu


Recommended Posts

I have a 4k screen (non retina) and when I have say a small window open at the bottom left hand corner of the monitor, it is a very very long mouse(or trackpad) movement to get to the file minuet the top left of the monitor.  

 

I would like to be able to assign a gesture, for example, double 4 finger tap to showing the menubar menus as a context menu (or not) right where my pointer is.

 

If this is possible already and I have missed it, I apologise.   I had a trial of BetterTouchtool which has this capability, but I love Alfred and don't really want to add another app just for one feature.

 

Thanks

 

Link to comment
Share on other sites

Create a workflow, add your Hotkey of choice, then connect it to a Run Script action with Language = /usr/bin/osascript (JS). Paste this code in the Script box:

 

ObjC.import('CoreGraphics');

function run() {
    let ev = $.CGEventCreateMouseEvent(null, $.kCGEventMouseMoved, {x: 100, y:10}, $.kCGMouseButtonLeft);
    $.CGEventPost($.kCGHIDEventTap, ev);
}

 

That will move your cursor to 100 pixels from the left of the screen and 10 from the top. Should be close to the File menu, but that moves depending on how long the name of the application is.

Link to comment
Share on other sites

If all you want is to show the menubar menus via hotkey, why not use the shortcut in System Preferences → Keyboard → Shortcuts → App Shortcuts → Show Help Menu? That puts you right into Help menu—which is even better because you can start typing what you want—but you can also use the arrow keys to navigate options.

Link to comment
Share on other sites

On 5/25/2021 at 10:48 PM, deanishe said:

Create a workflow, add your Hotkey of choice, then connect it to a Run Script action with Language = /usr/bin/osascript (JS). Paste this code in the Script box:

 


ObjC.import('CoreGraphics');

function run() {
    let ev = $.CGEventCreateMouseEvent(null, $.kCGEventMouseMoved, {x: 100, y:10}, $.kCGMouseButtonLeft);
    $.CGEventPost($.kCGHIDEventTap, ev);
}

 

That will move your cursor to 100 pixels from the left of the screen and 10 from the top. Should be close to the File menu, but that moves depending on how long the name of the application is.

 

Thanks, I'm giving this a try.  Ideally, I'd like to see the App menu as a context menu at the current mouse cursor position as opening the app menu in it's standard location is disruptive to my visual focus of the window I am working in.

Link to comment
Share on other sites

5 minutes ago, apjcs said:

Ideally, I'd like to see the App menu as a context menu at the current mouse cursor position as opening the app menu in it's standard location is disruptive to my visual focus of the window I am working in.

 

Right. Somehow I managed to completely miss the "context menu" part despite it being in your post and the thread title… Sorry.

 

Alfred can't build you an arbitrary context menu. Closest you can get is one of the menu-search workflows.

Link to comment
Share on other sites

Because there have been a couple of app submissions, note the top post:

 

On 5/25/2021 at 8:03 PM, apjcs said:

I had a trial of BetterTouchtool which has this capability, but I love Alfred and don't really want to add another app just for one feature.

 

So the only options are Alfred Workflows or macOS native features.

 

None of those can do the requested feature exactly, only the mentioned approximations.

Link to comment
Share on other sites

On 5/27/2021 at 5:57 PM, deanishe said:

Right. Somehow I managed to completely miss the "context menu" part despite it being in your post and the thread title… Sorry.

Hey @deanishe I see your "I missed 'context menu'" and I raise you to "I missed the whole paragraph about not wanting to use another app" 🤣

 

@vitor has a nice and gentle way of asking "have you even read the post fully?"
Thanks! 😇

Edited by Mr Pennyworth
Link to comment
Share on other sites

4 hours ago, deanishe said:

I use BetterTouchTool just for triple-tap.


I used it exclusively for middle-click (open link in new tab) at first. Somewhere along the way I got the idea of extending that use to pinch in for closing tabs, pinch out for reopening closed tabs, rotate left to switch to the left tab and rotate right for the right tab.

 

Though I get @apjcs‘s desire to not have multiple app’s running. I’m the same and go to great lengths to make Alfred be my one app as much as I can.

Edited by vitor
Link to comment
Share on other sites

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