C # mouse clicks-no test-self http://hi.baidu.com/syq_ghost/item/2cc253eb538b72e7fb42ba44

Source: Internet
Author: User
C # mouse clicks

Using system;

Using system. Collections. Generic;

Using system. componentmodel;

Using system. Data;

Using system. drawing;

Using system. LINQ;

Using system. text;

Using system. Windows. forms;

Using system. runtime. interopservices;

Using system. Threading;

Using system. Text. regularexpressions;

 

Namespace windowsformsapplication5

{

Public partial class form1: Form

{

[Dllimport ("USER32")]

Private Static extern int mouse_event (INT dwflags, int dx, int dy, int cbuttons, int dwextrainfo );

Const int mouseevent_leftdown = 0x0002;

Const int mouseevent_leftup = 0x0004;

Public form1 ()

{

Initializecomponent ();

}

 

Private void button#click (Object sender, eventargs E)

{

String Pattern = @ "^ \ D + (\. \ D )? $ ";

Timer1.enabled = true;

If (RegEx. ismatch (textbox2.text, pattern ))

{

Timer1.interval = int. parse (this. textbox2.text );

Timer1.start ();

}

Else

{

Timer1.stop ();

Timer1.enabled = false;

MessageBox. Show ("enter an integer! "," System prompt: ", messageboxbuttons. OK, messageboxicon. Error );

}

}

 

Private void mouse_click ()

{

Mouse_event (mouseevent_leftdown, 0, 0, 0, 0 );

Mouse_event (mouseevent_leftup, 0, 0, 0, 0 );

Textbox2.focus ();

}

 

Private void timereffectick (Object sender, eventargs E)

{

Mouse_click ();

}

 

Private void form1_load (Object sender, eventargs E)

{

Textbox2.focus ();

}

 

Private void textbox2_click (Object sender, eventargs E)

{

This. textbox2.selectall ();

}

 

Private void textbox2_keydown (Object sender, keyeventargs E)

{

String Pattern = @ "^ \ D + (\. \ D )? $ ";

If (E. keycode = keys. Pageup)

{

If (RegEx. ismatch (textbox2.text, pattern ))

{

Timer1.enabled = true;

Timer1.interval = int. parse (this. textbox2.text );

Timer1.start ();

}

Else

{

Timer1.stop ();

Timer1.enabled = false;

MessageBox. Show ("error: enter an integer! "," System prompt: ", messageboxbuttons. OK, messageboxicon. Error );

}

}

Else if (E. keycode = keys. Pagedown)

{

Timer1.enabled = true;

Timer1.stop ();

}

}

}

}

 

C # The Mouse clicking function can also be implemented. I tried to write a script that should be used by friends who play games. I hope it will be useful to you.

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.