Created
June 7, 2022 16:40
-
-
Save manucabral/db33b2036f4f89444b2139f1627d2816 to your computer and use it in GitHub Desktop.
python recorder
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
import win32api as api | |
import win32con as con | |
# recording velocity in seconds | |
VELOCITY = 0.1 | |
# keys definition | |
KEY_F1 = 0x70 | |
KEY_F2 = 0x71 | |
KEY_F3 = 0x72 | |
KEY_F4 = 0x73 | |
KEY_F5 = 0x74 | |
recording = False | |
sequence = [] | |
def key_pressed(key: int) -> bool: | |
return api.GetAsyncKeyState(key) & 0x8000 | |
print(""" | |
Cornelius Alpha Test | |
- Press F1 to start recording. | |
- Press F2 to stop recording. | |
- Press F3 to play back the recorded sequence. | |
- Press F4 to clear the recorded sequence. | |
- Press F5 to exit. | |
Script by: @manucabral | |
""") | |
while True: | |
if key_pressed(KEY_F1) and not recording: | |
print("Recording ...") | |
recording = True | |
elif key_pressed(KEY_F2) and recording: | |
print("Stopping recording ...") | |
recording = False | |
elif key_pressed(KEY_F3): | |
print("Playing back sequence ...") | |
for position in sequence: | |
api.SetCursorPos(position) | |
sleep(VELOCITY) | |
print("Sequence played back.") | |
elif key_pressed(KEY_F4): | |
print("Clearing sequence ...") | |
sequence = [] | |
elif key_pressed(KEY_F5): | |
print("Thank you for using Cornelius Alpha Test!") | |
break | |
if recording: | |
position = api.GetCursorPos() | |
sequence.append(position) | |
sleep(VELOCITY) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment