C# 模拟PrintScreen 和 Alt+PrintScreen
2011-12-22 15:43
274 查看
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Drawing.Imaging; namespace KeyBoard { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) {//打印全屏 Print.printScreen(); if (Clipboard.ContainsImage()) {//功能提取或替换Windows系统剪贴板的图片 Clipboard.GetImage(); } } private void button2_Click(object sender, EventArgs e) {//打印当前窗口 Print.altPrintScreen(); if (Clipboard.ContainsImage()) {//功能提取或替换Windows系统剪贴板的图片 Clipboard.GetImage(); } } } class Print { //bVk,虚拟键盘码 //bScan ,该键的硬件扫描码 //dwFlags,定义函数操作的各个方面的一个标志位集 //dwExtraInfo,定义与击键相关的附加的32位值 [DllImport("user32.dll")] static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);//该函数合成一次击键事件 const int KEYEVENTF_KEYUP = 0x2;//若指定该值,该键将被释放;若未指定该值,该键将被按下 public static void keydown(Keys k) {//按下 keybd_event((byte)k, 0, 0, UIntPtr.Zero); } public static void keyup(Keys k) {//释放 keybd_event((byte)k, 0, KEYEVENTF_KEYUP, UIntPtr.Zero); } public static void printScreen() {//模拟PrintScreen keydown(Keys.PrintScreen); Application.DoEvents(); keyup(Keys.PrintScreen); Application.DoEvents(); } public static void altPrintScreen() {//模拟Alt+PrintScreen keydown(Keys.Menu); keydown(Keys.PrintScreen); Application.DoEvents(); keyup(Keys.PrintScreen); keyup(Keys.Menu); Application.DoEvents(); } } }
相关文章推荐
- C# 模拟PrintScreen 和 Alt+PrintScreen
- C# 模拟PrintScreen 和 Alt+PrintScreen截取屏幕图片
- C#模拟键盘按键(ALT,CTRL...)
- 如何用Python,C#等语言去实现抓取静态网页+抓取动态网页+模拟登陆网站
- C#模拟web服务器
- C#三种模拟自动登录和提交POST信息的实现方法
- C#模拟http 发送post或get请求
- Eclipse4.4,Alt+/除了sysout能够提示System.out.print()以外,其他所有的都是no default proposals
- C# 第四章 上机练习模拟顾客点餐
- 浅析 C# WinForm程序模拟HTTP Request请求
- C#(DotNET CF 2.0) 模拟WP7的拖拉控件方式
- c# webkit 模拟点击
- C# 按名字引用动态控件,模拟动态语言
- C++ 模拟C#/Java中的检举(enum)类型
- 山东省第四届ACM大学生程序设计竞赛-Contest Print Server(模拟)
- 疯狂的图形(利用C# + GDI plus模拟杂乱无章的现实场景)
- C#模拟键盘事件
- C# 模拟光照运算以及背面剔除
- C# winfrom 模拟ftp文件管理实现代码
- C#模拟POST提交表单--WebClient