ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA to control the Mouse (https://www.excelbanter.com/excel-programming/343039-vba-control-mouse.html)

DejaVu[_50_]

VBA to control the Mouse
 

Is there anyway to control the mouse movements, position, and clicks? I
need to control the mouse to click a certain area on my database screen.
I can't get the control with the keyboard, and the mouse is the only
other option.

TIA,

DejaVu


--
DejaVu
------------------------------------------------------------------------
DejaVu's Profile: http://www.excelforum.com/member.php...o&userid=22629
View this thread: http://www.excelforum.com/showthread...hreadid=476871


Tom Ogilvy

VBA to control the Mouse
 
Unless you are programming some type of instructional routine that guides
the user to perform an action, you are headed in the wrong direction. If
you need to execute the click event for a commandbutton in Sheet1 (Sheet1
being the code name) for example, you would rename the click event to public

Private Sub CommandButton1_Click()

becomes

Public Sub CommandButton1_Click()

then you could do

Sheet1!CommandButton1_Click()

to execute the click event.

easier is move the meat of the code to a general module a a public sub and
then you can call that from either the click event or your own routine

Private Sub CommandButton1_Click()
MyCode
End Sub

in a general module

Public Sub Mycode()
' code that used to be in the click event
End Sub



--
Regards,
Tom Ogilvy


"DejaVu" wrote in
message ...

Is there anyway to control the mouse movements, position, and clicks? I
need to control the mouse to click a certain area on my database screen.
I can't get the control with the keyboard, and the mouse is the only
other option.

TIA,

DejaVu


--
DejaVu
------------------------------------------------------------------------
DejaVu's Profile:

http://www.excelforum.com/member.php...o&userid=22629
View this thread: http://www.excelforum.com/showthread...hreadid=476871




DejaVu[_51_]

VBA to control the Mouse
 

Thanks for the reply Tom.

I'm still not sure how to handle this though... I don't want to click
anywhere on a worksheet (or even in excel for that matter). I need to
mouse click on another program. Can I use VB code to control what the
mouse does, or can I use some sort of API call to (1) Open the program
window and (2) make the mouse click on a specified pixel or "latitude"
& "longitude" on my screen? I thought I read something that it was
possible to input the coordinates and have the mouse move there and
click on command... am I way off??

Thanks,

DejaVu


--
DejaVu
------------------------------------------------------------------------
DejaVu's Profile: http://www.excelforum.com/member.php...o&userid=22629
View this thread: http://www.excelforum.com/showthread...hreadid=476871


Tom Ogilvy

VBA to control the Mouse
 
I have no idea if you can do that - but if you can, I would say the approach
definitely isn't a route heavily travelled.

--
Regards,
Tom Ogilvy

"DejaVu" wrote in
message ...

Thanks for the reply Tom.

I'm still not sure how to handle this though... I don't want to click
anywhere on a worksheet (or even in excel for that matter). I need to
mouse click on another program. Can I use VB code to control what the
mouse does, or can I use some sort of API call to (1) Open the program
window and (2) make the mouse click on a specified pixel or "latitude"
& "longitude" on my screen? I thought I read something that it was
possible to input the coordinates and have the mouse move there and
click on command... am I way off??

Thanks,

DejaVu


--
DejaVu
------------------------------------------------------------------------
DejaVu's Profile:

http://www.excelforum.com/member.php...o&userid=22629
View this thread: http://www.excelforum.com/showthread...hreadid=476871




DejaVu[_52_]

VBA to control the Mouse
 

Thanks for your help Tom. I'll figure something out ... eventually!

DejaV

--
DejaV
-----------------------------------------------------------------------
DejaVu's Profile: http://www.excelforum.com/member.php...fo&userid=2262
View this thread: http://www.excelforum.com/showthread.php?threadid=47687



All times are GMT +1. The time now is 01:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com