catch exception when app not found
This commit is contained in:
parent
745017cd04
commit
a5935e45bb
@ -1,5 +1,5 @@
|
||||
|
||||
from pywinauto.application import Application
|
||||
from pywinauto.application import Application, ProcessNotFoundError
|
||||
from pywinauto.findwindows import ElementNotFoundError
|
||||
from src import data
|
||||
from src import config
|
||||
@ -8,11 +8,15 @@ from src import config
|
||||
def send_text(text: str) -> None:
|
||||
app = Application()
|
||||
try:
|
||||
app.connect(title=config.conf['General']['poe_window_title'], path=config.conf['General']['poe_path'])
|
||||
app.connect(path=config.conf['General']['poe_path'])
|
||||
except ProcessNotFoundError:
|
||||
data.log.warning(f'App "{config.conf["General"]["poe_window_title"]}": "{config.conf["General"]["poe_path"]}" not found')
|
||||
return
|
||||
try:
|
||||
win = app.window(title_re=config.conf['General']['poe_window_title'])
|
||||
except ElementNotFoundError:
|
||||
data.log.warning(f'Window 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