Sendkeys.Send() 用于右 alt 键?有什么替代方案吗?
我正在开发一个用于触摸屏显示器的 winform 应用程序。 该应用程序由网络浏览器和屏幕键盘组成。 我已经拥有了我需要的大部分东西,但我面临的问题是 有两种输入语言,英语和韩语。 熟悉使用两种语言的任何人都可以告诉您正确的 alt 键 用于在语言之间来回切换。 我需要模拟这个击键,但我找不到任何东西。
我找到了模拟左/右 shift 键和左/右 ctrl 键的方法。 但左/右 alt 键没有任何作用。
我还有其他选择吗?
I am working on a winform app for a touch screen monitor.
The app consists of a web browser and a on screen keyboard.
I have most everything I need, but the problem I am facing is that
there are two input languages, English and Korean.
Anyone familiar with using two languages can tell you that the right alt key
is used to go back and forth between languages.
I need to simulate this keystroke, but I can't find anything for it.
I have found ways to simulate left/right shift keys, and left/right ctrl keys.
But nothing for left/right alt keys.
Do I have any alternatives?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以将
keybd_event
与RALT
键码VK_RMENU
结合使用。完整的键码列表位于此处,您必须P/Invoke 击键如下:
You can use
keybd_event
withRALT
keycodeVK_RMENU
. A complete list of keycodes are hereYou would have to P/Invoke the keystroke like this:
您无需模拟 Alt+Shift 击键来更改输入语言。您可以在
System.Windows.Forms
命名空间中使用InputLanguage
类:当您恰好安装了 2 种输入语言时,此代码片段会在这两种语言之间切换。你明白了。正确的?
You don't need to simulate Alt+Shift keystrokes for changing input language. You can use
InputLanguage
class inSystem.Windows.Forms
namespace:When you have exactly 2 input languages installed, this code fragments switches between those two. You get the idea. Right?
您并不真的想找到一种发送 Alt 键的方法,对吗?您真正想要的是能够更改输入语言。在这种情况下,请直接前往源头。
Windows API 具有更改当前活动键盘布局的方法。它们不是 .NET Framework 的一部分,但您可以使用 P/Invoke 从 C# 调用它们。
ActivateKeyboardLayout 的 MSDN 文档位于此处。
P/Invoke 签名可以在此处找到。
You don't really want to find a way to send the Alt key, right? What you really want is to be able to change the input language. In that case, go straight to the source.
The Windows API has methods to change the current active keyboard layout. They're not part of the .NET Framework, but you can use P/Invoke to call them from C#.
The MSDN documentation for the ActivateKeyboardLayout is here.
And the P/Invoke signatures can be found here.
MSDN 给出 < code>RMenu 右 alt 的枚举条目。
MSDN gives the
RMenu
enum entry for right-alt.