资源简介
win32_sendinput模拟键盘组合键 代码模块处理,仅供学习使用
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace StrideTechInput
{
public static class CInput
{
[DllImport(“user32.dll“)]
internal static extern uint SendInput(uint nInputs [MarshalAs(UnmanagedType.LPArray) In] INPUT[] pInputs int cbSize);
internal enum INPUT_TYPE : uint
{
INPUT_MOUSE = 0
INPUT_KEYBOARD = 1
INPUT_HARDWARE = 2
}
public static void StrideTechKeyDown(ScanCodeShort ScankeyCode VirtualKeyShort VkeyShort)
{
INPUT down = new INPUT()
{
type = (int)INPUT_TYPE.INPUT_KEYBOARD
ki = new KEYBDINPUT()
{
wScan = ScankeyCode
wVk = VkeyShort
}
};
INPUT[] pInputs = new INPUT[1];
pInputs[0] = down;
System.Threading.Thread.Sleep(100);
var numberOfSuccessfulSimulatedInputs = SendInput((uint)pInputs.Length pInputs Marshal.SizeOf(typeof(INPUT)));
//SendInput(1 inputList Marshal.SizeOf(typeof(INPUT)));
if (numberOfSuccessfulSimulatedInputs == 0) throw new Exception(string.Format(“The key down simulation for {0} was not successful.“ ScankeyCode));
}
public static void StrideTechKeyUp(ScanCodeShort ScankeyCode VirtualKeyShort VkeyShort)
{
INPUT down = new INPUT()
{
type = (int)INPUT_TYPE.INPUT_KEYBOARD
ki = new KEYBDINPUT()
{
wScan = ScankeyCode
wVk = VkeyShort
dwFlags = KEYEVENTF.KEYUP
}
};
INPUT[] pInputs = new INPUT[1];
pInputs[0] = down;
System.Threading.Thread.Sleep(100);
var numberOfSuccessfulSimulatedInputs = SendInput((uint)pInputs.Length pInputs Marshal.SizeOf(typeof(INPUT)));
if (numberOfSuccessfulSimulatedInputs == 0) throw new Exception(string.Format(“The key down simulation for {0} was not successful.“ ScankeyCode));
}
public static void StrideTechKeyPress(ScanCodeShort ScankeyCode VirtualKeyShort VkeyShort)
{
}
///
/// 组合键
///
///
///
///
///
public static void StrideTechModifiedKeyStroke(ScanCodeShort ModifiedScankeyCode VirtualKeyShort ModifiedVkeyShort ScanCodeShort ScankeyCode VirtualKeyShort VkeyShort)
{
StrideTechKeyDown(ModifiedScankeyCode ModifiedV
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 12288 2017-11-15 20:01 StrideTechInput\bin\Debug\StrideTechInput.dll
文件 13824 2017-11-15 20:01 StrideTechInput\bin\Debug\StrideTechInput.pdb
文件 3612 2017-11-15 20:08 StrideTechInput\CInput.cs
文件 5759 2017-11-15 20:01 StrideTechInput\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 432 2017-11-15 20:01 StrideTechInput\obj\Debug\StrideTechInput.csproj.FileListAbsolute.txt
文件 12288 2017-11-15 20:01 StrideTechInput\obj\Debug\StrideTechInput.dll
文件 13824 2017-11-15 20:01 StrideTechInput\obj\Debug\StrideTechInput.pdb
文件 1380 2017-11-15 15:43 StrideTechInput\Properties\AssemblyInfo.cs
文件 2403 2017-11-15 20:01 StrideTechInput\StrideTechInput.csproj
文件 22593 2017-11-15 19:06 StrideTechInput\StructLib.cs
目录 0 2017-11-15 15:43 StrideTechInput\obj\Debug\TempPE
目录 0 2017-11-15 20:01 StrideTechInput\bin\Debug
目录 0 2017-11-15 17:41 StrideTechInput\bin\Release
目录 0 2017-11-15 20:01 StrideTechInput\obj\Debug
目录 0 2017-11-15 17:41 StrideTechInput\bin
目录 0 2017-11-15 15:43 StrideTechInput\obj
目录 0 2017-11-15 15:43 StrideTechInput\Properties
目录 0 2017-11-15 20:00 StrideTechInput
----------- --------- ---------- ----- ----
88403 18
- 上一篇:loading....
- 下一篇:基于STM32和SIM900A的短信发送程序
评论
共有 条评论