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 ...
随机推荐
- Codeforces 1146E Hot is Cold
题意: 给出一个序列,有两种操作: \(>\;x\) 将大于\(x\)的数全都取负 \(<\;x\) 将小于\(x\)的数全都取负 最后输出序列中的所有数最后的状态 思路: 我们先考虑对于 ...
- hdu5145 莫队算法
这题说的是个了n个数字 然后 在L 和R 区间内的数字的排列有多少种方案, 这里我们通过 将 这n长度的字符串 分成sqrt(n) 块然后 一个属性 他们的l 属于 那个快 以这个为第一关键字 ,然 ...
- HashMap、HashTable、ConcurrentHashMap的区别
一.相关概念 1.Map的概念 javadoc中对Map的解释如下: An objectthat maps keys to values . Amap cannot contain duplicate ...
- Java系列笔记(5) - 线程
我想关注这个系列博客的粉丝们都应该已经发现了,我一定是个懒虫,在这里向大家道歉了.这个系列的博客是在我工作之余写的,经常几天才写一小节,不过本着宁缺毋滥的精神,所有写的东西都是比较精炼的.这篇文章是本 ...
- bzoj1643 / P2666 [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪
[Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪 简单的dfs题 枚举前3个完全平方数,判断最后一个是不是完全平方数,统计合法方案数即可. (zz选手竟把数 ...
- AJAX 与 Python 后台通信
Ajax 简介 Ajax 即“Asynchronous Javascript And XML”(异步 JavaScript 和 XML),是指一种创建交互式网页应用的网页开发技术. Ajax = 异步 ...
- 20145101《Java程序设计》第10周学习总结
20145101<Java程序设计>第10周学习总结 教材学习内容总结 网络编程 网络编程的实质就是两个(或多个)设备(例如计算机)之间的数据传输. 计算机网络 路由器和交换机组成了核心的 ...
- 20145101《Java程序设计》第三周学习总结
20145101 <Java程序设计>第3周学习总结 教材学习内容总结 本周进行的是第四章和第五章的学习.本阶段的学习难度有所提升,无论是在知识的量还是深度都开始增加,内容很丰富,也很有趣 ...
- Springboot2.x 集成redis
pom.xml 添加 <dependency> <groupId>org.springframework.boot</groupId> <artifactId ...
- 用 SwitchHosts设置hotst, 用法示例
涉及到本地默认ip(localhost,127.0.0.1)设置关联地址时,使用XAMPP本地服务器时避免自动跳转设置的域名的一些处理方法 打开此文件,把内容修改如下 # Virtual Hosts# ...