Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving the mouse

Status
Not open for further replies.

BaDi

Programmer
May 14, 2002
32
NL
Hi!

Here comes my next question!:)

I have a button A
When I press it, I want to make the button move to button B, click it and then move it to button C and click that one.
How do I do this?

Thanx in advance!
 
Not sure if I have read your question correctly but I think that you are saying that you have 3 buttons on your form and that when button1 is pressed you would like the other 2 buttons to be pressed. If so just add the following 2 lines of code to the button 1 code
Button2_Click
Button3_Click

Just replace the Button2 & Button3 for the names of your buttons
 
I think that what BaDi means is that if he clicks button1 that the mouse moves to button2 and clicks it. No idea how to do this though. :S
 
I think that he means that too, but cannot see why it would matter whether the mouse moved or not. If it is important that the mouse moves then the only way I can think of doing it would be for the software to pick up the X and Y co-ordinates for buttons 2 & 3, then telling the mouse pointer to go to those points?
 
You need to use the following API call to move the mouse

Type POINTAPI
X As Long
Y As Long
End Type

Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Declare Function GetCursor Lib "user32" () As Long

private sub Button1_click()
Dim Pos As POINTAPI

r = GetCursorPos(Pos)
r = SetCursorPos(newx,newy)

'newx and newy should be the screen x and y coordinated Button2
end sub

private sub Button2_click()
Dim Pos As POINTAPI

r = GetCursorPos(Pos)
r = SetCursorPos(newx,newy)

'newx and newy should be the screen x and y coordinated Button3
end sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top