January 12th, 2006, 11:26 AM
Changing mouse position programmatically
Hello everyone. I would like your assistance in learning how to do the following two things in .net:
1. How do I alter the mouse position programmatically?
2. How do I send an event (ie. mouse click event) to a specific control?
Thanks a bunch,
January 12th, 2006, 11:44 AM
What would be the need to alter the mouse's position? Don't you think you'd be a bit miffed if someone didn't let you move your mouse where you wanted to?
Originally Posted by Tony Lintunen
Why would it need to be a mouse click event, you could just move mouse click code to another part of code, such as an onload method?
January 12th, 2006, 01:45 PM
I want a way to automatically resize a datagrid's columns to the correct width. I'm not particularly fond of the method where you iterate through all the rows and set the width according to the widest row.
Originally Posted by MBirchmeier
I want to simulate a datagrid column click, which resizes the column appropriately. I want to do this by programmatically moving the mouse to the column's right edge, and sending a column click message to the datagrid.
Is there a .net equivalent of the win32 api sendmessage function?
January 12th, 2006, 03:21 PM
You could always use this:
That will set your mouse to co-ordinates 200x200 upon clicking a command button.
Public Declare Function SetCursorPos Lib "user32" (ByVal X As Integer, ByVal Y As Integer) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
February 10th, 2006, 05:18 AM
Ah nice, thx. I needed this too
Do you also know how to click the left mouse button after you moved the mouse?
Thanks in advance