mightycpa
March 21st, 2001, 11:50 AM
Hi,
I need help writing a little VBA "coordinate detector", so that I can navigate my mouse to the proper place on my alien applications, Click it, and have a message box pop up with the coordinates. It sure would save a lot of time if I could replace my "Guess and Check It" coordinate detection method I use now.
I've included a bunch of detail below, just in case you need a larger perspective.
How do I detect a mouse click anywhere on the screen using VBA?
Tx,
George
Here's the details:
I'm writing a little VBA utility that moves the mouse around the screen, clicks it, and executes things I can't do with a SendKeys command. All that works fine.
There's one little thing - finding the x an y coordinates of where I want to click is a big PAIN!
The following code will identify the coordinates:
~~~~
Type POINTAPI
x as Long
y as Long
End Type
...
Declare Sub GetCursorPos Lib "user32" (lpPoint as POINTAPI)
...
'Every so often do this:
Call GetCursorPos(v_coord)
MsgBox "X is " & v_coord.x & chr(13) & "Y is " & v_coord.y
~~~~
The final thing I need is a way to detect a mouse click anywhere on the screen (over any window), so that my detector responds to my command. In other words, instead of "Every so often", I'd like "On Mouse Click".
How can I code that?
Tx again!
I need help writing a little VBA "coordinate detector", so that I can navigate my mouse to the proper place on my alien applications, Click it, and have a message box pop up with the coordinates. It sure would save a lot of time if I could replace my "Guess and Check It" coordinate detection method I use now.
I've included a bunch of detail below, just in case you need a larger perspective.
How do I detect a mouse click anywhere on the screen using VBA?
Tx,
George
Here's the details:
I'm writing a little VBA utility that moves the mouse around the screen, clicks it, and executes things I can't do with a SendKeys command. All that works fine.
There's one little thing - finding the x an y coordinates of where I want to click is a big PAIN!
The following code will identify the coordinates:
~~~~
Type POINTAPI
x as Long
y as Long
End Type
...
Declare Sub GetCursorPos Lib "user32" (lpPoint as POINTAPI)
...
'Every so often do this:
Call GetCursorPos(v_coord)
MsgBox "X is " & v_coord.x & chr(13) & "Y is " & v_coord.y
~~~~
The final thing I need is a way to detect a mouse click anywhere on the screen (over any window), so that my detector responds to my command. In other words, instead of "Every so often", I'd like "On Mouse Click".
How can I code that?
Tx again!