How do I make the mouse cursor get a value..?
I get the feeling there must be a simpler way to do what you want, but this
will get you the mouse coordinates:
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos _
Lib "user32" (lpPoint As POINTAPI) As Long
Function GetCursorPosition() As Long()
Dim Point As POINTAPI
Dim arr(1 To 2) As Long
GetCursorPos Point
arr(1) = Point.x
arr(2) = Point.y
GetCursorPosition = arr
End Function
Sub test()
Dim arr() As Long
arr = GetCursorPosition()
MsgBox "x " & arr(1) & vbCrLf & _
"y " & arr(2), , "mouse coordinates"
End Sub
RBS
wrote in message
...
Fellow programmers thank you for your time. I need some assistance...
I am trying to figure out how to get the mouse cursor select from text
from a specific x z cord and paste the value in a text box on my
userform. Here is some code I tried...
SetCursorPos 255, 413
Do Until UserForm1.TextBox1.Value = 521
DoEvents
Application.Run "mouscoords"
mouse_event MOUSEEVENTF_LEFTDOWN, 0&, 0&, 0&, 0&
SendKeys "^C", True
UserForm1.TextBox3.SetFocus
SendKeys "^V", True
mouse_event MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
UserForm1.TextBox1.Value = UserForm1.TextBox1.Value + 1
SetCursorPos UserForm1.TextBox1.Value, 413
DoEvents
Loop
It doesn't seem to want to work... I'd imagine that this isn't the
best way of doing this but but I'm curious if anyone has gotten
something simlar to work. I was also wondering if it was possible for
Excel VBA to read the value of a mouse cord x z value... Any ideas?
There seems to be alot of brilliant people on this message board so I
look forward to see what the end result is.
Thank you ever so much!
|