KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: simple command line application to run a DNS script
Topic Summary:
Created On: 07/15/2012 01:35 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 simple command line application to run a DNS script   - mdl - 07/15/2012 01:35 PM  
 simple command line application to run a DNS script   - mdl - 07/15/2012 01:40 PM  
 simple command line application to run a DNS script   - mdl - 07/15/2012 01:46 PM  
 simple command line application to run a DNS script   - monkey8 - 07/18/2012 09:11 AM  
 simple command line application to run a DNS script   - mdl - 07/18/2012 11:34 AM  
 simple command line application to run a DNS script   - monkey8 - 07/18/2012 07:24 PM  
 simple command line application to run a DNS script   - mdl - 07/18/2012 09:10 PM  
 simple command line application to run a DNS script   - monkey8 - 07/19/2012 08:02 AM  
 simple command line application to run a DNS script   - maxr - 07/22/2012 03:56 AM  
 simple command line application to run a DNS script   - mdl - 07/22/2012 01:20 PM  
 simple command line application to run a DNS script   - mdl - 07/25/2012 02:23 PM  
 simple command line application to run a DNS script   - R. Wilke - 07/25/2012 02:41 PM  
 simple command line application to run a DNS script   - mdl - 07/25/2012 08:56 PM  
 simple command line application to run a DNS script   - maxr - 07/25/2012 02:42 PM  
Keyword
 07/15/2012 01:35 PM
User is offline View Users Profile Print this message


mdl
Senior Member

Posts: 130
Joined: 04/18/2009

As an experiment, I tried playing with the DNS ActiveX controls using Visual Basic.  Here is a simple console application, Exec_Script.exe, that takes one or more DNS scripting commands and executes them via the DNSTools.DgnVoiceCmd control.  Sample invocation:

Exec_Script.exe "HeardWord ""open"", ""DragonPad"""

I assume it should be possible to use this plus say AutoHotkey to make keystrokes run DNS voice commands.  Note that this version does not wait for the script to finish, returning immediately.

I hope this will work with all editions of DNS, but if not please reply.

- Mark

 

 



Exec_Script.vb
Exec_Script.vb  (1 KB)
Exec_Script.exe
Exec_Script.exe  (13 KB)

 07/15/2012 01:40 PM
User is offline View Users Profile Print this message


mdl
Senior Member

Posts: 130
Joined: 04/18/2009

 

Below is the Visual Basic code for the application.  I used Visual Studio 2010 express (free); choose console application, and add a reference to Dragon NaturallySpeaking ActiveX controls (under project->add reference->Com for me).


Module Exec_Script

    Function Main(ByVal cmdArgs() As String) As Integer
        Dim Script As String
        Script = ""
        If cmdArgs.Length > 0 Then
            For argNum As Integer = 0 To UBound(cmdArgs, 1)
                Script = Script & vbCrLf & cmdArgs(argNum)
            Next argNum
        End If

        Dim control As DNSTools.DgnVoiceCmd
        control = New DNSTools.DgnVoiceCmd()

        control.Register("")

        Dim errLine As Long
        Dim errString As String
        errLine = control.CheckScript(Script, errString)
        If errLine <> 0 Then
            MsgBox("Error in script at command " & errLine - 1 & ": " & errString)
        Else
            control.ExecuteScript(Script, 0)
        End If

        control.UnRegister()

        Return errLine
    End Function

End Module

 07/15/2012 01:46 PM
User is offline View Users Profile Print this message


mdl
Senior Member

Posts: 130
Joined: 04/18/2009

I forgot to mention that you can sequence several script commands by passing multiple arguments like so:

Exec_Script.exe "Beep" "Wait 2000" "Beep"

(This is the DNS scripting language which predates and is somewhat incompatible with the more modern Advanced Scripting; in particular, wait takes microseconds rather than the modern seconds and SendKeys does what SendDragonKeys does today.  I believe KnowBrainer's verbal basic is using the same scripting language.)

 

 07/18/2012 09:11 AM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 1994
Joined: 01/14/2008

mdl,

What is the point of using a DgnVoiceCmd object to execute a script? We can execute scripts by a lot easier methods than that. Why don't you use it in the way it is meant to be used as an inbuilt Dragon command and not purely to execute a script.

DgnVoiceCmd.ExecuteScript is just a subsidiary method that may have its use on the odd occasion, it is not the method you use to implement inbuilt Dragon voice commands using the DgnVoiceCmd ActiveX/COM object.

Lindsay



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


www.pcbyvoice.com
www.pcbyvoice.co.uk

 07/18/2012 11:34 AM
User is offline View Users Profile Print this message


mdl
Senior Member

Posts: 130
Joined: 04/18/2009

is there a better way to execute a DNS voice command from the command line?  Please tell.

I believe when people asked in the past how to make a voice command run when a key was pressed, the consensus was that the only method was to buy a utility that no one knew how worked.

 

 07/18/2012 07:24 PM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 1994
Joined: 01/14/2008

Well it depends exactly what you want to do but if we take your exact example (using a DgnVoiceCmd) then yes there are better ways of implementing the commandline arguments. Using one commandline argument HeardWord is painfully slow and if you have a 50 line script having 50 commandline arguments, one for each line, is hardly practical.

Instead just use one commandline argument RunScriptFile which gives you the best of both worlds.

However my main point was that the DgnVoiceCmd is a far more powerful and flexible object when it isn't restricted to executing scripts, and yes there are other ways of executing script rather than using this object.

Lindsay



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


www.pcbyvoice.com
www.pcbyvoice.co.uk

 07/18/2012 09:10 PM
User is offline View Users Profile Print this message


mdl
Senior Member

Posts: 130
Joined: 04/18/2009

I think we are not disagreeing.  This was mostly an experiment, but I thought it might also be useful to the people that for whatever reason want to invoke one of their voice commands from the command line/via a keystroke.

 

 07/19/2012 08:02 AM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 1994
Joined: 01/14/2008

I think using the ActiveX/COM objects within an executable with commandline parameters could be a good idea in certain instances, it's just that ExecuteScript has so many restrictions. Like what to do if the script is an advanced script with 20+ lines and COM object library references e.g. Microsoft Word object library.

Also initially I thought you were just looking for ways to invoke voice commands using the various dragon API possibilities that you had discussed previously in your other thread, when in fact you were trying to do something more specific. You can't beat learning by doing, it's a never-ending process at least in my case.



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


www.pcbyvoice.com
www.pcbyvoice.co.uk



 07/22/2012 03:56 AM
User is offline View Users Profile Print this message


maxr
Senior Member

Posts: 113
Joined: 12/08/2009

Very handy utility mdl. I like it. Keep up the good work.

Max Roth
Dynamic Keyboard One for Naturally Speaking

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

ErgoArchitect Assistive Technologies - 

ShowNumbers Plus! Addon to Naturally Speaking - 

www.ergoarchitect.com 

 07/22/2012 01:20 PM
User is offline View Users Profile Print this message


mdl
Senior Member

Posts: 130
Joined: 04/18/2009

It worked for you?  Good.  I've only been able to test it on my Professional Edition.  I'm curious if it works on non-professional editions.

 07/25/2012 02:23 PM
User is offline View Users Profile Print this message


mdl
Senior Member

Posts: 130
Joined: 04/18/2009

I just tried Exec_script.exe on another computer that didn't have Visual Studio installed and apparently it needs .NET v4 or something like that installed to run.  Stupid Microsoft.  Can't even build a standalone executable correctly .  :-(  That said, if you want to try it, I'm sure installing .net is fairly trivial these days.

 

 07/25/2012 02:41 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 4393
Joined: 03/04/2007

Stupid Microsoft. Can't even build a standalone executable correctly.


Stupid programmer.

It all depends on how you build the setup project, in terms of project properties, and if you do it correctly, a missing .NET framework will be installed automatically. However, since you are using the Express Edition of Visual Studio, your chances are somewhat limited as far setup projects if I am not mistaken.

RĂ¼diger



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

Well, it's past the point where we can make any changes in the code, but we can still make changes to the Easter Egg!

 07/25/2012 08:56 PM
User is offline View Users Profile Print this message


mdl
Senior Member

Posts: 130
Joined: 04/18/2009

Touche.  That's good to know.  Can you tell I'm mostly a Unix programmer? :-)

 

 07/25/2012 02:42 PM
User is offline View Users Profile Print this message


maxr
Senior Member

Posts: 113
Joined: 12/08/2009

You are funny mdl. Crack me up! I haven't had a chance to give it a spin but it's on the todo list.

Max Roth
www.freesr.org

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

ErgoArchitect Assistive Technologies - 

ShowNumbers Plus! Addon to Naturally Speaking - 

www.ergoarchitect.com 

Statistics
27373 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 4 users logged in.
The most users ever online was 2028 on 04/05/2013 at 07:36 PM.
There are currently 99 guests browsing this forum, which makes a total of 103 users using this forum.

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