3

I try to keep a remote desktop window alive, i.e. to avoid screensaver and closing the connection due to inactivity timeout (I'm not allowed to configure the behaviour of remote desktop session).

Using pywinauto I only realised to connect to the application, but now e.g. app.Click() doesn't work. In the WWW there is no information how to simulate only clicking into the window.

Can anyone help me?

Thanks in advance.

Michael Hecht
  • 2,093
  • 6
  • 25
  • 37

2 Answers2

1

You need to describe the dialog on that you wanna click. There are 2 kinds of click also.

# it sends WM_LBUTTONDOWN and WM_LBUTTONUP messages to the window
app.RemoteDesktopConnection.Click()

# it generates "more natural" click with moving cursor to the window
app.RemoteDesktopConnection.ClickInput()

Clicking on the control in the dialog:

app.Window_(title='Remote Desktop Connection').Edit.ClickInput(double=True)
Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78
  • Hmmm ... I'm totally new to pywinauto. So app.RemoteDesktopConnection.Click() doesn't work, but app[u'the full qualified title of the object'].ClickInput() does the job. The naming conventions at app.SomeName is a total miracle for me. Furthermore, app.RemoteDesktopConnection.Click() does not set the focus to the window. Is this correct? – Michael Hecht Apr 21 '15 at 12:16
  • Yes. But you may set focus by calling `app[u'dlg name'].SetFocus()`. – Vasily Ryabov Apr 21 '15 at 12:19
  • Another convention (if you need exact matching) is `app.Window_(title=u'dialog name')`, because `app.dlg` == `app[u'dlg']` == `app.Window_(best_match=u'dlg')`. This is a power of Python: `__getattr__` method is overridden. – Vasily Ryabov Apr 21 '15 at 12:23
  • Ok, but if there is a space in the name? Then "app.dialog name" is not a valid python syntax. But the other possibilities are sufficient for me, thank you for your assistence. – Michael Hecht Apr 21 '15 at 13:48
  • Yes, there are natural limitations of object attribute access, of course. You're welcome to ask more questions about pywinauto. Any feedback is also useful for me, because I'm preparing next pywinauto release. Do not forget to mark answer as accepted. ;) – Vasily Ryabov Apr 21 '15 at 14:46
  • Hmmm ... I'm not sure wether my problem is solved or not, since even if I apply Click() to all possible objects of the remote desktop window, the remote system locks the screen after a while, i.e. it is not the same as clicking manually into the window. – Michael Hecht Apr 21 '15 at 15:48
  • ClickInput is the same. – Vasily Ryabov Apr 21 '15 at 15:50
  • Ok, even if I now slightly understand how to work with pywinauto, the remote session was closed due to inactivity, i.e. sending ClickInput() to the session was not successful or sufficient. – Michael Hecht Apr 22 '15 at 05:39
  • How many times did you try ClickInput()? I think it should be sent at least twice. Or double click. – Vasily Ryabov Apr 22 '15 at 08:19
  • I took all clickable objects and sent one times ClickInput() to each of them. I can try double click, maybe it helps. Is double click two times ClickInput()? – Michael Hecht Apr 22 '15 at 13:56
  • If you make ClickInput() for several controls, it seems double click shouldn't help. :( – Vasily Ryabov Apr 22 '15 at 14:09
  • Indeed it did not help. Possibly the remote desktop application uses other mechanisms?! Finally I can try to run the application inside the remote desktop session. Maybe this works? I keep you informed. – Michael Hecht Apr 23 '15 at 06:37
  • Probably it should help. Sometimes I run many GUI tests through Remote Desktop (on the remote machine) and it keeps connection until tests passed. – Vasily Ryabov Apr 24 '15 at 08:38
0

Probably there is much simpler solution: https://serverfault.com/questions/250384/how-to-prevent-windows-7-remote-desktop-time-outs

Not sure it's available for you (since you're not an admin on the remote PC). Just another option to try.

Community
  • 1
  • 1
Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78