![]() |
KnowBrainer Speech Recognition | ![]() |
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 |
|
![]() |
![]() |
- avkatz | - 11/10/2021 05:48 PM |
![]() |
![]() |
- Lunis Orcutt | - 11/10/2021 07:27 PM |
![]() |
![]() |
- avkatz | - 11/10/2021 08:34 PM |
![]() |
![]() |
- PG LTU | - 11/11/2021 10:38 AM |
![]() |
![]() |
- avkatz | - 11/12/2021 03:00 PM |
![]() |
|
I have a set of commands that allow me to mechanize various editing commands in a PDF editing program, and that are based on moving the mouse to a particular location on the screen. For example, if I wish to change the color of the highlighter pen to yellow, I need to click on a particular spot on the screen. But the coordinates of this spot are different depending upon which computer monitor I happen to be using. Is it possible for me to create a variable consisting of an ordered triple that would depend on which computer or monitor I'm using. For example, it could be called YellowMousePosition, and its content would differ depending upon the monitor. And then I could just set the mouse position by saying something like "SetMousePosition YellowMousePosition". This is got to be possible, right? Or is there a more straightforward solution that just scales all mouse position calls depending upon the monitor, so I don't have to create YellowMousePosition, BlueMousePosition, etc.? Thanks, Avery
------------------------- Avery |
|
|
|
![]() |
|
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 Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Type POINTAPI 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 pt 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 2022 |
|
|
|
![]() |
|
Thanks. I know about the Find Mouse Position and have been using it. That's how I found the original set of coordinates. But I was hoping that there was a simple method to translate commands written to work on one monitor so that they would work on another monitor, without having to collect and paste in all the new mouse positions all over again for the new monitor.
------------------------- Avery |
|
|
|
![]() |
|
Of course you can. You can use math to calculate since you can find the offset (monitors start at adjoining and adjacent pixels) which is constant (so addition or subtraction) and you can find the resolution, scaling and DPI factors of each monitor display to determine the ratio of unit lengths (so division) which can help you with determining the number of units lengths in the x and y direction to get to your spot of interest (so multiplication). It is not as hard as you'd think, but for more help look for the "Fling" AHK command I once wrote (and still use) which takes a program window from one monitor and positions it on another monitor in the exact same relative position and size as originally (and accounting for the different resolution and scaling of the different monitor) from which you can find most of the math involved: here -------------------------
|
|
|
|
![]() |
|
Thanks much - this is a help. With regard to using shortcut keys, I do that when feasible, but I am using Fox it PDF Editor, which is based on a graphic interface and does not (as far as I know) allow me to choose color and similar features using a keyboard. Maybe I should switch to PDF-XChange.
------------------------- Avery |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2023 FuseTalk™ Inc. All rights reserved.