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_file: 'D:\Poe\logs\Client.txt'
|
||||||
log_level: 'DEBUG'
|
log_level: 'DEBUG'
|
||||||
after_sendkeys_key_wait: 0.001 # Amount of seconds to wait after a keypress. Default is 0.01
|
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:
|
Chat:
|
||||||
# Define chat messages with the following placeholders:
|
# Define chat messages with the following placeholders:
|
||||||
# message, date, channel, user, guild, to_from, item, amount, currency, tab, row, col, league,
|
# 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.application import Application
|
||||||
|
from pywinauto.findwindows import ElementNotFoundError
|
||||||
from src import data
|
from src import data
|
||||||
from src import config
|
from src import config
|
||||||
|
|
||||||
|
|
||||||
def send_text(text: str) -> None:
|
def send_text(text: str) -> None:
|
||||||
app = Application()
|
app = Application()
|
||||||
app.connect(title='Path of Exile')
|
try:
|
||||||
win = app.window(title_re='Path of Exile')
|
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)
|
text = escape_mods(text)
|
||||||
win.type_keys('{ENTER}^A{DELETE}' + text + '{ENTER}', with_spaces=True, pause=config.conf['General']['after_sendkeys_key_wait'])
|
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