def click(x: int, y: int, button: str = "left") -> None: """Click at pixel xy.""" # No need for checking if special keys are pressed down. # When game is out of focus they are not sent :) button = Inputs.btns[button] Com.set_cur_pos(x + Window.x, y + Window.y) win32gui.SendMessage(Window.id, button.down, button.btn, 0) win32gui.SendMessage(Window.id, button.up, button.btn, 0) time.sleep(userset.SHORT_SLEEP) Com.restore_cur()
def send_string(s): """Send string to game""" for c in str(s): # UnityEngine.UI.InputField vkc = win32api.VkKeyScan(c) win32gui.PostMessage(Window.id, wcon.WM_KEYDOWN, vkc, 0) # UnityEngine.Input.GetKeyDownInt # https://github.com/jamesjlinden/unity-decompiled/blob/master/UnityEngine/UnityEngine/KeyCode.cs # Unity"s keycodes matches with ascii Com.shortcut(ord(c)) time.sleep(userset.SHORT_SLEEP)
def click_drag(x: int, y: int, x2: int, y2: int, button: str = "left") -> None: """Simulate drag event from x, y to x2, y2""" button = Inputs.btns[button] Com.set_cur_pos(x + Window.cx, y + Window.cy) win32gui.SendMessage(Window.id, button.down, button.btn, 0) time.sleep(userset.SHORT_SLEEP) Com.set_cur_pos(x2 + Window.cx, y2 + Window.cy) win32gui.SendMessage(Window.id, wcon.WM_MOUSEMOVE, 0, 0) win32gui.SendMessage(Window.id, button.up, button.btn, 0) time.sleep(userset.SHORT_SLEEP) Com.restore_cur()
def restore_special() -> None: """Restore special button state""" Com.restore_special()
def special(special: str = "leftShift") -> None: """Simulate special button to be down""" # UnityEngine.Input.GetKeyString key = Inputs.specialKeys[special] Com.special(key)
def send_arrow_press(a: str = "left") -> None: """Sends either a left, right, up or down arrow key press""" key = Inputs.Arrow[a] Com.shortcut(key) time.sleep(userset.SHORT_SLEEP)
def restore_cursor() -> None: """Restore cursor position""" Com.restore_cur()
def cursor_position(x: int, y: int) -> None: """Set cursor position to (x, y)""" Com.set_cur_pos(x + Window.cx, y + Window.cy)
def init() -> None: Window.init() Com.init() Com.hook()
def init(printCoords: bool = False) -> None: Window.init() Com.init() Com.hook()
from classes.match import Match from classes.user import User from classes.com import Com from classes.interface import Interface from classes.api_client import ApiClient interface = Interface() match = Match() user = User() com = Com() api_client = ApiClient() def reset(): """Resets wins and rounds""" match.reset_rounds() user.reset_wins() com.reset_wins() def print_default(): """Prints the default play area""" interface.clear_screen() interface.print_banner() def start_new_round(): """Starts a new round and sets input""" match.new_round() interface.print_input_prompt() user.set_play()