Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C#代码中模拟移位按压?_C#_Keyboard_Keycode_Shift - Fatal编程技术网

如何在C#代码中模拟移位按压?

如何在C#代码中模拟移位按压?,c#,keyboard,keycode,shift,C#,Keyboard,Keycode,Shift,我用这个代码来模拟按键或按键: [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo); const uint KEYEVENTF_KEYUP = 0x0002; const uint KEYEVENTF_EXTENDEDKEY = 0x0001; //

我用这个代码来模拟按键或按键:

[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
const uint KEYEVENTF_KEYUP = 0x0002;
const uint KEYEVENTF_EXTENDEDKEY = 0x0001;

// Key up
keybd_event((byte)Convert.ToInt32("A0"), 0, KEYEVENTF_KEYUP | 0, 0);

// Key down
keybd_event((byte)Convert.ToInt32("A0"), 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
根据,左换档键代码为A0

由于某种原因,上面的代码不起作用。有人知道为什么吗?非常感谢你的帮助!:)

如果不需要使用,则可以从中使用
键。LShiftKey

进一步利用

keybd_event((byte)0xA0, 0x45, KEYEVENTF_KEYUP | 0, 0); 
这主意不错。

我会用钥匙

 keybd_event(160, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);

你需要学习一些基本的技巧来对付hex。这很好: