Skip to content

Instantly share code, notes, and snippets.

@naoko1010hh
Created November 1, 2020 05:15
Show Gist options
  • Save naoko1010hh/77d15c8658a4fadfc7e945da80446e22 to your computer and use it in GitHub Desktop.
Save naoko1010hh/77d15c8658a4fadfc7e945da80446e22 to your computer and use it in GitHub Desktop.
aegigoe.py
import pyxhook
import time
import os, sys
import random
import subprocess
def kbevent(event):
files = os.listdir("./audio/")
r = random
r.seed()
play_no = r.randint(0, len(files)-1)
file = files[play_no]
subprocess.call("cvlc a ./audio/"+file+" --play-and-exit &", shell=True)
hookman = pyxhook.HookManager()
hookman.KeyDown = kbevent
hookman.HookKeyboard()
hookman.start()
running = True
ctrlflag = False
while running:
time.sleep(1)
hookman.cancel()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment