Last active
March 3, 2023 07:25
-
-
Save SuCicada/191227349dc8933f0f3e1a82572405e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local hyperShift = {'alt'} | |
| local screenOriginPosition = {} | |
| function switch_mouse_to_other_screen() | |
| local screen = hs.mouse.getCurrentScreen() | |
| screenOriginPosition[screen:id()] = hs.mouse.absolutePosition() | |
| local nextScreen = screen:next() | |
| local mouseOriginPosition = screenOriginPosition[nextScreen:id()] | |
| local targetPos = nil | |
| if (mouseOriginPosition ~= nil) then | |
| targetPos=mouseOriginPosition | |
| -- hs.mouse.setAbsolutePosition(mouseOriginPosition) | |
| else | |
| local rect = nextScreen:fullFrame() | |
| local center = hs.geometry.rectMidPoint(rect) | |
| targetPos=center | |
| -- hs.mouse.setAbsolutePosition(center) | |
| end | |
| for key, value in pairs(targetPos) do | |
| print(key, value) | |
| end | |
| hs.mouse.absolutePosition(targetPos) | |
| hs.eventtap.leftClick({x=targetPos.x, y=targetPos.y}) | |
| end | |
| hs.hotkey.bind(hyperShift, '`', function() | |
| switch_mouse_to_other_screen() | |
| end) | |
| hs.hotkey.bind({'ctrl','cmd'}, 'f11', function() | |
| local screen = hs.mouse.getCurrentScreen() | |
| print("screen: ", screen:id()) | |
| print(hs.spaces.allSpaces()) | |
| print(hs.spaces.activeSpaces()) | |
| hs.timer.usleep(1000*1000*1) | |
| hs.alert.show("Hello World!") | |
| end) | |
| hs.hotkey.bind({'ctrl','cmd'}, 'f12', function() | |
| -- hs.alert.show("Hello World!") | |
| -- hs.application.launchOrFocus("Mission Control") | |
| -- hs.eventtap.keyStroke(nil, "2") | |
| -- hs.application.launchOrFocus("Finder") | |
| for i = 1, 2 do | |
| local screen = hs.mouse.getCurrentScreen() | |
| local screen_id = screen:id() | |
| print(hs.spaces.allSpaces()) | |
| print(hs.spaces.activeSpaces()) | |
| print("screen: ", screen_id) | |
| if screen_id == 1 then | |
| print("goto space 6 ",hs.spaces.gotoSpace(6)) | |
| elseif screen_id == 3 then | |
| print("goto space 1 ",hs.spaces.gotoSpace(1)) | |
| end | |
| hs.timer.usleep(1000*1000*0.5) | |
| switch_mouse_to_other_screen() | |
| -- hs.application.enableSpotlightForNameSearches(true) | |
| -- print(hs.spaces.spaceDisplay(6)) | |
| end | |
| -- hs.spaces.toggleAppExpose() | |
| -- hs.spaces.toggleLaunchPad() | |
| end) | |
| -- cd ~/.hammerspoon && gist -u 191227349dc8933f0f3e1a82572405e8 init.lua |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment