KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: How to remember mouse position and return to it?
Topic Summary:
Created On: 01/05/2018 06:04 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 How to remember mouse position and return to it?   - avkatz - 01/05/2018 06:04 PM  
 How to remember mouse position and return to it?   - Lunis Orcutt - 01/05/2018 06:34 PM  
 How to remember mouse position and return to it?   - avkatz - 01/05/2018 06:53 PM  
 How to remember mouse position and return to it?   - avkatz - 01/05/2018 06:57 PM  
 How to remember mouse position and return to it?   - Grindcore - 01/05/2018 10:26 PM  
 How to remember mouse position and return to it?   - avkatz - 01/06/2018 10:02 AM  
 How to remember mouse position and return to it?   - Mark Bennett - 06/01/2018 04:51 PM  
 How to remember mouse position and return to it?   - Mphillipson - 06/03/2018 03:46 PM  
 How to remember mouse position and return to it?   - Ag - 09/07/2019 03:50 PM  
 How to remember mouse position and return to it?   - kkkwj - 12/23/2020 10:49 PM  
Keyword
 06/01/2018 04:51 PM
User is offline View Users Profile Print this message

Author Icon
Mark Bennett
New Member

Posts: 3
Joined: 05/27/2018

I borrowed some command from this page and other posts on the form. The command I came up with (after very minimal editing) copies the mouse coordinates (based on the screen position, not the window). The next command moves the mouse to the copied coordinates. I needed this to be a 2-command process. The downside is that it uses the clipboard. If someone finds errors in this, please let me know. If someone knows how to duplicate this code without using the clipboard, please let me know also.

1)MOUSE LOCATION COPY COMMAND (based on screen coordinates only)


Type POINTAPI 'Declare types

x As Long
y As Long
End Type

Dim Pre as String
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long 'Declare API
Dim z As POINTAPI 'Declare variable

Sub Main

GetCursorPos z 'Get Coordinates
Pre = "The captured screen-relative mouse position was: X = "
X$ = Str$(z.x)
Y$ = Str$(z.y)
Let Sp = " Y = "

Let S = Pre+X$+Sp+Y$
'MsgBox S, 0, "Get Mouse Screen Position"   '  This was in the original code
Let SpC = ","
C$ = X$+SpC+Y$
Clipboard C$ 'this statement compiles but causes a runtime error

End Sub


2)MOUSE 'PASTE' COMMAND

Sub Main
clip = Clipboard
Dim LString As String
Dim LArray() As String

LString = clip
LArray = Split(LString, ", ")
SetMousePosition 0,LArray(0),LArray(1)




End Sub



-------------------------

Mark Bennett, Learning about Computer Disability Accomodations



Statistics
32133 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 0 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 423 guests browsing this forum, which makes a total of 423 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2021 FuseTalk™ Inc. All rights reserved.