PyKeyboard.tap_key() doesn't work when I disconnect from Remote Desktop

女生的网名这么多〃 提交于 2019-12-08 04:13:36

问题


I have a program that uses PyKeyboard.tap_key() to send keystrokes to another application that I'm automating (the application can't be automated any other way, unfortunately). I run it on a remote Windows computer, which I access through Remote Desktop.

PyKeyboard.tap_key() works well while I'm connected, but if I disconnect from the Remote Desktop session, keystrokes are no longer delivered.

Another question: Is disconnecting the remote session equivalent to "Log off->Switch User"? I assume that the problem is that the user is not logged-in (even though a session is running).


回答1:


It seems that this is not a Python related problem. This happens for SendInput() as well (which is probably the WINAPI function Python uses anyway).

From this MSDN thread:

Applications are not allowed to send input to the desktop when the computer is locked for security reasons. I tested changing the cursor position when RDP was minimized, but in fact, the mouse cursor is not shown when the session is restored after being minimized, and when it is restored, no cursor visible until the mouse is moved back over the visible area, in which case it is displayed then where the user moves it. In fact, even if the RDP window is restored but the mouse on the host machine is not over the window, the mouse cursor in the RDP window will not be visible. So this is probably not possible either. If you are trying to achieve a specific behavior, there may be another way to do this other than moving the mouse with simulated input though.



来源:https://stackoverflow.com/questions/26848714/pykeyboard-tap-key-doesnt-work-when-i-disconnect-from-remote-desktop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!