C # software development instance. Customize your own screenshot capture tool (8) to add keyboard operation screenshots

Source: Internet
Author: User

Previous Article: C # software development instance. customized screen tool (7) add magnifiers

Although a magnifier is added, it is not easy to locate the pixel level. It is still difficult to change the location of one or two pixels when you use the mouse.

Handle keyboard press events

////// Handle keyboard press events /// used to implement the following functions: /// exit the process when the user presses the Esc key; // Shift + Enter; /// use the upper, lower, left, and lower keys on the keyboard to adjust the position. /// Shift + upper, lower, and left keys to adjust the area size ;/////////Private void Form1_KeyDown (object sender, KeyEventArgs e) {if (e. keyCode = Keys. escape) {ExitCutImage (true); // if this sentence is not added, the hot key can only be used once after the window is hidden, and then does not work. // RegisterHotKey (Handle, 100, 2 | 1, Keys. A);} if (e. Shift & e. KeyCode = Keys. Enter) {if (! This. lbl_CutImage.Visible) {this. isCuting = true; this. beginPoint = MousePosition; this. endPoint = MousePosition; SaveCutImageSize (MousePosition, MousePosition); UpdateCutInfoLabel (UpdateUIMode. showInfoBox | UpdateUIMode. showCutImage) ;}} if (e. keyCode = Keys. left) {if (this. lbl_CutImage.Visible) {if (e. shift) {if (this. cutImageRect. width> 1) {this. cutImageRect. width-= 1; Cursor. position = new Point (Cursor. position. x-1, Cursor. position. y); UpdateCutInfoLabel (UpdateUIMode. none) ;}} else {if (this. cutImageRect. left>-1) {this. cutImageRect. x-= 1; UpdateCutInfoLabel (UpdateUIMode. none) ;}} else {if (Cursor. position. x>-1) {Cursor. position = new Point (Cursor. position. x-1, Cursor. position. y) ;}} if (e. keyCode = Keys. right) {if (this. lbl_CutImage.Visible) {if (e. shift) {if (this. cutImageRect. right <this. width + 1) {this. cutImageRect. width + = 1; Cursor. position = new Point (Cursor. position. X + 1, Cursor. position. y); UpdateCutInfoLabel (UpdateUIMode. none) ;}} else {if (this. cutImageRect. right <this. width + 1) {this. cutImageRect. X + = 1; UpdateCutInfoLabel (UpdateUIMode. none) ;}} else {if (Cursor. position. X <this. width + 1) {Cursor. position = new Point (Cursor. position. X + 1, Cursor. position. y) ;}} if (e. keyCode = Keys. up) {if (this. lbl_CutImage.Visible) {if (e. shift) {if (this. cutImageRect. height> 1) {this. cutImageRect. height-= 1; Cursor. position = new Point (Cursor. position. x, Cursor. position. y-1); UpdateCutInfoLabel (UpdateUIMode. none) ;}} else {if (this. cutImageRect. top>-1) {this. cutImageRect. y-= 1; UpdateCutInfoLabel (UpdateUIMode. none) ;}} else {if (Cursor. position. y>-1) {Cursor. position = new Point (Cursor. position. x, Cursor. position. y-1) ;}}} if (e. keyCode = Keys. down) {if (this. lbl_CutImage.Visible) {if (e. shift) {if (this. cutImageRect. bottom <this. height + 1) {this. cutImageRect. height + = 1; Cursor. position = new Point (Cursor. position. x, Cursor. position. Y + 1); UpdateCutInfoLabel (UpdateUIMode. none) ;}} else {if (this. cutImageRect. bottom <this. height + 1) {this. cutImageRect. Y + = 1; UpdateCutInfoLabel (UpdateUIMode. none) ;}} else {if (Cursor. position. Y <this. height + 1) {Cursor. position = new Point (Cursor. position. x, Cursor. position. Y + 1 );}}}}
Handle keyboard lift events
////// Handle keyboard lift events // Shift + Enter. When the Shitf key is released, // stop the area size setting, otherwise, moving the mouse will change the size of the captured area ;/////////Private void Form1_KeyUp (object sender, KeyEventArgs e) {if (e. keyCode = Keys. shiftKey) {if (this. isCuting) {this. isCuting = false; this. pictureBox_zoom.Hide (); this. lastMouseMoveTime = 0; UpdateCutInfoLabel (UpdateUIMode. none );}}}

Functions of keyboard operations:

After pressing the shortcut key (usually Ctrl + Shift + A), you can move the mouse to the approximate position, and then you can precisely move the mouse position through the upper, lower, and lower buttons on the keyboard, after the location is precisely located, you can press the Shift key and then press Enter. do not release the Shift key. In this case, you can press the up or down key to change the size of the region and release the Shift key to complete the region size setting;

At this time, you can change the location of the region by pressing the up or down key, press Shift key, and then press the up or down key to change the size of the region.

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.