Skip to content

Instantly share code, notes, and snippets.

@atty303
Last active February 7, 2025 21:58
Show Gist options
  • Save atty303/14c7d4b23bc27d7549d1cd8aa6e5c040 to your computer and use it in GitHub Desktop.
Save atty303/14c7d4b23bc27d7549d1cd8aa6e5c040 to your computer and use it in GitHub Desktop.
キーが単独で押されたときコールバックを実行する
InstallKeybdHook
;;; キーが単独で押されたときコールバックを実行する
StandaloneHotKey(key, callback) {
static enabled := false
down() {
enabled := true
; https://github.com/karakaram/alt-ime-ahk/issues/2
Send("{Blind}{vk07}")
}
up() {
if enabled {
enabled := false
If A_PriorKey = key {
callback()
}
}
}
Hotkey("~" . key, _ => down())
Hotkey(key . " Up", _ => up())
standaloneHook := InputHook("L0V")
standaloneHook.NotifyNonText := true
standaloneHook.OnKeyDown := (hook, vk, sc) => enabled := false
standaloneHook.Start()
}
StandaloneHotKey("LAlt", () => Send("{vk1D}")) ; LAlt単独 -> 無変換
StandaloneHotKey("RAlt", () => Send("{vk1C}")) ; RAlt単独 -> 変換
@atty303
Copy link
Author

atty303 commented Feb 7, 2025

Alt単独を無変換・変換に割り当て、ATOK側で無変換・変換にON/OFFを割り当てている。
Ref: WindowsのATOKで日本語入力のON/OFFを変換/無変換キーに割り当てる

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment