import pywinauto
from pywinauto.application import Application
PATH = 'c:/Users/User/PycharmProjects/InviterChannel/Telegram/Telegram.exe'
app = Application().start(PATH)
app.Telegram.ClickInput(coords=(330, 530)) # This is what the user should not see
Is it possible to hide the window while continuing to click in it?
How to do it?
The task is to hide from the user what the algorithm does (keyboard input, mouse clicks, etc.)
Both .click_input()
and .type_keys()
methods require active window.
There is only workaround for keyboard input that is sometimes possible for minimized window (after app.Telegram.minimize()
):
.send_keys()
and .send_keystrokes()
(the difference may appear for some special keys that may work or may not).app.Telegram.move_window(x=-1000, y=-1000)
would help. The window will have negative coordinates. It will be in focus, but invisible to user. So usual .click_input()
and .type_keys()
should work, but these actions may bother a user. So you'll have to remember mouse cursor (by win32api.GetCursorPos()
) and get it back by win32api.SetCursorPos(...)
quickly. Also need to switch focus back to previous active window.P.S. I'm in doubt moving Telegram window would work, because it's not movable by hands as far as I remember. They made some defense against this probably. :)