Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hammerspoon alternative #4

Open
Porco-Rosso opened this issue Apr 2, 2023 · 1 comment
Open

Hammerspoon alternative #4

Porco-Rosso opened this issue Apr 2, 2023 · 1 comment

Comments

@Porco-Rosso
Copy link

Hi just want to note that you can do something similar with hammerspoon. It's also not 100% reliable because I couldn't figure out a proper way of using the timer delay function, but this seems to work 90% of the time.

-- Hyper+pageup Opens mission control with spaces visible. 
-- Still buggy, so doesn't work every time.
-- Would appreciate any help on getting sleep timers working.

hs.hotkey.bind({"ctrl", "alt", "cmd"},'pageup', function()
   local mousepoint = hs.mouse.absolutePosition()
   hs.mouse.absolutePosition({x=0,y=0})
   hs.eventtap.event.newKeyEvent('ctrl', true):post()
   hs.eventtap.event.newKeyEvent('up', true):post()
   hs.timer.usleep(30000)
   hs.mouse.absolutePosition({x=mousepoint.x,y=mousepoint.y})
   hs.eventtap.event.newKeyEvent('up', false):post()
   hs.eventtap.event.newKeyEvent('ctrl', false):post()
end)
@briankendall
Copy link
Owner

I actually made some experimental changes to MissionControlFullDesktopBar that added a third method, one that would reposition the mouse cursor, trigger mission control, and then put the cursor back to where it was before. After hours of working at it, though, I couldn't get it to work reliably, at least not without the entire process being agonizingly slow. The trouble was trying to figure out when the system had registered the mouse cursor as having moved, dealing with the fact that sometimes the cursor would not move after being told to, and figuring out how to move it back again taking into account possible movements by the user in the intervening time. I eventually abandoned it because the two methods I already have seem to work reliably enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants