Catch the window title not found exception
This commit is contained in:
parent
36589fc68f
commit
990b001730
@ -2,6 +2,7 @@ General:
|
||||
log_file: 'D:\Poe\logs\Client.txt'
|
||||
log_level: 'DEBUG'
|
||||
after_sendkeys_key_wait: 0.001 # Amount of seconds to wait after a keypress. Default is 0.01
|
||||
poe_window_title: 'Path of Exile'
|
||||
Chat:
|
||||
# Define chat messages with the following placeholders:
|
||||
# message, date, channel, user, guild, to_from, item, amount, currency, tab, row, col, league,
|
||||
|
@ -1,13 +1,18 @@
|
||||
|
||||
from pywinauto.application import Application
|
||||
from pywinauto.findwindows import ElementNotFoundError
|
||||
from src import data
|
||||
from src import config
|
||||
|
||||
|
||||
def send_text(text: str) -> None:
|
||||
app = Application()
|
||||
app.connect(title='Path of Exile')
|
||||
win = app.window(title_re='Path of Exile')
|
||||
try:
|
||||
app.connect(title=config.conf['General']['poe_window_title'])
|
||||
except ElementNotFoundError:
|
||||
data.log.warning(f'Title {config.conf["General"]["poe_window_title"]} not found')
|
||||
return
|
||||
win = app.window(title_re=config.conf['General']['poe_window_title'])
|
||||
text = escape_mods(text)
|
||||
win.type_keys('{ENTER}^A{DELETE}' + text + '{ENTER}', with_spaces=True, pause=config.conf['General']['after_sendkeys_key_wait'])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user