'PyWinAuto in exe (PyInstaller) on Citrix can't find window, from python itself works like a charm
I have a pywinauto application that triggers a search in Notepad (for testing purposes).
This works excellent in a regular Windows enviroment. (both running directly from running the python script stand-alone, as from the pywinauto-packed exe).
When I run this in an Citrix environment, pywinauto seems unable to find the windows when running from the pyinstaller-exe. When running directly from python, it does work correctly.
I couldn't find limitation in the pyinstaller documentation, as that states that it works with pywinauto.
(This is using Python 3.10)
This is the error from the .exe
:
Update
Building like this (with splash screen)
pyinstaller.exe --noconfirm --noconsole --paths ./venv/Lib/site packages/ --splash splashscreen.png ./main.py -n notepadopener
Seems to make it fail. Building without splash-screen works fine:
pyinstaller.exe --noconfirm --noconsole --paths ./venv/Lib/site packages/ ./main.py -n notepadopener
Update 2
It seems this piece of code in the main.py
, which should hide the splashscreen, causes it to fail.
# Hide the splash screen after one second
if '_PYIBoot_SPLASH' in os.environ and importlib.util.find_spec("pyi_splash"):
import pyi_splash
sleep(1)
pyi_splash.close()
Update 3
It seems adding a sleep after the .close()
also solves the issues..
# Hide the splash screen after one second
if '_PYIBoot_SPLASH' in os.environ and importlib.util.find_spec("pyi_splash"):
import pyi_splash
sleep(1)
pyi_splash.close()
sleep(0.5)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|