![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Caffeinated Neural Net
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 920
Rep Power: 4
![]() |
Re: Left Mouse Click
Here is a simple console application I whipped up to demonstrate:
C# Syntax (Toggle Plain Text)
System.Windows.Forms.Keys enumeration; this is basically the .NET version of the virtual-key constants. You need to cast them to byte first, and (if you're creating a console app, rather than a Windows forms app) add a reference in your project. To add a reference, right-click the project name in the Solution Explorer, say 'add reference', and on the .NET tab, there will be one for System.Windows.Forms. You need to do this before the matching using directive will work. If you're creating a forms app, the reference will already be there, and the using directive will too for any forms-derived classes you create.The second thing I did was to use the constant 0x7F. This is simply the value of the KEYEVENTF_KEYUP constant. Remember that each 'key down' event needs to be matched with a corresponding 'key up' event, or the system will think a key is still being held down.Anyways, if you create a new console application, and copy-paste my code above in, it should work fine (after you add the reference, of course). To run it, don't do it from the IDE. Rather, open up a command window (Start -> Run -> type 'cmd' and hit ENTER), navigate to the directory where your program executable is, and run it. You should get output similar to the following: C:\PathToYourExecutable>NameOfYourExecutable C:\PathToYourExecutable>hello
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp |
|
|
|
|
|
#12 |
|
Expert Programmer
|
Re: Left Mouse Click
again, thankyou, that worked perfectly. also thank you for taking the time to explain what was going on.
__________________
|
|
|
|
|
|
#13 | |
|
Caffeinated Neural Net
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 920
Rep Power: 4
![]() |
Re: Left Mouse Click
Quote:
keybd_event() and have your public method use the Keys enumeration directly: C# Syntax (Toggle Plain Text)
System.Windows.Forms.Keys enumeration. Second, by using an enum, the calling code can only simulate keys for which there is a defined value (no passing in random numeric values). Third, it's clearer because there are two methods that take a single parameter, rather than one method with four (arguably more obscure) parameters. I mean, knowing the names and parameters of those two methods there makes it pretty clear what they do.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Implementation of Mouse Events. | smita | Existing Project Development | 3 | Mar 15th, 2007 3:11 PM |
| Java applet mouse event. Some trouble... | glopal | Java | 5 | Mar 9th, 2007 3:59 PM |
| Hyperactive mouse | Polyphemus_ | Coder's Corner Lounge | 4 | Jan 13th, 2007 10:59 PM |
| Mouse problems | coldDeath | Coder's Corner Lounge | 8 | Jul 5th, 2006 5:11 PM |
| Help: Changing mouse input to keyboard? | Alighieri | C++ | 2 | Mar 17th, 2005 9:59 AM |