Skip to content

Instantly share code, notes, and snippets.

@fand

fand/config.py

Last active Mar 6, 2020
Embed
What would you like to do?
keyhac config for amagi
import sys
import os
import datetime
import pyauto
from keyhac import *
def configure(keymap):
keymap.editor = "notepad.exe"
keymap.setFont("MS Gothic", 12)
keymap.setTheme("black")
def is_target(window):
print(window.getProcessName())
if window.getProcessName() in ("atom.exe"):
return False
return True
keymap_global = keymap.defineWindowKeymap(check_func=is_target)
# keymap_global = keymap.defineWindowKeymap()
# Cursor
keymap_global[ "C-P" ] = "Up"
keymap_global[ "C-N" ] = "Down"
keymap_global[ "C-F" ] = "Right"
keymap_global[ "C-B" ] = "Left"
keymap_global[ "C-A" ] = "Home"
keymap_global[ "C-E" ] = "End"
keymap_global[ "C-V" ] = "PageDown"
keymap_global[ "A-V" ] = "PageUp"
keymap_global[ "A-Comma" ] = "C-Home"
keymap_global[ "A-Period" ] = "C-End"
keymap_global[ "S-C-P" ] = "S-Up"
keymap_global[ "S-C-N" ] = "S-Down"
keymap_global[ "S-C-F" ] = "S-Right"
keymap_global[ "S-C-B" ] = "S-Left"
keymap_global[ "S-C-A" ] = "S-Home"
keymap_global[ "S-C-E" ] = "S-End"
keymap_global[ "S-C-V" ] = "S-PageDown"
keymap_global[ "S-A-V" ] = "S-PageUp"
keymap_global[ "S-A-Comma" ] = "S-C-Home"
keymap_global[ "S-A-Period" ] = "S-C-End"
# Ctrl bindings
keymap_global[ "C-D" ] = "Delete" # Delete
keymap_global[ "C-H" ] = "Back" # Backspace
keymap_global[ "C-W" ] = "C-X" # Cut
keymap_global[ "C-Y" ] = "C-V" # Paste
keymap_global[ "C-(191)" ] = "C-Z" # Undo
keymap_global[ "C-K" ] = "S-End","C-X" # Removing following text
keymap_global[ "C-J" ] = "Enter"
# Ctrl押しっぱなしになってしまうので、Ctrlをもう一度押して解除する関数
withC = lambda x: (x, "D-Ctrl", "U-Ctrl")
# VSCodeで動かないことがあるので対策
def ifProcessIs(name, thenKeys, elseKeys):
def func():
window = keymap.getWindow()
procname = window.getProcessName()
if procname in (name):
keymap.InputKeyCommand(*thenKeys)()
else:
keymap.InputKeyCommand(*elseKeys)()
return func
withCnotCode = lambda x, y: ifProcessIs("Code.exe", y, withC(x))
# Alt as Command
keymap_global[ "A-C" ] = withC("C-C") # Copy
keymap_global[ "A-V" ] = withC("C-V") # Paste
keymap_global[ "A-T" ] = withCnotCode("C-T", "A-T") # New Tab
keymap_global[ "A-W" ] = withC("C-W") # Close Tab
keymap_global[ "A-L" ] = withC("C-L") # Focus URL bar
keymap_global[ "A-A" ] = withC("C-A") # Select All
keymap_global[ "A-S" ] = withCnotCode("C-S", "A-S") # Save
keymap_global[ "A-K" ] = withC("C-K") # Channels
keymap_global[ "A-N" ] = withC("C-N") # New File
keymap_global[ "A-F" ] = ifProcessIs("Code.exe", ("A-F"), withC("C-F")) # Find
# Tabs
keymap_global[ "A-1" ] = withCnotCode("C-1", "A-1")
keymap_global[ "A-2" ] = withCnotCode("C-2", "A-2")
keymap_global[ "A-3" ] = withCnotCode("C-3", "A-3")
keymap_global[ "A-4" ] = withCnotCode("C-4", "A-4")
keymap_global[ "A-5" ] = withCnotCode("C-5", "A-5")
keymap_global[ "A-6" ] = withCnotCode("C-6", "A-6")
keymap_global[ "A-7" ] = withCnotCode("C-7", "A-7")
keymap_global[ "A-8" ] = withCnotCode("C-8", "A-8")
keymap_global[ "A-9" ] = withCnotCode("C-9", "A-9")
keymap_global[ "A-0" ] = withCnotCode("C-0", "A-0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.