Created
December 17, 2016 18:04
-
-
Save derrod/bc7a339a1d80e262102773b94e6d274f to your computer and use it in GitHub Desktop.
obs hotkey thing in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python, yay! | |
import win32api | |
import win32con | |
hotkeys = { | |
'start_stream': 0x7C, # F13 | |
'stop_stream': 0x7D, # F14 | |
'switch_to_break': 0x7E, # F15 | |
'switch_to_ingame': 0x7F, # F16 | |
} | |
def press_hotkey(cmd): | |
key_to_press = hotkeys[cmd] | |
win32api.keybd_event(key_to_press, 0) | |
# Without this delay, obs won't register the hotkey if it's not in focus. | |
win32api.Sleep(50) | |
win32api.keybd_event(key_to_press, 0, win32con.KEYEVENTF_KEYUP) | |
while True: | |
print("Switch to Break scene") | |
press_hotkey('switch_to_break') | |
win32api.Sleep(2000) | |
print("Switch to ingame scene") | |
press_hotkey('switch_to_ingame') | |
win32api.Sleep(2000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment