Added sendkeys module.

This commit is contained in:
2021-03-14 13:20:22 +01:00
parent e817062f68
commit d67b574969
4 changed files with 63 additions and 1 deletions

32
src/sendkeys.py Normal file
View File

@@ -0,0 +1,32 @@
from pywinauto.application import Application
def send_text(text: str) -> None:
app = Application()
app.connect(title='Path of Exile')
win = app.window_(title_re='Path of Exile')
win.TypeKeys('{ENTER}^A{DELETE}' + text + '{ENTER}', with_spaces=True)
def send_to(user: str, text: str) -> None:
send_text(f'@{user} {text}')
def invite(user: str) -> None:
send_text(f'/invite {user}')
def send_ty(user: str, conf: dict) -> None:
send_to(user, conf['Chat']['ty'])
def send_wait(user: str, conf: dict) -> None:
send_to(user, conf['Chat']['wait'])
def send_pickup(user: str, item: str, amount: int, currency: str, conf: dict) -> None:
text = conf['Chat']['pickup'].replace('{item}', item)
text = text.replace('{amount}', str(amount))
text = text.replace('{currency}', currency)
send_to(user, text)