- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要以编程方式将 RDP 连接到虚拟机 (XP SP3/.NET3.5/VS 2008),(凭据已保存在 .rdp 文件中)并进行 UI 自动化测试。由于我们的域安全性,我需要以编程方式对交互式登录回答“确定”。登录后,我可以访问其他对话窗口和 SendMessages 按钮等,但我无法让我的 SendMessage 在此初始屏幕上工作。我使用 spy++ 来捕获当我按下 enter 时实际发送的内容,当我在运行我的程序时查看 spy++ 日志中的响应时,我似乎能够复制这些消息,但无论我在消息中使用什么变体,都没有任何反应. 我想知道是否有可能以编程方式执行此操作,或者操作系统是否会因安全问题而阻止这种自动化?
当我按下回车键时,我在 spy++ 中看到的消息(在初始屏幕上似乎任何键都可以)我看到:
WM_KEYDOWN nVirtKey:00FF cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:0 Up:0
WM_KEYUP nVirtKey:00FF cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:1 Up:1
当我运行下面的代码并观察发送到 IHWindowClass(下面的 hwnd6)的消息时,我看到我向该窗口生成了上述消息。任何帮助将不胜感激!
以下是代码的相关部分:
'UIntPtr ip = new UIntPtr(0x0D); //ENTER
UIntPtr ip2 = new UIntPtr(0xFF); //00FF
UIntPtr kyDwnlParam = new UIntPtr(0x001);
UIntPtr kyUplParam = new UIntPtr(0xc0000001);
// used UISpy to get these class names...
string lpszParentClass = "TscShellContainerClass";
string lpszParentWindow = "test2 - test2 - Remote Desktop Connection";
string lpszClass2 = "TscShellAxHostClass";
string lpszClass3 = "ATL:2D33D580";
string lpszClass4 = "UIMainClass";
string lpszClass5 = "UIContainerClass";
string lpszClass6 = "IHWindowClass";
hWnd2 = FindWindowEx(ParenthWnd, IntPtr.Zero, lpszClass2, IntPtr.Zero);
hWnd3 = FindWindowEx(hWnd2, IntPtr.Zero, lpszClass3, IntPtr.Zero);
hWnd4 = FindWindowEx(hWnd3, IntPtr.Zero, lpszClass4, IntPtr.Zero);
hWnd5 = FindWindowEx(hWnd4, IntPtr.Zero, lpszClass5, IntPtr.Zero);
hWnd6 = FindWindowEx(hWnd5, IntPtr.Zero, lpszClass6, IntPtr.Zero);
string hexValue = hWnd6.ToString("X"); //Convert to hex to use find in spy++
SetForegroundWindow(hWnd6); // for good measure....
// tried this....
SendMessage(hWnd6, (uint)WindowsUtilities.WindowsMessages.WM_KEYDOWN, ip2, kyDwnlParam);
SendMessage(hWnd6, (uint)WindowsUtilities.WindowsMessages.WM_KEYUP, ip2, kyUplParam);
// tried this....
SendMessage(hWnd6, (uint)WindowsUtilities.WindowsMessages.WM_KEYDOWN, ip, kyDwnlParam);
SendMessage(hWnd6, (uint)WindowsUtilities.WindowsMessages.WM_KEYUP, ip, kyUplParam);
// tried this...
SendMessage(hWnd6, (uint)WindowsUtilities.WindowsMessages.WM_CHAR, ip, UIntPtr.Zero);
SendMessage(hWnd6, (uint)WindowsUtilities.WindowsMessages.WM_CHAR, ip, UIntPtr.Zero);'
最佳答案
您快完成了,您还需要发送一些其他消息以使 RDP session 准备好接受键盘输入。使用 Spy++,您应该看到发送了更多消息。
我能够使用以下代码将字母“a”输入记事本窗口(或者理论上 RDP session 中的事件窗口是什么):
SendMessage(cWind, (int)WM.IME_SETCONTEXT, new UIntPtr(0x00000001), new UIntPtr(0xC000000F));
SendMessage(cWind, (int)WM.IME_NOTIFY, new IntPtr(0x00000002), new IntPtr(0x00000000));
Thread.Sleep(1);
SendMessage(cWind, (int)WM.SETFOCUS, new UIntPtr(0x00203794), new UIntPtr(0x00000000));
Thread.Sleep(1);
//Random keypress
SendMessage(cWind, (int)WM.KEYDOWN, new UIntPtr(0x000000FF), new UIntPtr(0x00000001));
SendMessage(cWind, (int)WM.KEYUP, new UIntPtr(0x00000041), new UIntPtr(0xC0000001));
Thread.Sleep(1);
//A key presses
SendMessage(cWind, (int)WM.KEYDOWN, new IntPtr(0x00000041), new IntPtr(0x001E0001));
SendMessage(cWind, (int)WM.KEYUP, new UIntPtr(0x00000041), new UIntPtr(0xC01E0001));
可能需要也可能不需要 sleep ,但 Spy++ 显示调用返回,所以我在继续之前稍等片刻。您可能还应该“撤消”setfocus/setcontext 操作,但根据我的需要,这很好。 (Spy++ 将揭示细节)
关于c# - 程序化 RDP 登录和 SendMessage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3094789/
我是一名长期开发人员,但对 DNS 的经验并不丰富。这是我的问题: 我们的应用程序在 Amazon EC2 上为客户启动服务器。一个客户希望为每台启动的服务器使用自定义 DNS,而不是 AWS 提供的
我正在尝试以编程方式添加几个从 TextViews 扩展到 RelativeLayout 的 Tiles。 我的代码如下。 RelativeLayout.LayoutParams params = n
如果我在黑莓 (5.0.0) 上的电话应用程序中输入电话号码,我可以点击菜单按钮,其中一个选项是“添加到联系人”,这将显示添加联系人屏幕,电话号码已经人口稠密。我想在我的应用程序中做同样的事情 - 调
我试图将 Android XML 的外观与以编程方式创建它的方式关联起来,但我惨遭失败。我读过几个引用资料,指出 View 的 LayoutParams 类型必须等于父级的类型,但我只是不理解它。 给
我正在尝试创建 Joda 2.2 DateTimeFormatter 来重构我的代码。我试图重现的行为是 private String getSemesterLabel() { StringB
我几乎所有的用户界面都是以编程方式完成的,并在 Interface Builder 中进行了轻微的修改。但是 99% 的 UI 完全是用代码完成的,因为我觉得通过以下方式可以获得一定程度的灵 acti
我正在尝试学习如何以编程方式创建不同的 UI 元素。我的 UITableView 面临以下问题.. 我有 2 个 .swift 文件,一方面,我们有.. struct Settings
我想使用ONLY编程语法创建页面布局,但我无法将带有左、中、右内容 Pane 的边框容器插入到主 Pane 的顶部 Pane 中布局(底部布局也是如此)。 每次我尝试使用内容 Pane 作为父级时,都
我需要一些指示从哪里开始: 从任何使用 ALSA 播放音频的应用程序到连接的扬声器,我想获取样本并进行一些音频处理。我无法控制播放器,我希望能够处理来自任何来源的音频。基本上它将是一个 UV 计,也许
我想以编程方式(因为文件路径是在运行时生成的)为 SQL 语句创建一个单独的日志文件。我的代码看起来像这样 public static void InitializeLogger(FileInfo
如何以编程方式关闭嵌入式 jetty 服务器? 我这样启动 jetty 服务器: Server server = new Server(8090); ... server.start(); serve
我有一个派生自 QGraphicsView 的自定义类,它实现了一个插槽调用 scrollHorizontal(int dx),里面的代码很简单 void CustomView::scrollHo
我正在尝试了解在 ios 中布局 UI 的最佳实践。具体来说,我试图了解以下优点/缺点:纯编程 UI、 Storyboard和 XIB,以及 ios 6.0+ 中的自动布局。 我已经习惯了纯程序化 U
我正在尝试做类似于提出此问题的用户正在尝试做的事情: HTTPS Request From a Credential Provider DLL 关于用户个人资料的组成部分,我找到了this . Win
所以我试图为一些布局约束设置动画,但运气很差,我什么也没看到,然后我收到一条错误消息,说明它如何不能同时满足所有约束等。 我正在使用一个名为 PullableView 的类谁的动画用的是旧风格[UIV
我有大量的 Python 代码,需要对其施加符合 pep8 的样式/格式。 pep8 有各种规则的变体(如 this one by a coworker ),但最难的是处理分割太长的行和格式化修改后的
我试图让 ZeroClipboard API 工作,但看起来 setText() 函数没有效果。 提供简单示例 > here Copy to Clipboard ZeroClipboa
假设我有一个这样的错误应用程序: using System; namespace ConsoleApplication1 { class Program { stati
我是 Android 开发的新手,但遇到以下问题。我正在尝试以编程方式创建多个 ImageView 并使用 Picasso 加载图像,但我无意中发现了以下问题。 编辑:我想要实现的是我希望使用 wid
我需要以编程方式将 RDP 连接到虚拟机 (XP SP3/.NET3.5/VS 2008),(凭据已保存在 .rdp 文件中)并进行 UI 自动化测试。由于我们的域安全性,我需要以编程方式对交互式登录
我是一名优秀的程序员,十分优秀!