C # simulate printscreen and ALT + printscreen

Source: Internet
Author: User
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 button#click (Object sender, eventargs e) {// Print full screen print. printscreen (); If (clipboard. containsimage () {// function to extract or replace the clipboard image of the Windows clipboard. getimage () ;}} private void button2_click (Object sender, eventargs e) {// print the current window print. altprintscreen (); If (clipboard. containsimage () {// function to extract or replace the clipboard image of the Windows clipboard. getimage () ;}} class print {// bvk, virtual keyboard code // bscan, hardware scan code for this key // dwflags, define a flag set for each aspect of function operations // dwextrainfo, and define the 32-bit value related to the strike key [dllimport ("user32.dll")] static extern void keybd_event (byte bvk, byte bscan, uint dwflags, uintptr dwextrainfo); // This function combines a key-hitting event const int keyeventf_keyup = 0x2; // if this value is specified, the key will be released. If this value is not specified, the key will be pressed public static void keydown (Keys K) {// press keybd_event (byte) K, 0, 0, uintptr. zero);} public static void keyup (Keys K) {// release keybd_event (byte) K, 0, keyeventf_keyup, uintptr. zero);} public static void printscreen () {// simulate printscreen keydown (keys. printscreen); application. doevents (); keyup (keys. printscreen); application. doevents ();} public static void altprintscreen () {// simulate Alt + printscreen keydown (keys. menu); keydown (keys. printscreen); application. doevents (); keyup (keys. printscreen); keyup (keys. menu); application. doevents ();}}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.