Sendkeys.Send() 用于右 alt 键?有什么替代方案吗?

2023-12-04

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.

我还有其他选择吗?


您可以使用keybd_event with RALT关键代码VK_RMENU。完整的键码列表是here

你必须P/Invoke击键如下:

[DllImport("user32.dll", SetLastError = true)] 
static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);  

public const int KEYEVENTF_EXTENDEDKEY = 0x0001; //Key down flag 
public const int KEYEVENTF_KEYUP = 0x0002; //Key up flag 
public const int VK_RMENU = 0xA5;

keybd_event(VK_RMENU, 0, KEYEVENTF_EXTENDEDKEY, 0); 
keybd_event(VK_RMENU, 0, KEYEVENTF_KEYUP, 0); 
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Sendkeys.Send() 用于右 alt 键?有什么替代方案吗? 的相关文章

随机推荐