KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Help with writing commands calling MousePosition on multiple monitors?
Topic Summary:
Created On: 11/10/2021 05:48 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 11/10/2021 07:27 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 40108
Joined: 10/01/2006

KnowBrainer 2020 includes the Find Mouse Position command. Just say this command to capture your mouse X & Y window coordinates. The following command works in both KnowBrainer 6 - 2020 and Dragon


Option Explicit

Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

x As Long
y As Long
End Type

' declare Win32 API functions

Declare Function GetCursorPos Lib "user32" _
  Alias "GetCursorPos" (lpPoint As POINTAPI) As Long

Declare Function GetWindowRect Lib "user32" _
  Alias "GetWindowRect" (ByVal hwnd As Long, _
  lpRect As RECT) As Long

Declare Function GetForegroundWindow& Lib "user32" ()

Function GetWinCurPos(hwnd As Long) As POINTAPI

Dim wRect As RECT
Dim result As POINTAPI

GetCursorPos pt

GetWindowRect hwnd, wRect

result.x = pt.x - wRect.Left
result.y = pt.y - wRect.Top

GetWinCurPos = result
End Function
Sub Main
Dim hwnd As Long
Dim result As POINTAPI
Dim clip As String

hwnd = GetForegroundWindow
result = GetWinCurPos(hwnd)

clip = "SetMousePosition 1," & result.x & _
"," & result.y
clip = clip & Chr(13) & Chr(10) & _
"Wait 0.5" & Chr(13) & Chr(10) & _
"ButtonClick 1,1" & Chr(13) & Chr(10) & _
"Wait 0.5" & Chr(13) & Chr(10)
Clipboard clip
TTSPlayString "ready"
End Sub


Change "No" to "Know" w/KnowBrainer 2020
Trial Downloads
(615) 884-4558 ex 1

32358 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 374 guests browsing this forum, which makes a total of 374 users using this forum.

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