aboutsummaryrefslogtreecommitdiffstats
path: root/mouse.lua
diff options
context:
space:
mode:
authorTeddy Wing2019-06-13 21:37:53 +0200
committerTeddy Wing2019-06-15 20:31:22 +0200
commit1d4584b346ffb29ad0ef4b3d2472edadc282b700 (patch)
tree61194df473fcfc724f8a9267bd030c3e8cb88a8c /mouse.lua
parente3bc1d3782f82ff2ed3addf7e0ad3cf08afc1694 (diff)
downloaddothammerspoon-1d4584b346ffb29ad0ef4b3d2472edadc282b700.tar.bz2
Add mouse hotkeys
Proof of concept of shortcuts to move the mouse around.
Diffstat (limited to 'mouse.lua')
-rw-r--r--mouse.lua75
1 files changed, 75 insertions, 0 deletions
diff --git a/mouse.lua b/mouse.lua
new file mode 100644
index 0000000..5a81708
--- /dev/null
+++ b/mouse.lua
@@ -0,0 +1,75 @@
+mouse = {}
+function mouse.bottom_left()
+ local position = hs.mouse.getRelativePosition()
+ position.x = position.x - 100
+ position.y = position.y + 100
+ hs.mouse.setRelativePosition(position)
+end
+
+function mouse.bottom()
+ local position = hs.mouse.getRelativePosition()
+ position.y = position.y + 100
+ hs.mouse.setRelativePosition(position)
+end
+
+function mouse.bottom_right()
+ local position = hs.mouse.getRelativePosition()
+ position.x = position.x + 100
+ position.y = position.y + 100
+ hs.mouse.setRelativePosition(position)
+end
+
+function mouse.left()
+ local position = hs.mouse.getRelativePosition()
+ position.x = position.x - 100
+ hs.mouse.setRelativePosition(position)
+end
+
+function mouse.click()
+ local position = hs.mouse.getAbsolutePosition()
+ hs.eventtap.leftClick(position)
+
+ -- TODO: key down is mouse down, key up is mouse up
+end
+
+function mouse.right()
+ local position = hs.mouse.getRelativePosition()
+ position.x = position.x + 100
+ hs.mouse.setRelativePosition(position)
+end
+
+function mouse.top_left()
+ local position = hs.mouse.getRelativePosition()
+ position.x = position.x - 100
+ position.y = position.y - 100
+ hs.mouse.setRelativePosition(position)
+end
+
+function mouse.top()
+ local position = hs.mouse.getRelativePosition()
+ position.y = position.y - 100
+ hs.mouse.setRelativePosition(position)
+end
+
+function mouse.top_right()
+ local position = hs.mouse.getRelativePosition()
+ position.x = position.x + 100
+ position.y = position.y - 100
+ hs.mouse.setRelativePosition(position)
+end
+
+
+mouse_mode = hs.hotkey.modal.new({'ctrl', 'option', 'shift'}, 'm', 'Mouse')
+mouse_mode:bind({'ctrl', 'option', 'shift'}, 'm', 'Mouse Off', function()
+ mouse_mode:exit()
+end)
+
+mouse_mode:bind({}, 'pad1', mouse.bottom_left, nil, mouse.bottom_left)
+mouse_mode:bind({}, 'pad2', mouse.bottom, nil, mouse.bottom)
+mouse_mode:bind({}, 'pad3', mouse.bottom_right, nil, mouse.bottom_right)
+mouse_mode:bind({}, 'pad4', mouse.left, nil, mouse.left)
+mouse_mode:bind({}, 'pad5', mouse.click)
+mouse_mode:bind({}, 'pad6', mouse.right, nil, mouse.right)
+mouse_mode:bind({}, 'pad7', mouse.top_left, nil, mouse.top_left)
+mouse_mode:bind({}, 'pad8', mouse.top, nil, mouse.top)
+mouse_mode:bind({}, 'pad9', mouse.top_right, nil, mouse.top_right)