Skip to content

Instantly share code, notes, and snippets.

@alexmaze
Created August 20, 2020 15:17
Show Gist options
  • Save alexmaze/94dea20707b31e4ac00e418461f617ba to your computer and use it in GitHub Desktop.
Save alexmaze/94dea20707b31e4ac00e418461f617ba to your computer and use it in GitHub Desktop.
-- 重新加载配置
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", function()
hs.reload()
end)
hs.alert.show("加载完毕")
-- 窗口横二竖二
hs.hotkey.bind({"cmd", "ctrl"}, "a", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl"}, "s", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 2
f.y = max.y
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl"}, "z", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y + max.h / 2
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl"}, "x", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w / 2
f.y = max.y + max.h / 2
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f)
end)
-- 窗口竖四
hs.hotkey.bind({"cmd", "ctrl"}, "u", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w / 4
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl"}, "i", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.w = max.w / 4
f.h = max.h
f.x = max.x + f.w
f.y = max.y
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl"}, "o", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.w = max.w / 4
f.h = max.h
f.x = max.x + f.w * 2
f.y = max.y
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl"}, "p", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.w = max.w / 4
f.h = max.h
f.x = max.x + f.w * 3
f.y = max.y
win:setFrame(f)
end)
-- 窗口竖三
hs.hotkey.bind({"cmd", "ctrl"}, "m", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w / 3
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl"}, ",", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.w = max.w / 3
f.h = max.h
f.x = max.x + f.w
f.y = max.y
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl"}, ".", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.w = max.w / 3
f.h = max.h
f.x = max.x + f.w * 2
f.y = max.y
win:setFrame(f)
end)
-- 窗口上下左右二分
hs.hotkey.bind({"cmd", "ctrl"}, "h", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w / 2
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl"}, "l", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + (max.w / 2)
f.y = max.y
f.w = max.w / 2
f.h = max.h
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl"}, "k", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w
f.h = max.h / 2
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl"}, "j", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.h / 2
f.w = max.w
f.h = max.h / 2
win:setFrame(f)
end)
-- 窗口全屏
hs.hotkey.bind({"cmd", "ctrl"}, "f", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w
f.h = max.h
win:setFrame(f)
end)
-- 窗口居中
hs.hotkey.bind({"cmd", "ctrl"}, "c", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.w / 8
f.y = max.h / 8
f.w = max.w * 3 / 4
f.h = max.h * 3 / 4
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "ctrl", "shift", "alt"}, "a", function()
hs.alert.show("timer: toggle display")
hs.http.asyncGet("http://timer.qvm-dev.online/api/toggle_client", {}, function()
hs.alert.show("success")
end)
end)
hs.hotkey.bind({"cmd", "ctrl", "shift", "alt"}, "b", function()
hs.alert.show("timer: reset & go")
hs.http.asyncGet("http://timer.qvm-dev.online/api/reset_go", {}, function()
hs.alert.show("success")
end)
end)
hs.hotkey.bind({"cmd", "ctrl", "shift", "alt"}, "c", function()
hs.alert.show("timer: reset")
hs.http.asyncGet("http://timer.qvm-dev.online/api/reset", {}, function()
hs.alert.show("success")
end)
end)
-- hs.hotkey.bind({"cmd", "ctrl", "shift", "alt"}, "1", function()
-- hs.alert.show("核弹已就位")
-- end)
-- hs.hotkey.bind({"cmd", "ctrl", "shift", "alt"}, "2", function()
-- hs.alert.show("发射倒计时 3")
-- hs.timer.doAfter(2, function()
-- hs.alert.show("发射倒计时 2")
-- hs.timer.doAfter(2, function()
-- hs.alert.show("发射倒计时 1")
-- hs.timer.doAfter(2, function()
-- hs.alert.show("目标已摧毁")
-- end)
-- end)
-- end)
-- end)
-- hs.hotkey.bind({"cmd", "ctrl"}, "f", function()
-- local str = hs.pasteboard.readString()
-- local obj = hs.json.decode(str)
-- local fjson = hs.json.encode(obj, true)
-- -- hs.eventtap.keyStrokes(fjson)
-- hs.pasteboard.writeObjects(fjson)
-- hs.alert.show("已格式化JSON到剪切板")
-- end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment