Last active
November 13, 2021 04:59
-
-
Save selbyk/2df57bb2975f90e31cde098b38e59e5b to your computer and use it in GitHub Desktop.
cta buff macro
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
#!/bin/python | |
# Run with python script_name.py or ./script_name.py if executable | |
# F9 activates buff macro, - toggles whether F9 activates macro or not | |
import time | |
from pynput import keyboard | |
from pynput.mouse import Button, Controller as MouseController | |
from pynput.keyboard import Key, Controller as KeyboardController | |
mouseControl = MouseController() | |
keyboardControl = KeyboardController() | |
buffyToggle = True | |
def toggle_buffy(): | |
global buffyToggle | |
buffyToggle = not buffyToggle | |
print("Buffy toggled " + ("ON" if buffyToggle else "OFF")) | |
def buff_macro(): | |
print("BUFFY") | |
# Weapon swap | |
keyboardControl.press("w") | |
keyboardControl.release("w") | |
time.sleep(0.1) | |
# Holy shield | |
keyboardControl.press(Key.f4) | |
keyboardControl.release(Key.f4) | |
time.sleep(0.2) | |
mouseControl.press(Button.right) | |
mouseControl.release(Button.right) | |
time.sleep(0.4) | |
# Battle Command | |
keyboardControl.press(Key.f5) | |
keyboardControl.release(Key.f5) | |
time.sleep(0.2) | |
mouseControl.press(Button.right) | |
mouseControl.release(Button.right) | |
time.sleep(0.4) | |
# Battle Orders | |
keyboardControl.press(Key.f6) | |
keyboardControl.release(Key.f6) | |
time.sleep(0.2) | |
mouseControl.press(Button.right) | |
mouseControl.release(Button.right) | |
time.sleep(0.5) | |
# Weapon swap | |
keyboardControl.press("w") | |
keyboardControl.release("w") | |
time.sleep(0.1) | |
# Reset main spell | |
keyboardControl.press(Key.f1) | |
keyboardControl.release(Key.f1) | |
def on_press(key): | |
try: | |
# Debug, can comment out | |
print("alphanumeric key {0} pressed".format(key.char)) | |
if key.char == "-": | |
toggle_buffy() | |
except AttributeError: | |
# Debug, can comment out | |
print("special key {0} pressed".format(key)) | |
if key == Key.f9 and buffyToggle: | |
buff_macro() | |
def on_release(key): | |
# Debug, can comment out | |
print("{0} released".format(key)) | |
# if key == keyboard.Key.esc: | |
# # Stop listener | |
# return False | |
if __name__ == "__main__": | |
print("Running") | |
# ...or, in a non-blocking fashion: | |
listener = keyboard.Listener(on_press=on_press, on_release=on_release) | |
listener.start() | |
listener.join() | |
# while True: | |
# time.sleep(3) | |
# keyboardControl.press('1') | |
# keyboardControl.release('1') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment