KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: How to bring the mouse to the cursor position
Topic Summary: (I know I have asked before...)
Created On: 02/17/2022 03:57 AM
Status: Post and Reply
Linear : Threading : Single : Branch
 How to bring the mouse to the cursor position   - Anandits - 02/17/2022 03:57 AM  
 How to bring the mouse to the cursor position   - Matt_Chambers - 02/17/2022 09:29 AM  
 How to bring the mouse to the cursor position   - Edgar - 02/17/2022 09:43 AM  
 How to bring the mouse to the cursor position   - Alan Cantor - 02/17/2022 10:04 AM  
 How to bring the mouse to the cursor position   - Ag - 02/18/2022 02:07 AM  
 How to bring the mouse to the cursor position   - Ag - 09/02/2022 01:10 PM  
 How to bring the mouse to the cursor position   - Robert Snow - 02/18/2022 09:18 PM  
 How to bring the mouse to the cursor position   - dilligence - 02/19/2022 08:51 AM  
 How to bring the mouse to the cursor position   - Alan Cantor - 02/19/2022 12:37 PM  
 How to bring the mouse to the cursor position   - Anandits - 09/01/2022 01:40 AM  
Keyword
 02/17/2022 03:57 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Advanced Member

Posts: 184
Joined: 03/25/2019

Some time ago I also asked this question, and it gave interesting discussion but no answer. I wonder if by now maybe someone happened to find a solution to this...

 

I would like to have a command that is taking the mouse cursor to the insertion point. It is very tedious to navigate to a certain place in a document, and then execute a mouse command and lose your place. I am currently for instance trying to practice using SP's WinPress, or SpeechStarts's 'Left Mouse Down' command to try to select text. (for instance, if I want to highlight a few lines in a paragraph). (In Dragon unfriendly environments, especially Google docs). I would have navigated to a certain position by saying things like "go down 5"..."go right 3 words...", And when I finally get where I want to be, it is annoying to realize I have left the mouse cursor behind and have to start all over again.

 

There might be other solutions for this particular Problem, but this is just one example. I would love a way to "call" the cursor and have it join the insertion point. (I don't know if I'm using the right terminology).

 

 02/17/2022 09:29 AM
User is offline View Users Profile Print this message

Author Icon
Matt_Chambers
Top-Tier Member

Posts: 756
Joined: 08/09/2018

I don't know the answer and can't find one anywhere on this forum, surprisingly. Seems like there ought to be a sensible solution.

It appears that there may be a way to do it using AutoHotKey: https://superuser.com/questions/1037906/move-mouse-pointer-to-typing-area



 02/17/2022 09:43 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1375
Joined: 04/03/2009

It might also be possible using a fairly small C# application. There's a snippet from a post on stackoverflow.com, posted by BrendanMcK:

GetGUIThreadInfo() is probably your best bet; pass it with idThread = 0 to get the info from the currently active thread, and then check the rcCaret member of the returned GUITHREADINFO structure. You'll then need to use ClientToScreen() with the hwndCaret value to convert client-relative coordinates to screen coordinates.

Note that this only works for apps that use the Win32 caret functions - specifically SetCaretPos(). If an app draws its own caret without using these, you may not get anything meaningful back. (Some apps, like Word, draw their own caret, but still call SetCaretPos so that accessibility aids that need to track the caret can use this technique.)

The rectangle you get back can sometimes be wider than the actual caret. When a bitmap is used for the caret, as is the case for Right-To-Left or Left-To-Right carets that have a little 'flag' attached to the top, you'll get back a rectangle that's a bit wider than the actual caret area, and may need to adjust or otherwise figure out where within this area the actual caret bar is - it may or may not be in the exact middle. Looks like for Notepad++ you should be fine, though.



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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 02/17/2022 10:04 AM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4532
Joined: 12/08/2007

If you are working in Dragon-compatible applications (Word, Outlook, a browser with its Dragon plug-in installed), there are easier and faster ways to select text. Moving the mouse pointer, clicking, and dragging is a lot of work because you're dealing with content on the level of the pixel - and there are millions of pixels. The following technique uses the words that you can see as anchors.

The main technique is this:

"select [word]"

For example, if you want to select the last word in the first paragraph, say:

"select anchors"

If you want to select the last word in the first paragraph and the punctuation mark afterward, say:

"select anchors period"

To select the first four words in the first paragraph, say:

"select if you are working"

When selecting big chunks of text, specify the start and end words. To select from the start of the first paragraph to after "faster," say:

"select if through faster"

(Depending on your region, you may need to substitute the word "to" for "through" when selecting a range of text.)
 02/18/2022 02:07 AM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 1035
Joined: 07/08/2019

Originally posted by: AnanditsI would like to have a command that is taking the mouse cursor to the insertion point.


This is an AutoHotKey FAQ.

Here is my Dragon - AHK code to do it. I hope this provides enough information that you could translate it into Dragon Basic.

 

#TBD-post-to-my-GitHub-wiki

 

It does not work with all apps. For example, I print warning or explanatory messages because I already know it does not work in Microsoft OneNote or Google Chrome. It works in Outlook and Microsoft Word.  It gets confused on some systems, like my system that has 4 monitors, each with different display scaling. That's a generic AutoHotKey problem AFAICT. But it works in quite a few places, enough to be useful.  I currently have it as a single global binding, with the explanatory messages for places where it is known to be bad. You might prefer to only enable it in apps that you know it works.But that leads to a proliferation of app specific commands in Dragon Basic.

 

;; HERE: move mouse to text positiom
;;  I don't really need move text position to mouse, because that's usually just a plain click
;;  although I suppose I could have a command like that

global.simple( { action_fn: Func("fn_move_Mouse_to_Text_cursor")
,	   regex: "(move[d]? )?mouse( (cursor|pointer|position))?( to)? text (cursor|caret|\^|position)"
,          0:0 } )

;; TBD:  automate the tests, embedding them in the pattern
;;  "Comment: relatively complete basic patterns"
;;  { test_pattern: "PUFF move mouse cursor to text cursor" }
;;  { test_pattern: "PUFF move mouse cursor to text caret" }
;;  { test_pattern: "PUFF move mouse to text cursor" }
;;  { test_pattern: "PUFF move mouse to text caret" }
;;  { test_pattern: "PUFF mouse cursor to text cursor" }
;;  { test_pattern: "PUFF mouse cursor to text caret" }
;;  { test_pattern: "PUFF mouse to text cursor" } ;
;;  { test_pattern: "PUFF mouse to text caret" }
;;  { test_pattern: "PUFF mouse to text position" }
;;  { test_pattern: "PUFF move to text cursor" }
;;  { test_pattern: "PUFF move to text caret" }
;;  { test_pattern: "PUFF move to text position" }
;;  { test_pattern: "PUFF move mouse cursor to caret" }
;;  { test_pattern: "PUFF move mouse to caret" }
;;  { test_pattern: "PUFF move mouse to text cursor position" }
;;  { test_pattern: "PUFF move mouse to text caret position" }
;;  "Comment: special case?"
;;  { test_pattern: "PUFF move to caret" }
;;  "comment: misrecognitions kluged in"
;;  { test_pattern: "PUFF moved to caret" }
;;  "comment: end" )

;; TBD: It might be nice to have this as a mouse trackball hotkey finding, in addition to speech
fn_move_Mouse_to_Text_cursor(args,tuple)
{
	local
	if(1)
	{

		CoordMode, Caret, Screen
		CoordMode, Mouse, Screen

		MouseGetPos,old_X,old_Y

		MouseMove, %A_CaretX%, %A_CaretY%

		MouseGetPos,new_X,new_Y

		mouse_moved := old_X != new_X ||  old_Y != new_Y
		same_mc := new_X == A_CaretX &&  new_Y == A_CaretY
		if( mouse_moved )
			my_ExitApp(0)
		if( same_mc )
			my_ExitApp(0)
		;; TBD: use some sort of heuristic or fuzz since seldom is the mouse exactly equal to the ^, there is often an offset

		if(1)
		{
			known_problem := ""
			if( my_WinActive("OneNote") )
				known_problem := "`nactive app OneNote is known problem"
			if( my_WinActive("Chrome") )
				known_problem := "`nactive app Chrome is known problem"

			msg_short := "Mouse did not move. App may not support A_CaretXY text position. " . known_problem

			msg_long := ""
			. "Mouse did not move - active window/app may not support A_CaretXY"
			. "`n Apps known to support: emacs, word,.."
			. "`n Apps known to NOT support: OneNote, Chrome, ..."
			. known_problem

			my_error(msg_short,msg_long)
			my_ExitApp(1)
		}
	}
	my_ExitApp(0)

	;; fall through
	my_error("command not recognized: " . args . "`n   only handled in " . contexts )
}



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

DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design.



 09/02/2022 01:10 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 1035
Joined: 07/08/2019

BTW I have since updated to use my "MouseMove_KLUGE",  and it does a better job of handling displays with  heterogenous display scaling



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

DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design.

 02/18/2022 09:18 PM
User is offline View Users Profile Print this message

Author Icon
Robert Snow
Top-Tier Member

Posts: 239
Joined: 04/18/2017

I'm not sure what your using and why. It sounds like a text edit. Don't know what SP WinPress is. I'm using Office 365 DeskTop OneNote. I have 2 items on my ToolBar that I use to recover my previous locations.

  1. A simple "Back". 3 clicks and I'm back to 3 previous moves etc.
  2. The second Button is a history of 25 moves. At least I use 25 there might be more in the settings. I look at the list and can select the point I want to return to.

 Bob



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

Robert Snow
Germantown, WI

 02/19/2022 08:51 AM
User is offline View Users Profile Print this message

Author Icon
dilligence
Top-Tier Member

Posts: 1650
Joined: 08/16/2010

Irene does not mean speech friendly office applications. There are more than enough ways there to get to the insertion point there and using a mouse would be mostly unnecessary (both SP versions have several really fast text direction commands). However, her issue is particularly occurring in Google Docs, which is probably the most Dragon® unfriendly application right next to Thunderbird. 

 

Moving the mouse pointer to the current insertion point (regardless of which application you are in) has been a long-term wish for many Dragon users, including myself. 

 

However this involves a complex process, not even sure if it's doable in a way that it reliably works everywhere. Nevertheless, this has my full attention and I'm going to ask Tom to take a serious look at creating a simple utility for this that doesn't require complex coding for the user.

 

@Robert Snow

The WinPress command Irene is referring to is part of the SP Press Utility© (available in both SP Standard and PRO):

 

 

 

 

 



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

https://speechproductivity.eu


Turbocharge your Dragon productivity with 40+ Power Addons

 02/19/2022 12:37 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4532
Joined: 12/08/2007

I just whipped up this custom Dragon command to select text in non-Dragon friendly applications. It's not bulletproof. But hopefully it's a good place to start.

Grab <direction> <1-12> <move-by-unit>

Sub Main
' Select text in non-Dragon friendly applications. Examples:
' "Grab Right 2 Words"
' "Grab Down 5 Lines"
' "Grab Up 8 Paragraphs"
' "Grab Left 12 Characters"
' OK to substitute "Cares" for "Characters" and "Paras" for "Paragraphs"

Dim Direction, Count, Unit As String

Let Direction = ListVar1 ' down, left, right, or up
Let Count = ListVar2 ' Number of repetitions
Let Unit = Left(ListVar3, InStr(ListVar3, "\")-1) ' SendKey codes to select words, lines, characters, paragraphs, etc.

SendKeys Unit & "{" & Direction & " " & Count & "}"
' Example: SendKeys "+^{Right 5}"
End Sub


You'll need to create three lists in the Command Browser:


<direction> consists of:

down
left
right
up


<1-12> consists of:

1
2
3
4
5
6
7
8
9
10
11
12

You can expand this list to 20, 50, 100, or whatever maximum value seems reasonable to you.


<move-by-unit> consists of:

+\Care
+\Cares
+\Character
+\Characters
+\Line
+\Lines
+^\Para
+^\Paragraph
+^\Paragraphs
+^\Paras
+^\Word
+^\Words


This list contains the codes for SendKeys to output either the Shift key, or the Shift key plus the Ctrl key.
 09/01/2022 01:40 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Advanced Member

Posts: 184
Joined: 03/25/2019

Thank you very much, Allan, for some reason I only tried this out now, and it does help in selecting text in Google Docs. Thank you for taking the time to create this script for me.
Statistics
32529 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 358 guests browsing this forum, which makes a total of 358 users using this forum.

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