hammerspoon
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[mac]]
init.lua
-- Shift + Spaceでローマ字入力とひらがな入力を切り替え
hs.hotkey.bind({"shift"}, "space",
function()
local currentMethod = hs.keycodes.currentMethod()
--hs.alert.show(currentMethod)
if currentMethod == "Romaji" then
hs.keycodes.setMethod("Hiragana")
else
hs.keycodes.setMethod("Romaji")
end
end
)
-- 特定アプリ以外ではcaps(ctrlに設定)をcmdにする
capsTo = "ctrl"
local function handleGlobalEvent(name, event, app)
--hs.alert.show(name)
if event == hs.application.watcher.activated then
if name == "MacVim" or name == "ターミナル" or n...
capsTo = "ctrl"
else
capsTo = "cmd"
end
end
end
watcher = hs.application.watcher.new(handleGlobalEvent)
watcher:start()
keyboardTracker = hs.eventtap.new({hs.eventtap.event.typ...
--keyboardTracker = hs.eventtap.new({hs.eventtap.event.t...
local flags = e:getFlags()
-- print(flags.ctrl)
if (capsTo == "cmd" and flags.ctrl) then
-- print("set cmd")
local eventType = e:getType(true)
if (eventType == hs.eventtap.event.types.keyDown...
local keyCode = e:getKeyCode()
-- print(keyCode)
-- print("cmd + key")
hs.eventtap.event.newKeyEvent(hs.keycodes.ma...
hs.eventtap.event.newKeyEvent(keyCode,true):...
hs.eventtap.event.newKeyEvent(keyCode,false)...
hs.eventtap.event.newKeyEvent(hs.keycodes.ma...
return true
elseif (eventType == hs.eventtap.event.types.lef...
local pointerPos = hs.mouse.absolutePosition()
-- print("cmd + leftMouse")
hs.eventtap.event.newMouseEvent(hs.eventtap....
hs.eventtap.event.newMouseEvent(hs.eventtap....
return true
end
end
end)
keyboardTracker:start()
終了行:
[[mac]]
init.lua
-- Shift + Spaceでローマ字入力とひらがな入力を切り替え
hs.hotkey.bind({"shift"}, "space",
function()
local currentMethod = hs.keycodes.currentMethod()
--hs.alert.show(currentMethod)
if currentMethod == "Romaji" then
hs.keycodes.setMethod("Hiragana")
else
hs.keycodes.setMethod("Romaji")
end
end
)
-- 特定アプリ以外ではcaps(ctrlに設定)をcmdにする
capsTo = "ctrl"
local function handleGlobalEvent(name, event, app)
--hs.alert.show(name)
if event == hs.application.watcher.activated then
if name == "MacVim" or name == "ターミナル" or n...
capsTo = "ctrl"
else
capsTo = "cmd"
end
end
end
watcher = hs.application.watcher.new(handleGlobalEvent)
watcher:start()
keyboardTracker = hs.eventtap.new({hs.eventtap.event.typ...
--keyboardTracker = hs.eventtap.new({hs.eventtap.event.t...
local flags = e:getFlags()
-- print(flags.ctrl)
if (capsTo == "cmd" and flags.ctrl) then
-- print("set cmd")
local eventType = e:getType(true)
if (eventType == hs.eventtap.event.types.keyDown...
local keyCode = e:getKeyCode()
-- print(keyCode)
-- print("cmd + key")
hs.eventtap.event.newKeyEvent(hs.keycodes.ma...
hs.eventtap.event.newKeyEvent(keyCode,true):...
hs.eventtap.event.newKeyEvent(keyCode,false)...
hs.eventtap.event.newKeyEvent(hs.keycodes.ma...
return true
elseif (eventType == hs.eventtap.event.types.lef...
local pointerPos = hs.mouse.absolutePosition()
-- print("cmd + leftMouse")
hs.eventtap.event.newMouseEvent(hs.eventtap....
hs.eventtap.event.newMouseEvent(hs.eventtap....
return true
end
end
end)
keyboardTracker:start()
ページ名: