IMsRdpClientNonScriptable ::的SendKeys [英] IMsRdpClientNonScriptable::SendKeys
问题描述
我想使用IMsRdpClientNonScriptable :: SendKeys函数将键击传输到嵌入在Form中的RDP ActiveX插件。
我正在使用C#,VS2008,.NET 3.5和一个干净的测试项目只包含几个文件。
如本主题所述:
http://social.msdn.microsoft.com/Forums/en-US/netfxcompact/thread/ba56a8f9-e3c2-4cc4-9565-67d6a1c5cb96
生成的IMsRdpCleintNonScriptable界面不正确,但这不是我的主要问题。
我正在试图找出如何发送键组合,如alt + f4,ctrl + alt + end到远程计算机。
第一个问题:
根据MSDN,定义了SendKey功能( http://msdn.microsoft.com/en-us/library/aa381294(VS.85).aspx )像这样:
HRESULT SendKeys(
[in] LONG numKeys ,
[in] VARIANT_BOOL * pbArrayKeyUp ,
[ in] LONG * plKeyData
);
plKeyData根据MSDN与WM_KEYDOWN消息中的lParam相同(但MSDN文章中的WM_KEYDOWN链接已损坏)。
lParam(plKeyData)
$ b指定重复次数,扫描码,扩展 - 键标志,上下文代码,上一个键状态标志和转换状态标志,如下表所示。
0-15
指定当前消息的重复计数。该值是用户按住键时键击自动重复的次数。如果按键保持足够长的时间,则会发送多条消息。但是,重复计数不是累积计数。
$ 16-23
指定扫描码。价值取决于OEM。
$ b指定密钥是否为扩展密钥,例如增强型101键或102键键盘上显示的右侧ALT和CTRL键。如果它是扩展密钥,则值为1;否则,它是0.
25-28
保留;不使用。
$ b指定上下文代码。对于WM_KEYDOWN消息,该值始终为0。
$ b指定先前的键状态。如果在发送消息之前密钥已关闭,则值为1;如果密钥已启动,则该值为零。
$ b指定过渡状态。对于WM_KEYDOWN消息,该值始终为零。
但是通过这个因为plKeyData不起作用!与MSDN声称的扫描码必须放在偏移0(而不是16)相反。所以没有重复计数。
第二个问题:
有时候功能失败了E_FAIL(有同样问题的人:http://stackoverflow.com/questions/1069990/keep-alive-code-fails-with-new-rdp -client )我不知道为什么。
所以我想知道 - 我在哪里可以找到正确的规格功能?
- 为什么SendKey有时会因异常而失败?
- 有没有人知道如何使用IMsRdpClientNonScriptable接口发送键击如alt + f4(Form.SendKeys和keybd_event不可靠)
如果您想知道它们存在的代码段中的空行,因为此站点的编辑功能被严重破坏IE6。
I'd like to use the IMsRdpClientNonScriptable::SendKeys function to transfer keystrokes to an RDP ActiveX plugin embedded in a Form.
I'm using C#, VS2008, .NET 3.5 and a clean test project only containing a few files.
Like in this topic:
http://social.msdn.microsoft.com/Forums/en-US/netfxcompact/thread/ba56a8f9-e3c2-4cc4-9565-67d6a1c5cb96
the generated interface of IMsRdpCleintNonScriptable is not correct, however that's not my main issue.
I'm currently trying to figure out how to send key combinations like alt+f4, ctrl+alt+end to the Remote Computer.
FIRST issue:
According to MSDN the SendKey function is defined (http://msdn.microsoft.com/en-us/library/aa381294(VS.85).aspx) like this:
HRESULT SendKeys(
[in] LONG numKeys,
[in] VARIANT_BOOL *pbArrayKeyUp,
[in] LONG *plKeyData
);
plKeyData is according to MSDN the same as lParam in a WM_KEYDOWN message (link to WM_KEYDOWN in the MSDN article is broken, though).
lParam (plKeyData) Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. 0-15 Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative. 16-23 Specifies the scan code. The value depends on the OEM. 24 Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0. 25-28 Reserved; do not use. 29 Specifies the context code. The value is always 0 for a WM_KEYDOWN message. 30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up. 31 Specifies the transition state. The value is always zero for a WM_KEYDOWN message.
But passing this as plKeyData does NOT work! Contrary to what MSDN claims the scancode has to be put at offset 0 (instead of 16). So there is no repeat count, whatsoever.
SECOND issue:
Also sometimes the function fails with E_FAIL (someone with same problem: http://stackoverflow.com/questions/1069990/keep-alive-code-fails-with-new-rdp-client) and I'm not sure why.
So I'd like to know
- Where can I find a correct spec of the function?
- Why does SendKey sometimes fail with an Exception?
- Does anyone know how to send keystrokes like alt + f4 using the IMsRdpClientNonScriptable Interface (Form.SendKeys and keybd_event aren't reliable)
If you are wondering about the empty lines in the code-sections they exist because the edit function of this site is severly broken on IE6.
这篇关于IMsRdpClientNonScriptable ::的SendKeys的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!