- 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())
- {
- Clipboard.GetImage();
- }
- }
-
- private void button2_Click(object sender, EventArgs e)
- {
- Print.altPrintScreen();
- if (Clipboard.ContainsImage())
- {
- Clipboard.GetImage();
- }
- }
- }
-
- class Print
- {
-
-
-
-
- [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()
- {
- keydown(Keys.PrintScreen);
- Application.DoEvents();
- keyup(Keys.PrintScreen);
- Application.DoEvents();
- }
-
- public static void altPrintScreen()
- {
- keydown(Keys.Menu);
- keydown(Keys.PrintScreen);
- Application.DoEvents();
- keyup(Keys.PrintScreen);
- keyup(Keys.Menu);
- Application.DoEvents();
-
- }
- }
- }