Dragon custom voice command to change date format (and some extras)

Post your working scripts, libraries and tools for AHK v1.1 and older
wbm1113
Posts: 18
Joined: 28 Aug 2018, 11:19

Dragon custom voice command to change date format (and some extras)

03 Oct 2018, 21:19

Setup & add the custom command (slightly modified version of Elgin's script):

Code: Select all

OnExit, CleanUp

DVC:= ComObjCreate("Dragon.DgnVCmd")
DVC.Register("", 1)
DMnu:= DVC.MenuCreate("SomeRuleName", "", 0, "", 1)
DMnu.hWndMenu:=0
DMnu.Active:=True
LStr:=COMObjCreate("Dragon.DgnStrings")

Lstr.Add("date format short")
Lstr.Add("date format long")

DMnu.ListSetStrings("MyCommands", Lstr)
ObjRelease(Lstr)
DMnu.Add(72, "<MyCommands>","SomeCategory","SomeDescription","Action1",0)
ComObjConnect(DVC, "On_")

On_CommandRecognize(pcom,pID,pact,plist)
{
	commandptr := NumGet(ComObjValue(pcom),0,"Ptr")
	command := StrGet(commandptr)
	id := NumGet(ComObjValue(pID),0,"int")
	actptr := NumGet(ComObjValue(pact),0,"Ptr")
	act := StrGet(actptr)
	listp := NumGet(ComObjValue(plist),0,"Ptr")
	lp := ComObject(9,listp,1)
	listcnt := lp.Count
	if listcnt>0
	{
		listit := lp.Item(1)
	}
	else listit:=""
		
	If(Command="date format short")
	{
		DgnEngine := ComObjCreate("Dragon.DgnEngineControl")
		DgnEngine.Register(0)
		DgnEngine.Option(45) := 9
		DgnEngine.UnRegister(0)
		ObjRelease(DgnEngine)
	}
	
	If(Command="date format long")
	{
		DgnEngine := ComObjCreate("Dragon.DgnEngineControl")
		DgnEngine.Register(0)
		DgnEngine.Option(45) := 1
		DgnEngine.UnRegister(0)
		ObjRelease(DgnEngine)
	}
	return
}

CleanUp:
DVC.UnRegister()
ObjRelease(DVC)
ObjRelease(x1)
ObjRelease(oWord)
ExitApp
You can keep using this pair in the setup and function to make any voice command do anything you want (my script has about 20 of them). You can also use the date formats as indicated below with this particular function. There are more past the number 10 but I didn't test them.

Code: Select all

Lstr.Add("Sample Command")
If(Command="Sample Command")
{
	msgbox sample command
}

DgnEngine.Option(45) := [1, or 2, or 3, or 4, etc...]

October 3, 2018		1
October 03, 2018	2
Oct 3, 2018			3
Oct 03, 2018		4
10/3/2018			5
10/3/18				6
10/03/2018			7
10/03/18			8
10-03-18			9
3 October, 2018		10
rapp
Posts: 7
Joined: 22 May 2019, 23:19

Re: Dragon custom voice command to change date format (and some extras)

03 Sep 2022, 07:09

wbm1113, thank you for your impressive post. You understand Dragon on a level that I do not. I have a number of AutoHotkey scripts that received variables passed from Dragon to the AutoHotkey script, as in the example provided below.

Command Name: Box <dictation>

Path = "C:\Program Files\AutoHotkey\AutoHotkey.exe /force " & Chr(34) & "Edit Selection.ahk" & Chr(34) & " " & Chr(34) & ListVar1 & Chr(34)

Shell (Path)

Are you aware of a way to access ListVar1 (or even the last recognized command text) without passing this variable? The reason I ask is that I would like to use Dragon Legal Anywhere, which only supports step-by-step commands rather than advanced scripting, to trigger a number of Autohotkey scripts that I have created, some of which pass variables to an Autohotkey script. I can trigger an AutoHotkey script, using step-by-step scripting, but I do not know how to access the ListVar1 variables or the last recognized command text. Any help would be appreciated.
Gio710
Posts: 31
Joined: 01 Mar 2022, 06:34

Re: Dragon custom voice command to change date format (and some extras)

08 Jun 2023, 05:17

Hi Guys,

I have a question slightly similar for which I cannot find an answer on forums so far.

I'm trying to change DgnEngineOptionConstants => dgnengoptionDoubleClickForCorrection, from within AHK. I can read it's value (-1 or 0 from AHK) but I cannot change it ! Can you help me change it from AHK ? Here is my script :

Code: Select all

dgnengoptionDoubleClickForCorrection := 17 ; 0x11 
dgnengoptionDoubleClickForCorrection_state := ""

DgnEngine:= ComObjCreate("Dragon.DgnEngineControl")
DgnEngine.Register(0)

dgnengoptionDoubleClickForCorrection_state := DgnEngine.Option(dgnengoptionDoubleClickForCorrection)
msgbox %dgnengoptionDoubleClickForCorrection_state%

DgnEngine.Option(dgnengoptionDoubleClickForCorrection) = not DgnEngine.Option(dgnengoptionDoubleClickForCorrection)
; DgnEngine.Option(dgnengoptionDoubleClickForCorrection) = 0

dgnengoptionDoubleClickForCorrection_state := DgnEngine.Option(dgnengoptionDoubleClickForCorrection)
msgbox %dgnengoptionDoubleClickForCorrection_state%

DgnEngine.Unregister(0)
ObjRelease(DgnEngine)
Gio710
Posts: 31
Joined: 01 Mar 2022, 06:34

Re: Dragon custom voice command to change date format (and some extras)

08 Jun 2023, 05:19

Ho, I found the answer rereading my own post

it must not be DgnEngine.Option(dgnengoptionDoubleClickForCorrection) = not DgnEngine.Option(dgnengoptionDoubleClickForCorrection)

it must be
DgnEngine.Option(dgnengoptionDoubleClickForCorrection) := not DgnEngine.Option(dgnengoptionDoubleClickForCorrection)

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: gwarble, manbat42, MiM and 70 guests