Return value of RememberPoint in Nuance Dragon

44 Views Asked by At

I'm trying to create a voice command in Nuance Dragon (Professional Individual version) to switch my language input to Korean. I want it to press the associated hot keys, click the button to toggle to Hangul characters, and return the cursor to where it was when I started.

So basically:

  1. Get current position of mouse
  2. Press hot keys
  3. Click mouse at target location
  4. Set position of mouse to position in step one

I'm running into trouble with RememberPoint -- whenever I try to run the script, it gives me an error, telling me either that "Subs can't be used in expressions" (if put inside Sub Main) or that it expects a different command ("Expecting 'Declare|Delegate|Event|Function|Property|Sub|Const|Dim|Private|Public|Friend|Class|Enum|Module|Type' " if put outside Sub Main).

(NOTE: these are the two positions things I've tried, but I didn't do both of them at once, as below)

Dim originalPoint

originalPoint = RememberPoint

Sub Main
    originalPoint = RememberPoint
End Sub

There is pretty much no documentation on RememberPoint*. I've looked through Dragon's samples , I've declare the variable as a String and Integer, and I've tried other declarations listed above. I expected RememberPoint to return a value in mouse coordinates but this seems wrong. Perhaps it should be something like a Sub or Event, but I've had no luck there.

Thanks!

Simon

*https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/scrptref/rememberpoint.htm, https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/scrptref/dragtopoint.htm

2

There are 2 best solutions below

0
On

Hmmm lemme try again more directly as below may be more than what OP needs (see comment).

Are you just missing how it all works in practice? In code, you'll have to actually indicate where the mouse goes (or position it yourself) before the RememberPoint directive and then move the mouse to the end position in code (or by hand yourself) before the DragToPoint is issued. In code, using the Dragon extensions, it is the SetMousePosition command that you need:

https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/scrptref/setmouseposition.htm

My below reference code (use at own sole risk) uses the Wait scripting extension so after hitting Run in the command Browser (or speaking the command name) you have 5 seconds to move the mouse to your start position. If you do nothing, the start position will be in the title bar of the active window (I hope - YMMV). You'll hear a beep to know 5 seconds are up. Then move the mouse to the end position, and 5 seconds later (you'll hear another beep) the drag will happen. By default, it moves the active window a bit to the right and down.

'#Language "WWB-COM"
Option Explicit

Sub Main
    SetMousePosition 1,80,15 ' 1 is relative to active window
    Wait 5
    Beep
    RememberPoint
    SetMousePosition 2,100,200 ' 2 is relative to the current position
    Wait 5
    Beep
    DragToPoint 1
End Sub

hth,

1
On

It seems you have difficulty getting and storing the current mouse position? Note, mouse positions are stored as two long numbers, one for each dimension.

Can you tell me if this helps get you where you want as it should demonstrate how to capture and use a mouse coordinate:

'#Language "WWB-COM"
Option Explicit
Type POINT
   xCoord As Long
   yCoord As Long
End Type

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

Sub Main
    Dim originalPoint As POINT  '  dimensions the proper data structure
    GetCursorPos originalPoint  '  captures where the mouse currently is
    '  show result after converting each Long to a String:
    MsgBox CStr( originalPoint.xCoord ) & " " & CStr( originalPoint.yCoord )
End Sub

Of course, between getting and setting mouse positions, be also aware of your basic mouse coordination frameworks (as in Desktop, Window, etc.) which tell you which point to call 0,0 and measure the offset from.