当我与远程桌面断开连接时,PyKeyboard.tap_key() 不起作用 [英] PyKeyboard.tap_key() doesn't work when I disconnect from Remote Desktop

查看:103
本文介绍了当我与远程桌面断开连接时,PyKeyboard.tap_key() 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,它使用 PyKeyboard.tap_key() 将击键发送到我正在自动化的另一个应用程序(不幸的是,该应用程序不能以任何其他方式自动化).我在通过远程桌面访问的远程 Windows 计算机上运行它.

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() 在我连接时运行良好,但如果我与远程桌面会话断开连接,则不再提供击键.

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).

推荐答案

看来这不是 Python 相关的问题.SendInput() 也会发生这种情况(这可能是 Python 无论如何都会使用的 WINAPI 函数).

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).

来自 这个 MSDN 线程:

出于安全原因,当计算机被锁定时,不允许应用程序将输入发送到桌面.我测试了在RDP最小化时更改光标位置,但实际上,会话最小化后恢复时鼠标光标不显示,并且当它恢复时,直到鼠标移回可见区域后才可见光标,在这种情况下,它会显示在用户移动它的位置.事实上,即使RDP窗口恢复了但是宿主机上的鼠标没有在窗口上,RDP窗口中的鼠标光标也不会被看到.所以这也可能是不可能的.如果您正在尝试实现特定行为,除了使用模拟输入移动鼠标之外,可能还有另一种方法可以做到这一点.

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.

这篇关于当我与远程桌面断开连接时,PyKeyboard.tap_key() 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆