Keyboard shortcut to move cursor among displays on Mac

Use Hammerspoon.
Create a Lua script in ~/.hammerspoon/init.lua if not exist.

I set shortcut as cmd + ` for myself.
Example code:

-- Set hyper to cmd
local cmd = 'cmd'

-- Move Mouse to center of next Monitor
hs.hotkey.bind(cmd, '`', function()
    local screen = hs.mouse.getCurrentScreen()
    local nextScreen = screen:next()
    local rect = nextScreen:fullFrame()
    local center = hs.geometry.rectMidPoint(rect)

    hs.mouse.setAbsolutePosition(center)
end)

I tried CatchMouse before, but I don't want to keep several shortcuts since I'm using three displays.

posted @ 2021-03-14 14:03  Chan7  阅读(40)  评论(0编辑  收藏  举报