-
March 24th, 2017, 10:43 PM
#1
How to get GetCursor and SetCursor together...
I have this code where it can give me the range of my cursor but I also want to insert cursor or set my cursor within that range, how to call the x and y with SetCursor? After that I want to insert/attach a string in to it, i.e. Text=X and Y, do I need to use Dim as Range or Dim as Long? I tried SetCursorPos PT.x,PT.y and SetCursorPos Text1.text, but it gives me error or Invalid outside Procedure...
Code:
Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Timer1_Timer()
Dim PT As POINTAPI
GetCursorPos PT
Text1.Text = "(" & PT.x & "," & PT.y & ")"
End Sub
Last edited by 2kaud; March 25th, 2017 at 03:34 AM.
Reason: Added code tags
-
March 25th, 2017, 06:58 AM
#2
Re: How to get GetCursor and SetCursor together...
The error message you mention indicates that you placed the code outside of a procedure.
Since you did not show that code we don;t know where you put it but that is what the error is telling you.
All code must be inside a sub or function block.
Only declares can be placed outside of a procedure.
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|