inputsimulator - Windows Input Simulator
install-Package InputSimulator
示例
例子1:单一按键
public void PressTheSpacebar()
{
InputSimulator.SimulateKeyPress(VirtualKeyCode.SPACE);
}
例子2:按键按下和放开
public void ShoutHello()
{
// Simulate each key stroke
InputSimulator.SimulateKeyDown(VirtualKeyCode.SHIFT);
InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_H);
InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_E);
InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_L);
InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_L);
InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_O);
InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_1);
InputSimulator.SimulateKeyUp(VirtualKeyCode.SHIFT); // Alternatively you can simulate text entry to acheive the same end result
InputSimulator.SimulateTextEntry("HELLO!");
}
例子3:修饰按键 比如CTRL-C
public void SimulateSomeModifiedKeystrokes()
{
// CTRL-C (effectively a copy command in many situations)
InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C); // You can simulate chords with multiple modifiers
// For example CTRL-K-C whic is simulated as
// CTRL-down, K, C, CTRL-up
InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, new [] {VirtualKeyCode.VK_K, VirtualKeyCode.VK_C}); // You can simulate complex chords with multiple modifiers and key presses
// For example CTRL-ALT-SHIFT-ESC-K which is simulated as
// CTRL-down, ALT-down, SHIFT-down, press ESC, press K, SHIFT-up, ALT-up, CTRL-up
InputSimulator.SimulateModifiedKeyStroke(
new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.MENU, VirtualKeyCode.SHIFT },
new[] { VirtualKeyCode.ESCAPE, VirtualKeyCode.VK_K });
}
例子4:模拟文字输入
public void SayHello()
{
InputSimulator.SimulateTextEntry("Say hello!");
}
检测按键的不同状态
public void GetKeyStatus()
{
// Determines if the shift key is currently down
var isShiftKeyDown = InputSimulator.IsKeyDown(VirtualKeyCode.SHIFT); // Determines if the caps lock key is currently in effect (toggled on)
var isCapsLockOn = InputSimulator.IsTogglingKeyInEffect(VirtualKeyCode.CAPITAL);
}
摘自:http://inputsimulator.codeplex.com/
连接:http://wpfkb.codeplex.com/
inputsimulator - Windows Input Simulator的更多相关文章
- 与众不同 windows phone (25) - Input(输入)之捕获 UIElement 之外的触控操作, Silverlight 方式捕获手势操作, XNA 方式捕获手势操作, 多点触控
原文:与众不同 windows phone (25) - Input(输入)之捕获 UIElement 之外的触控操作, Silverlight 方式捕获手势操作, XNA 方式捕获手势操作, 多点触 ...
- 与众不同 windows phone (24) - Input(输入)之软键盘类型, XNA 方式启动软键盘, UIElement 的 Touch 相关事件, 触摸涂鸦
原文:与众不同 windows phone (24) - Input(输入)之软键盘类型, XNA 方式启动软键盘, UIElement 的 Touch 相关事件, 触摸涂鸦 [索引页][源码下载] ...
- 【本人译作推荐】Windows 8应用开发:C#和XAML卷(原名:Building Windows 8 Apps with C# and XAML)
[图书推荐] 译名:Windows 8应用开发:C#和XAML卷 原名:Building Windows 8 Apps with C# and XAML 编辑推荐 国内第一本使用XAML与C#语言 ...
- C# 模拟Windows键盘事件
发送键盘消息 [DllImport("user32.dll", EntryPoint = "keybd_event", SetLastError = true) ...
- 背水一战 Windows 10 (24) - MVVM: 通过 Binding 或 x:Bind 结合 Command 实现,通过非 ButtonBase 触发命令
[源码下载] 背水一战 Windows 10 (24) - MVVM: 通过 Binding 或 x:Bind 结合 Command 实现,通过非 ButtonBase 触发命令 作者:webabcd ...
- 背水一战 Windows 10 (23) - MVVM: 通过 Binding 或 x:Bind 结合 Command 实现,通过 ButtonBase 触发命令
[源码下载] 背水一战 Windows 10 (23) - MVVM: 通过 Binding 或 x:Bind 结合 Command 实现,通过 ButtonBase 触发命令 作者:webabcd ...
- windows phone listbox的点击事件
前台 <ListBox x:Name="> <ListBox.ItemTemplate> <DataTemplate> <Grid Margin=& ...
- 【转】Windows Phone在隔离存储里存取图片文件
一共两个页面,第一个为MainPage.xaml,代码如下: <!--ContentPanel - place additional content here--> <Grid x: ...
- Windows Phone 支持中国移动官方支付
今天在这里与大家分享一个好消息,Windows Phone 官方支付支持中国移动(MO Payment),在此之前无论是 Windows Phone 的用户还是开发者,都知道在Windows Phon ...
随机推荐
- form表单提交 type="submit"
<form action="" method="post" onsubmit="return validte()"> < ...
- Object-C-Foundation-set
无序集合 哈希表 NSSet *colors=[NSSet setWithObjects:@@"yellow",@"red",@"blue" ...
- 在outlook中发邮件判断邮件发送成功的方法
早上给企业发了求职邮件,但是发送的时候,自己发现附件比较大,因为之前比较少使用这个工具来发邮件,所以发送之后没有提醒成功与否,求职心切,内心变得比较紧张. 所以查了查方法,发现了以下解决方案,现备注下 ...
- linux常用命令:telnet 命令
telnet命令通常用来远程登录.telnet程序是基于TELNET协议的远程登录客户端程序.Telnet协议是TCP/IP协议族中的一员,是Internet远程登陆服务的标准协议和主要方式.它为用户 ...
- java多线程----拒绝策略
本章介绍线程池的拒绝策略.内容包括:拒绝策略介绍拒绝策略对比和示例 转载请注明出处:http://www.cnblogs.com/skywang12345/p/3512947.html 拒绝策略介绍 ...
- Ubuntu 16.04下为Android编译OpenCV 3.2.0 Manager
http://johnhany.net/2016/07/build-opencv-manager-for-android-on-ubuntu/ 最近想在Android上尝试一下SIFT和SURF匹配算 ...
- Kali连接不上ssh
1.修改sshd_config文件 vim /etc/ssh/sshd_config 将#PasswordAuthentication yes的注释去掉 将#PermitRootLogin prohi ...
- c++中的字符集与中文
就非西欧字符而言,比如中国以及港澳台,在任何编程语言的开发中都不得不考虑字符集及其表示.在c++中,对于超过1个字节的字符,有两种方式可以表示: 1.多字节表示法:通常用于存储(空间效率考虑). 2. ...
- JSmpeg-用JavaScript编写的视频播放器
使用说明:https://github.com/phoboslab/jsmpeg ffmpeg -i rtmp://abc/ccc/111 -f mpegts -codec:v mpeg1video ...
- 20145118《Java程序设计》 第9周学习总结
20145118 <Java程序设计>第9周学习总结 教材学习内容总结 1.SUN公司定义了一套Java操作数据库的规范(接口)来简化数据库操作,称之为JDBC.开发人员只需要学习jdbc ...