Announcement

Collapse
No announcement yet.

some com functions for Nuance Dragon using console utility

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • some com functions for Nuance Dragon using console utility

    For information on using Nuance Dragon COM, usually a file called "dnsapi.chm" is in the "help" directory near where the Nuance Dragon keeps their program files. This was my first COM program I did on my own without asking for help but used POFFS and PBROW.EXE program and I need some help on how to work with the COM techniques like these for a program that stays in memory. I am sure I would do it wrong on my own. But I am very tired now. It took me over a week to just find the file "dnsapi.chm" but I do not feel so bad. One guy on the internet looked for 2 years.

    com interface to check or change status (off/on/sleep plus pause and resume )of the microphone status in a running nuance dragon software state
    and a bonus to check if nuance dragon is loaded or not.

    Seems very fast with my testing and checked with versions Nunance Dragon Premium 12, Dragon Naturally Speaking 13 basic and Dragon Professional 15.

    Only a few more things to put in the program like testing if dragon is actually completely loaded and in a ready state.

    console utility exe in the zipped file

    Code:
    'dragnmic.bas
    'compiled with pbcc 6.04
    'program to check the status or change the status of a microphone for dragon software
    
    #COMPILE EXE "dragnmic.exe"
    #DIM ALL
    #BREAK ON
    #INCLUDE ONCE "WIN32API.INC"
    
    DECLARE FUNCTION EnumProcesses LIB "PSAPI.DLL" ALIAS "EnumProcesses" (lpidProcess AS DWORD, BYVAL cb AS DWORD, cbNeeded AS DWORD) AS LONG
    DECLARE FUNCTION EnumProcessModules LIB "PSAPI.DLL" ALIAS "EnumProcessModules" (BYVAL hProcess AS DWORD, lphModule AS DWORD, BYVAL cb AS DWORD, lpcbNeeded AS DWORD) AS LONG
    DECLARE FUNCTION GetModuleBaseName LIB "PSAPI.DLL" ALIAS "GetModuleBaseNameA" (BYVAL hProcess AS DWORD, BYVAL hModule AS DWORD, lpBaseName AS ASCIIZ, BYVAL nSize AS DWORD) AS DWORD
    
    
    ' Generated by: PowerBASIC COM Browser v.2.00.0081
    ' Date & Time : 6/21/2017 at 1:20 AM
    ' ------------------------------------------------
    ' Library Name: DNSTools
    ' Library File: C:\Program Files\Nuance\NaturallySpeaking12\Program\dnstk10.dll
    ' Description : Dragon NaturallySpeaking ActiveX Controls
    ' Help File : C:\Program Files\Nuance\NaturallySpeaking12\Help\dnsapi.chm
    ' Help Context : 0
    ' GUID : {5C486340-2F92-11D1-A47C-00A024A3A678}
    ' LCID : 0
    ' Version : 1.0
    
    ' DgnMicStateConstants enumeration
    '%DgnMicStateConstants_dgnmicDisabled = 0
    '%DgnMicStateConstants_dgnmicOff = 1
    '%DgnMicStateConstants_dgnmicOn = 2
    '%DgnMicStateConstants_dgnmicSleeping = 3
    '%DgnMicStateConstants_dgnmicPause = 4
    '%DgnMicStateConstants_dgnmicResume = 5
    
    
    ' Version Independent ProgIDs
    $PROGID_DNSTools_DgnMicBtn = "Dragon.MicBtn"
    ' Interface Identifiers
    $IID_DNSTools_IDgnMicBtn = GUID$("{12212BCA-F242-4168-A982-F083E4F94D86}")
     ' Interface Name  : IDgnMicBtn
    ' Description     : IDgnMicBtn Interface
    ' Class Name      : DgnMicBtn
    ' ClassID         : $CLSID_DNSTools_DgnMicBtn
    ' ProgID          : $PROGID_DNSTools_DgnMicBtn
    ' Version ProgID  : $PROGID_DNSTools_DgnMicBtn1
    INTERFACE IDgnMicBtn $IID_DNSTools_IDgnMicBtn
        INHERIT IDISPATCH
        PROPERTY GET Enabled <1> () AS INTEGER
        PROPERTY SET Enabled <1> (BYVAL Rhs AS INTEGER)
        PROPERTY GET MicState <2> () AS LONG
        PROPERTY SET MicState <2> (BYVAL Rhs AS LONG)
        PROPERTY GET VUMeterNotify <3> () AS INTEGER
        PROPERTY SET VUMeterNotify <3> (BYVAL Rhs AS INTEGER)
        PROPERTY GET AutoRegister <4> () AS INTEGER
        PROPERTY SET AutoRegister <4> (BYVAL Rhs AS INTEGER)
        METHOD REGISTER <5> (OPT BYVAL Flags AS VARIANT)
        METHOD UnRegister <6> ()
        PROPERTY GET Paused <7> () AS INTEGER
        METHOD WaveCaptureStart <8> (BYVAL WaveFilePath AS STRING)
        METHOD WaveCaptureStop <9> ()
        PROPERTY GET OPTION <10> (BYVAL PB_Option AS LONG) AS VARIANT
        PROPERTY SET OPTION <10> (BYVAL PB_Option AS LONG, BYVAL Value AS VARIANT)
    END INTERFACE
    
    
    
    'get the status of the dragon microphone
    'if there is error return -1
    FUNCTION microphonestatus() AS LONG
       LOCAL iresult AS LONG
    
         FUNCTION=-1
         LOCAL objvar AS IDgnMicBtn
         objvar = NEWCOM $PROGID_DNSTools_DgnMicBtn
         IF ISNOTHING( objvar ) OR ERR THEN
            '? "Object was not created 1"    'for testing only
            'WAITKEY$                        'for testing only
            EXIT FUNCTION
         END IF
         IF ISFALSE ISOBJECT( objvar ) THEN
            '? "Object was not created 2"   'for testing only
            'waitkey$                       'for testing only
            EXIT FUNCTION
         END IF
          objvar.REGISTER
          iresult=objvar.MicState()
          objvar.UnRegister
          '%DgnMicStateConstants_dgnmicDisabled = 0
          '%DgnMicStateConstants_dgnmicOff = 1
          '%DgnMicStateConstants_dgnmicOn = 2
          '%DgnMicStateConstants_dgnmicSleeping = 3
          '%DgnMicStateConstants_dgnmicPause = 4
          '%DgnMicStateConstants_dgnmicResume = 5
          FUNCTION=iresult
    END FUNCTION
    
    
    'change the status status of the dragon microphone
    'if there is error return -1
    
    FUNCTION microphonestatuschange(BYVAL ichangemicrophonestatus AS LONG) AS LONG
       LOCAL iresult AS LONG
    
         FUNCTION=-1
         IF ichangemicrophonestatus < 1 OR ichangemicrophonestatus > 5 THEN EXIT FUNCTION
         LOCAL objvar AS IDgnMicBtn
         objvar = NEWCOM $PROGID_DNSTools_DgnMicBtn
         IF ISNOTHING( objvar ) OR ERR THEN
            '? "Object was not created 1"    'for testing only
            'WAITKEY$                        'for testing only
            EXIT FUNCTION
         END IF
         IF ISFALSE ISOBJECT( objvar ) THEN
            '? "Object was not created 2"   'for testing only
            'waitkey$                       'for testing only
            EXIT FUNCTION
         END IF
          objvar.REGISTER
          objvar.MicState=ichangemicrophonestatus
         ' sleep 100
          iresult=objvar.MicState()
          objvar.UnRegister
          '%DgnMicStateConstants_dgnmicDisabled = 0
          '%DgnMicStateConstants_dgnmicOff = 1
          '%DgnMicStateConstants_dgnmicOn = 2
          '%DgnMicStateConstants_dgnmicSleeping = 3
          '%DgnMicStateConstants_dgnmicPause = 4
          '%DgnMicStateConstants_dgnmicResume = 5
          IF iresult=ichangemicrophonestatus THEN FUNCTION=iresult
          IF ichangemicrophonestatus>3  THEN FUNCTION=ichangemicrophonestatus
    END FUNCTION
    
    FUNCTION PBMAIN () AS LONG
      LOCAL iresult AS LONG
      LOCAL istatus AS LONG
      LOCAL scommandline AS STRING
    
        scommandline=LCASE$(TRIM$(COMMAND$))
        IF LEN(scommandline)=0 OR scommandline="?" OR scommandline="/?" OR _
             scommandline="/help" OR  scommandline="help" THEN
            PRINT  "This program can return or set the status of the microphone"
            PRINT  "in nuance dragon software provided it is running."
            PRINT  "Using the word STATUS on the command tail will retrieve"
            PRINT  "the current status of the microphone."
            PRINT  "To change the status use a single word from"
            PRINT  "OFF ON SLEEP PAUSE RESUMED."
            PRINT  "Changing the status to DISABLED is not allowed"
            PRINT  "For each time you pause the micophone you must use"
            PRINT  "a matching resume. So you are now warned. Pause will"
            PRINT  "pause the microphone in its current on/off/sleeping state"
            PRINT  "Pausing is for uses like when loading a user profile."
            PRINT  "Returned values are:"
            PRINT  "0 for a successful change in status"
            PRINT  "1 microphone status is disabled"
            PRINT  "2 microphone status is off"
            PRINT  "3 microphone status is on"
            PRINT  "4 microphone status is sleeping"
            PRINT  "5 an unknown error occurr"
            PRINT  "7
            PRINT  "8 dragon software natspeak.exe is not running"
            PRINT  "9 bad input on the command line"
            PRINT  "10 help shown"
            PRINT  "If the word LOADED is used the return values will be"
            PRINT  "0 for a natspeak.exe is loaded in memory"
            PRINT  "1 for a natspeak.exe is not loaded in memory"
            PRINT  "If the word READY is used the return values will be"
            PRINT  "0 for a natspeak.exe is loaded and ready"
            PRINT  "1 for a natspeak.exe is not ready."
            PRINT  "READY is a future function not working now"
            FUNCTION=10
            EXIT FUNCTION
        END IF
    
        IF INSTR(scommandline,"load")>0 THEN
            IF isnatspeakexerunning=0 THEN
                FUNCTION=1
                ELSE
                FUNCTION=0
            END IF
            EXIT FUNCTION
        END IF
    
        IF INSTR(scommandline,"status")>0 THEN
            IF isnatspeakexerunning=0 THEN FUNCTION=8:EXIT FUNCTION
            iresult=microphonestatus
            IF iresult=-1 THEN FUNCTION=5:EXIT FUNCTION
            FUNCTION=iresult+1
            EXIT FUNCTION
        END IF
        istatus=10
       ' IF INSTR(scommandline,"disabled") THEN istatus=0   'this program cannot enable so disabling is not allowed
        IF scommandline="off" THEN istatus=1
        IF scommandline="on" THEN istatus=2
        IF INSTR(scommandline,"sleep") THEN istatus=3
        IF INSTR(scommandline,"pause") THEN istatus=4
        IF INSTR(scommandline,"resume") THEN istatus=5
    
        IF istatus=10 THEN FUNCTION=9:EXIT FUNCTION
        IF isnatspeakexerunning=0 THEN FUNCTION=8:EXIT FUNCTION
        iresult=microphonestatuschange(istatus)
        ' stdout str$(iresult)    'for testing only
        IF iresult=-1 THEN FUNCTION=5:EXIT FUNCTION
        IF istatus>4 THEN FUNCTION=0:EXIT FUNCTION
        IF istatus=iresult THEN FUNCTION=0:EXIT FUNCTION
    END FUNCTION
    
    
    
    FUNCTION isnatspeakexerunning() AS LONG
        LOCAL i              AS LONG
        LOCAL  cbNeeded       AS DWORD
        LOCAL  cProcesses     AS DWORD
        LOCAL szProcessName   AS ASCIIZ * %MAX_PATH
        LOCAL sProcessNameToCompare     AS STRING
        LOCAL sProcessNameSearchedFor   AS STRING
        LOCAL  hProcess        AS DWORD
        LOCAL  hMod            AS DWORD
        LOCAL szTHisProcessName AS ASCIIZ * %MAX_PATH
        DIM  aProcesses(4096) AS DWORD
    
        sProcessNameSearchedFor="natspeak.exe"
        IF ISFALSE EnumProcesses(aProcesses(LBOUND(aProcesses)), (UBOUND(aProcesses) - LBOUND(aProcesses) + 1) * 4, cbNeeded) THEN EXIT FUNCTION
        cProcesses = cbNeeded \ 4
        FOR i = 0 TO cProcesses - 1 'get info for each process
            IF aProcesses(i)=0 THEN ITERATE
            CALL OpenProcess(%PROCESS_QUERY_INFORMATION OR %PROCESS_VM_READ, %FALSE, aProcesses(i)) TO hProcess
            IF ISFALSE hProcess THEN  ITERATE
            IF ISFALSE EnumProcessModules(hProcess, hMod, SIZEOF(hMod), cbNeeded) THEN  CloseHandle hProcess:ITERATE
            CALL GetModuleBaseName(hProcess, hMod, szProcessName, SIZEOF(szProcessName))
            CloseHandle hProcess
            sProcessNameToCompare=LCASE$(TRIM$(szProcessName))
            WHILE INSTR(sProcessNameToCompare,"  ")
                  REPLACE " " WITH ""  IN sProcessNameToCompare
            WEND
            IF sProcessNameToCompare=sProcessNameSearchedFor THEN
               FUNCTION=1
               EXIT FUNCTION
            END IF
        NEXT
    END FUNCTION
    Attached Files
    Last edited by Paul Purvis; 21 Jun 2017, 06:44 PM.
    p purvis

  • #2
    oops i made an error in providing the wrong code listing and the wrong bas file in the zipped file.
    It was an earlier version that i had been working from and i add numbers to the end of the file to as i am working through code.
    but the good news is the exe was correct.

    also in testing, i am seeing some speed issues on an intel atom processor, it has to do with the com object and when the program exists or something like that.
    i will get to the bottom of it, just unnecessary work to do.
    p purvis

    Comment


    • #3
      Well on an Intel Compute stick with win 10 I have 2 systems almost identical but I have Dragon naturally speaking basic version 13 where the program is wet very slow to exit but I have Dragon professional
      15 on the other similar machine the program does not exhibit any issues at all. I did uninstall Draon 13 and cleaned up everything I could and reinstalled but the issue is still there. I think my proble is Dragon basic 13 and I have not tried and releases of 13 but worth noting. The machine with draon professional 15 was updated from a fresh installed Dragon basics verion 13. I will report back.
      p purvis

      Comment


      • #4
        Hey Paul!

        I'm not clear on what you've done ...

        Are you saying that you installed Dragon 15 - an application - and was able to access its functionality via COM code?

        Or, did you purchase the Nuance SDK product and are accessing functionality through its API?

        Or none of the above?

        Comment


        • #5
          Gary. Choice 1.
          I need to control the microphone status.

          The above console program started out as a simple program just for testing if I could control the microphone and put it through some test. I had first used sendkeys to control the microphone status and watched some Dragon active window controls but it was not very clean.

          What I am working toward is a GUI program that monitors a CUI program and when needed, the GUI
          program will make itself available for easier speech to text input in a text box of the GUI. After input is made either by speech or typed or both. I will use sendkeys to fill the CUI multiline input.
          One unique purpose that I need is to have users document information in a CUI program rather than them writting the information on the back of ledger cards. Simply put. Many people cannot type well and write even worst. Hopefully the information gathered will be more detailed also with speech to text in a 16 bit program.

          I was able to use some function calls to a DLL file of dragon's but that turned out not well at all when I got to hammering the program and natspeak.exe would end up with 2 instances and a functional main window that I could not get to reappear.
          The problem I have not worked out yet is only a problem when the program exits in the above code.
          I don't know what problems will be in my final code of the unique GUI will have.
          Dragon does come with a nice Dictation Box for such programs but it could be better and by far with a customized GUI.
          My code above was just to hopefully give others a heads up on what I was able to do consoling a microphone and showing it could be done.

          p purvis

          Comment


          • #6
            Got some work done on changing dragon micophone status some thing many of you might like but it is not yet refined for my standards.
            It is very slow due to my knowledge of object and methods and such and very little info to go on interacting with dragon..
            This is some code work that this a build block to some of my needs.
            I have some good questions for a lot of things i am doing and i know many of you have answers or can lead me and i do need leading.
            Here is a program that is designed to stay in memory and the dialog will hide itself away when dragon is not loaded or at least the dragonbar dialog/window is not being shown.
            Now to test if dragon is running i just check a window class named DgnBarMainWindowCls if that is how it is described. It is tough just to come up with the terminology for the lesser skilled people in dialog programing like my self. I know the code looks ruff but you might just like the program. You can close the program by right clicking on the title bar or from the taskbar.
            If dragon gets unloaded, then this program tries to beat it to closing, if not, the main natspeak.exe stay running. I am trying to learn how to create an object that can be called run globally across many functions.
            Anyways, if you exit dragon and this program is not fast enough to exit out and close the objects, you are left with natspeak.exe running in the background that almost requires some kill exe function and it can really be called a feature as Michael would put it.
            So if this program is running and you exit dragon, the dialog will close all out, maybe not so pretty, and the program will exit dialog and sit in the PBmain looping until dragon is loaded again and hopefully it is start up like new. I have seen problems with the number handles growing but i think that might of been worked out. Time testing will tell.
            I have seen other code from the forum I want to include in this program like keeping the position of the dialog on the screen upon next time the program is ran from the very start but in the loop of the Pbmain to reload the dialog, i do keep the last position of the previous same loaded dialog.
            This program has a very skinny dialog and i am using labels in place of buttons. i will describe some of my issues after this posting for some help. Check out the zipped files. Just saying.
            I am going to work a wider dialog and a dialog that is more horizontal that vertical. The vertical dialog is to allow micophone status changes to be placed near other windows rather than places a lot of people do not perfer.

            This program loads the dialog always on top and to far right roughly have way down a screen and i do not day any match to put it there.
            You put the x,y screen coordinates on the command line using 2 separate numbers for a starting place you like. There is no help.
            I use a timer to check for the status of the microphone and other information and it is set at 400 msec which seems fine. I did not want hog the processor and i do not use any threads. It seems getting the program to just do what is needed is hard enough. It would be nice to know when a profile is not loaded dragon and i have not found a way to get that yet from vague info.
            I think most of you might like what i have so far, and it is not perfect. But i do need some people to really give this program a go and i will post a couple of variations of this program in dialog dimensions.
            I would like to be able to change dictation modes and hopefully that will come too.
            I want to warn others that if you look at the messages being placed it the DgnBarMainWindowCls dialog window, by which you can turn it off and on with setting in the Dragon program.
            It is very difficult to absolutely figure out what the microphone status, dictation mode, and what statuses Dragon is actually in. You can enumerate though the messages to get that though quit easily and i will show the code in my next posting. During testing, it seems that dragon professional 15 is much more stable about providing more predictable messages based on the status of what dragon is in.

            Code:
            'drgnbutn.bas
            'compiled with pbwin10 version 10.04
            'program to change and monitor the dragon naturally speaking microphone setting while
            'the dragonbar window is running from the natspeak.exe program of dragon
            'tested on dragon 12, 13, and 15
            'retrieved COM information using the powerbasic pbrow program
            
            
            #COMPILE EXE "drgnbutn.exe"
            #DIM ALL
            
            #INCLUDE ONCE "WIN32API.INC"
            
            
            DECLARE FUNCTION EnumProcesses LIB "PSAPI.DLL" ALIAS "EnumProcesses" (lpidProcess AS DWORD, BYVAL cb AS DWORD, cbNeeded AS DWORD) AS LONG
            DECLARE FUNCTION EnumProcessModules LIB "PSAPI.DLL" ALIAS "EnumProcessModules" (BYVAL hProcess AS DWORD, lphModule AS DWORD, BYVAL cb AS DWORD, lpcbNeeded AS DWORD) AS LONG
            DECLARE FUNCTION GetModuleBaseName LIB "PSAPI.DLL" ALIAS "GetModuleBaseNameA" (BYVAL hProcess AS DWORD, BYVAL hModule AS DWORD, lpBaseName AS ASCIIZ, BYVAL nSize AS DWORD) AS DWORD
            
            %IDD_DIALOG1 =  101
            %IDC_LABEL1 = 1001
            %IDC_LABEL2= 1002
            %IDC_LABEL3  = 1004
            
            GLOBAL ghDLG AS DWORD
            GLOBAL gimicrophonestatus AS LONG
            GLOBAL gimicrophonestatusprior AS LONG
            GLOBAL gidragonenginerunning AS LONG
            GLOBAL gidragonenginerunningprior AS LONG
            'removed code
            '=============================================================================
            'GLOBAL gidragonexerunning AS LONG
            'GLOBAL gidragonexerunningprior AS LONG
            '=============================================================================
            GLOBAL gidragonbarrunning AS LONG
            GLOBAL gidragonbarrunningprior AS LONG
            GLOBAL giwindowhandleprior AS DWORD
            GLOBAL giregistered_IDgnMicBtn AS LONG
            GLOBAL girunprogramagain AS LONG
            GLOBAL g_windowstartcolumn AS LONG
            GLOBAL g_windowstartrow AS LONG
            GLOBAL gidragonbarfound AS LONG
            GLOBAL gichangingmicstatusinprocess AS LONG
            
            
            
            GLOBAL  glRes  AS LONG
            GLOBAL  gbResult  AS LONG
            GLOBAL  gszClass AS ASCIIZ  *  %MAX_PATH
            
            
            GLOBAL  objvar_IDgnMicBtn AS IDgnMicBtn
            GLOBAL  objvar_IDgnEngineControlW AS  IDgnEngineControlW
            
            
            ' Version Independent ProgIDs
            $PROGID_DNSTools_DgnMicBtn = "Dragon.MicBtn"
            $PROGID_DNSTools_DgnEngineControl = "Dragon.DgnEngineControl"
            
            ' Class Identifiers
            $CLSID_DNSTools_DgnEngineControl = GUID$("{DE2DB781-BE83-11D1-A572-006008AAC4E2}")
            
            ' Interface Identifiers
            $IID_DNSTools_IDgnMicBtn = GUID$("{12212BCA-F242-4168-A982-F083E4F94D86}")
            $IID_DNSTools_IDgnEngineControlW = GUID$("{F16BE28E-D738-4E66-9807-1C89B4391589}")
            
            
            ' Interface Name  : IDgnEngineControlW
            ' Class Name      : DgnEngineControl
            ' ClassID         : $CLSID_DNSTools_DgnEngineControl
            ' ProgID          : $PROGID_DNSTools_DgnEngineControl
            ' Version ProgID  : $PROGID_DNSTools_DgnEngineControl1
            ' This Interface cannot be created directly it can only
            ' be returned by a Method or Property in this library.
            INTERFACE IDgnEngineControlW $IID_DNSTools_IDgnEngineControlW
                INHERIT IUNKNOWN
            
                METHOD BaseSpeakerModelsGet(BYREF ppModels AS WSTRINGZ, BYREF pdwSize AS DWORD) AS LONG
                METHOD BaseTopicModelsGet(BYREF ppModels AS WSTRINGZ, BYREF pdwSize AS DWORD) AS LONG
                METHOD EngineVersionGet(BYREF INOUT psMajorNum AS INTEGER, BYREF INOUT psMinorNum AS INTEGER, BYREF INOUT psBuildNum AS _
                    INTEGER) AS LONG
                METHOD ToolsVersionGet(BYREF INOUT psMajorNum AS INTEGER, BYREF INOUT psMinorNum AS INTEGER, BYREF INOUT psBuildNum AS _
                    INTEGER) AS LONG
                METHOD WindowModuleFileNameGet(BYVAL hWnd AS DWORD, BYREF ppszFileName AS WSTRINGZ) AS LONG
                METHOD GlobalDictationGet(BYVAL hWndApp AS DWORD, BYREF INOUT pbEnabled AS LONG) AS LONG
                METHOD GlobalDictationSet(BYVAL hWndApp AS DWORD, BYVAL bEnabled AS LONG) AS LONG
                METHOD REGISTER(BYVAL dwFlags AS DWORD, BYREF IN riid AS GUID, BYVAL pNotifySinkUnk AS IUNKNOWN) AS LONG
                METHOD SpeakerCreate(BYREF IN pszSpeakerName AS WSTRINGZ, BYREF IN pszSpeakerBasedOn AS WSTRINGZ) AS LONG
                METHOD SpeakerModifiedGet(BYREF INOUT pbModified AS LONG) AS LONG
                METHOD SpeakerTopicSelect(BYREF IN pszSpeaker AS WSTRINGZ, BYREF IN pszTopic AS WSTRINGZ) AS LONG
                METHOD TopicCreate(BYREF IN pszSpeaker AS WSTRINGZ, BYREF IN pszTopic AS WSTRINGZ, BYREF IN pszTopicBasedOn AS WSTRINGZ) _
                    AS LONG
                METHOD TopicDelete(BYREF IN pszReserved AS WSTRINGZ, BYREF IN pszTopic AS WSTRINGZ) AS LONG
                METHOD TopicGet(BYREF ppTopic AS WSTRINGZ) AS LONG
                METHOD TopicSet(BYREF IN pszTopic AS WSTRINGZ) AS LONG
                METHOD TopicsGet(BYREF IN pszSpeaker AS WSTRINGZ, BYREF ppTopics AS WSTRINGZ, BYREF pdwSize AS DWORD) AS LONG
                METHOD UnRegister(BYVAL bLockServer AS LONG) AS LONG
                METHOD EngineUIGet(BYREF INOUT pEngineUI AS LONG) AS LONG
                METHOD EngineUISet(BYVAL EngineUI AS LONG) AS LONG
                METHOD RecognitionMimic(BYVAL dwNumWords AS DWORD, BYREF IN pWords AS WSTRINGZ, BYVAL dwSize AS DWORD, BYVAL dwParam AS _
                    DWORD) AS LONG
                METHOD ISRCentralGet(BYREF INOUT ppUnk AS IUNKNOWN) AS LONG
                METHOD SpeakerTrainedGet(BYVAL dwReserved AS DWORD, BYREF INOUT pbTrained AS LONG) AS LONG
                METHOD EngineRunningGet(BYREF INOUT pbRunning AS LONG) AS LONG
                METHOD LanguagesGet(BYREF ppLangs AS DWORD, BYREF pdwSize AS DWORD) AS LONG
                METHOD SpeakerLanguageGet(BYREF IN pszSpeaker AS WSTRINGZ, BYREF INOUT pLang AS LONG) AS LONG
                METHOD BaseSpeakerModelLanguageGet(BYREF IN pszBaseSpeakerModel AS WSTRINGZ, BYREF INOUT pLang AS LONG) AS LONG
                METHOD BaseTopicModelLanguageGet(BYREF IN pszBaseTopicModel AS WSTRINGZ, BYREF INOUT pLang AS LONG) AS LONG
                METHOD AudioSetupCompleteGet(BYREF INOUT pbComplete AS LONG) AS LONG
                METHOD SpeakerCalibratedGet(BYREF INOUT pbCalibrated AS LONG) AS LONG
            END INTERFACE
            
            ' Interface Name  : IDgnMicBtn
            ' Description     : IDgnMicBtn Interface
            ' Class Name      : DgnMicBtn
            ' ClassID         : $CLSID_DNSTools_DgnMicBtn
            ' ProgID          : $PROGID_DNSTools_DgnMicBtn
            ' Version ProgID  : $PROGID_DNSTools_DgnMicBtn1
            INTERFACE IDgnMicBtn $IID_DNSTools_IDgnMicBtn
                INHERIT IDISPATCH
            
                PROPERTY GET Enabled <1> () AS INTEGER
                PROPERTY SET Enabled <1> (BYVAL Rhs AS INTEGER)
                PROPERTY GET MicState <2> () AS LONG
                PROPERTY SET MicState <2> (BYVAL Rhs AS LONG)
                PROPERTY GET VUMeterNotify <3> () AS INTEGER
                PROPERTY SET VUMeterNotify <3> (BYVAL Rhs AS INTEGER)
                PROPERTY GET AutoRegister <4> () AS INTEGER
                PROPERTY SET AutoRegister <4> (BYVAL Rhs AS INTEGER)
                METHOD REGISTER <5> (OPT BYVAL Flags AS VARIANT)
                METHOD UnRegister <6> ()
                PROPERTY GET Paused <7> () AS INTEGER
                METHOD WaveCaptureStart <8> (BYVAL WaveFilePath AS STRING)
                METHOD WaveCaptureStop <9> ()
                PROPERTY GET OPTION <10> (BYVAL PB_Option AS LONG) AS VARIANT
                PROPERTY SET OPTION <10> (BYVAL PB_Option AS LONG, BYVAL Value AS VARIANT)
            END INTERFACE
                  'for both property MicState above
                  '%DgnMicStateConstants_dgnmicOff = 1
                  '%DgnMicStateConstants_dgnmicOn = 2
                  '%DgnMicStateConstants_dgnmicSleeping = 3
            
            
            DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
            DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
            
            FUNCTION PBMAIN()
               'Gary Beene's instance checker
               IF InstanceTest = 0 THEN EXIT FUNCTION
                setwindowdimensions
               IF isDragonBarActive THEN GOTO LETSRUNTHEPROGRAMAGAIN_GOAROUND
                WHILE isDragonBarActive=0
                 SLEEP 15000
                WEND
            
            LETSRUNTHEPROGRAMAGAIN:
                WHILE isDragonBarActive=0
                 SLEEP 8000
                WEND
            
            LETSRUNTHEPROGRAMAGAIN_GOAROUND:
                ghDlg=0
                gimicrophonestatus=0
                gidragonenginerunning=0
                gidragonbarrunning=0
                gidragonbarrunningprior=-1
                giwindowhandleprior=0
            'removed code
            '=============================================================================
            '    gidragonexerunning=0
            '    gidragonexerunningprior=-1
            '=============================================================================
                gimicrophonestatusprior=-1
                gidragonenginerunningprior=-1
                gimicrophonestatusprior=-1
                giregistered_IDgnMicBtn=0
                girunprogramagain=0
                gidragonbarfound=0
            
                ShowDIALOG1 %HWND_DESKTOP
                IF girunprogramagain THEN 'continue the program if dragon was close before this program manually closed
                    SLEEP 25000
                    GOTO LETSRUNTHEPROGRAMAGAIN
                END IF
            
            
            END FUNCTION
            
            CALLBACK FUNCTION ShowDIALOG1Proc()
            STATIC hTimer AS LONG
            
                SELECT CASE AS LONG CB.MSG
                    CASE %WM_INITDIALOG
                        ' Initialization handler
                        DIALOG HIDE CB.HNDL   'hide the dialog to start
                        DIALOG SET COLOR CB.HNDL, %RGB_DODGERBLUE,  %RGB_DODGERBLUE
                        CONTROL SET COLOR CB.HNDL, %IDC_LABEL1, %RGB_WHITE, %RGB_BLACK
                        CONTROL SET COLOR CB.HNDL, %IDC_LABEL2, %RGB_BLACK, %RGB_SANDYBROWN
                        SetWindowPos ghDlg, %HWND_TOPMOST, 0,0,0,0, %SWP_NOMOVE OR %SWP_NOSIZE  'set the dialog to always on top
                        hTimer = SetTimer( CB.HNDL, 1, 400, CODEPTR(TimerProc) )
                        CONTROL SET COLOR CB.HNDL, %IDC_LABEL3, %RGB_BLACK, %RGB_BLACK
            
            
                    CASE %WM_NCACTIVATE
                        STATIC hWndSaveFocus AS DWORD
                        IF ISFALSE CB.WPARAM THEN
                            ' Save control focus
                            hWndSaveFocus = GetFocus()
                        ELSEIF hWndSaveFocus THEN
                            ' Restore control focus
                            SetFocus(hWndSaveFocus)
                            hWndSaveFocus = 0
                        END IF
                  CASE %WM_USER + 996
                         KillTimer CB.HNDL, hTimer
                         removeobjectsfordragon
                         girunprogramagain=1
                         DIALOG GET LOC CB.HNDL TO g_windowstartcolumn,g_windowstartrow
                         DIALOG END CB.HNDL
                         FUNCTION = 1
            
                   CASE %WM_DESTROY
                        KillTimer CB.HNDL, hTimer
                        removeobjectsfordragon
                         FUNCTION =1
            
                    CASE %WM_COMMAND
                        ' Process control notifications
            
                        SELECT CASE AS LONG CB.CTL
                            CASE %IDC_LABEL1
                                IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                    setpreviouswindowhandleactive
                                    gichangingmicstatusinprocess=1
                                    togglemicophoneonoff
                                    gichangingmicstatusinprocess=0
                                END IF
            
                            CASE %IDC_LABEL2
                                IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                    setpreviouswindowhandleactive
                                    gichangingmicstatusinprocess=1
                                    microphonetosleep
                                    gichangingmicstatusinprocess=0
                                END IF
                            CASE %IDC_LABEL3
                                IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                    setpreviouswindowhandleactive
                                    DIALOG MINIMIZE ghDlg
                               END IF
            
                        END SELECT
                END SELECT
            END FUNCTION
            FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                LOCAL lRslt AS LONG
                LOCAL hFont1 AS DWORD
                LOCAL hDlg  AS DWORD
                DIALOG NEW hParent, "Mic-", g_windowstartcolumn,g_windowstartrow, 12, 74, %WS_POPUP OR %WS_BORDER _
                    OR %WS_DLGFRAME OR %WS_SYSMENU OR _   ' %WS_MINIMIZEBOX _
                    %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
                    %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
                    OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "Off", 0, 17, 12, 24,_
                     %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR  %SS_CENTER OR %SS_CENTERIMAGE, %WS_EX_LEFT OR _
                     %WS_EX_LTRREADING
                CONTROL ADD LABEL, hDlg, %IDC_LABEL2, "Nap", 0, 47, 12, 24,_
                     %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_CENTERIMAGE,  %WS_EX_LEFT OR _
                     %WS_EX_LTRREADING
            
                CONTROL ADD LABEL,  hDlg, %IDC_LABEL3, "", 0, 0, 12, 14, _
                     %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_LEFT, %WS_EX_LEFT OR _
                     %WS_EX_LTRREADING
            
                FONT NEW "Arial", 7, 1, %ANSI_CHARSET TO hFont1
                CONTROL SET FONT hDlg, %IDC_LABEL1, hFont1
                CONTROL SET FONT hDlg, %IDC_LABEL2, hFont1
            
                ghDlg=hDlg
                DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
            
                 FONT END hFont1
                FUNCTION = lRslt
            END FUNCTION
            
            
            FUNCTION TimerProc( BYVAL hDlg AS LONG, BYVAL Msg AS LONG, BYVAL EvntID AS LONG, BYVAL Time AS LONG ) AS LONG
              STATIC idwresult AS DWORD
                idwresult=GetForeGroundWindow
                IF idwresult<>ghdlg THEN giwindowhandleprior=idwresult
                IF gichangingmicstatusinprocess THEN EXIT FUNCTION
            
            'removed code
            '=============================================================================
            '    gidragonexerunning=isnatspeakexerunning
            '    IF gidragonexerunning THEN
            '        IF gidragonexerunning<>gidragonexerunningprior THEN
            '               gidragonexerunningprior=1
            '               DIALOG NORMALIZE ghDlg
            '        END IF
            '    ELSE
            '       IF gidragonexerunningprior=gidragonexerunning THEN EXIT FUNCTION
            '       gidragonexerunningprior=0
            '       CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_BLACK
            '       DIALOG HIDE ghDlg
            '       EXIT FUNCTION
            '    END IF
            '=============================================================================
            
                gidragonbarrunning=isDragonBarActive
                IF gidragonbarrunning THEN
                    IF gidragonbarrunning<>gidragonbarrunningprior THEN
                           gidragonbarrunningprior=1
                           DIALOG NORMALIZE ghDlg
                    END IF
                ELSE
                   IF gidragonbarrunningprior=gidragonbarrunning THEN EXIT FUNCTION
                   gidragonbarrunningprior=0
                   CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_BLACK
                   DIALOG HIDE ghDlg
                   DIALOG POST ghDlg, %WM_USER+996,0,0
                   EXIT FUNCTION
                END IF
            
            
            
                 IF ISFALSE ISOBJECT( objvar_IDgnEngineControlW ) THEN
                      objvar_IDgnEngineControlW = NEWCOM $PROGID_DNSTools_DgnEngineControl
                 END IF
                objvar_IDgnEngineControlW.EngineRunningGet(gidragonenginerunning)
                IF gidragonenginerunning<>gidragonenginerunningprior THEN
                    IF gidragonenginerunning THEN
                       gidragonenginerunningprior=1
                       DIALOG NORMALIZE ghDlg
                    ELSE
                       gidragonenginerunningprior=0
                       DIALOG HIDE ghDlg
                       CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_BLACK
                       EXIT FUNCTION
                    END IF
                END IF
                gimicrophonestatus=dragonmicrophonebtncontrol(0,0)
                IF gimicrophonestatusprior=gimicrophonestatus THEN EXIT FUNCTION
                gimicrophonestatusprior=gimicrophonestatus
            
                SELECT CASE gimicrophonestatus
                    CASE 1
                        DIALOG SET TEXT ghDlg, "Mic-Off"
                        CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_RED, %RGB_RED
                        CONTROL SET TEXT  ghDlg, %IDC_LABEL1, "On"
                        CONTROL SET TEXT  ghDlg, %IDC_LABEL2, "Nap"
                    CASE 2
                        DIALOG SET TEXT ghDlg, "Mic-On"
                        CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_LIME, %RGB_LIME
                        CONTROL SET TEXT  ghDlg, %IDC_LABEL1, "Off"
                        CONTROL SET TEXT  ghDlg, %IDC_LABEL2, "Nap"
                    CASE 3
                        DIALOG SET TEXT ghDlg, "Mic-Asleep"
                        CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_YELLOW, %RGB_YELLOW '%RGB_SANDYBROWN
                        CONTROL SET TEXT  ghDlg, %IDC_LABEL2, "On"
                        CONTROL SET TEXT  ghDlg, %IDC_LABEL1, "Off"
            
                    CASE ELSE
                        DIALOG SET TEXT ghDlg, "Mic-"
                       CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_WHITE
                       CONTROL SET TEXT  ghDlg, %IDC_LABEL1, ""
                       CONTROL SET TEXT  ghDlg, %IDC_LABEL2, ""
            
                END SELECT
                 'DIALOG REDRAW ghDlg
                 CONTROL REDRAW   ghDlg, %IDC_LABEL1
                 CONTROL REDRAW   ghDlg, %IDC_LABEL2
                 CONTROL REDRAW   ghDlg, %IDC_LABEL3
            END FUNCTION 'TimerProc
            
            'removed code
            '=============================================================================
            'FUNCTION isnatspeakexerunning() AS LONG
            '    DIM aProcesses(4096) AS DWORD
            '    STATIC cbNeeded       AS DWORD
            '    STATIC cProcesses     AS DWORD
            '    STATIC i              AS LONG
            '    STATIC szProcessName   AS ASCIIZ * %MAX_PATH
            '    STATIC  hProcess        AS DWORD
            '    STATIC hMod            AS DWORD
            '
            '    IF ISFALSE EnumProcesses(aProcesses(LBOUND(aProcesses)), (UBOUND(aProcesses) - LBOUND(aProcesses) + 1) * 4, cbNeeded) THEN EXIT FUNCTION
            '    cProcesses = cbNeeded \ 4
            '    FOR i = 0 TO cProcesses - 1 'get info for each process
            '         IF aProcesses(i)=0 THEN ITERATE
            '        CALL OpenProcess(%PROCESS_QUERY_INFORMATION OR %PROCESS_VM_READ, %FALSE, aProcesses(i)) TO hProcess
            '        IF ISFALSE hProcess THEN ITERATE
            '        IF ISFALSE EnumProcessModules(hProcess, hMod, SIZEOF(hMod), cbNeeded) THEN  CALL CloseHandle(hProcess):ITERATE
            '        CALL GetModuleBaseName(hProcess, hMod, szProcessName, SIZEOF(szProcessName))
            '        CALL CloseHandle(hProcess)
            '        IF LCASE$(szProcessName)="natspeak.exe"  THEN FUNCTION=1 :EXIT FOR
            '  '      IF LCASE$(szProcessName)="dragonbar.exe" THEN FUNCTION=1 :EXIT FOR
            '    NEXT
            'END FUNCTION
            '=============================================================================
            
            FUNCTION dragonmicrophonebtncontrol(BYVAL itodo AS LONG,BYVAL imicphonechangestate AS LONG) AS LONG
            'if itodo equal 0 then return the state of the microphone
            'if itodo equal 1 then change the state of the microphone him him him him him him
               STATIC iregistered AS LONG
               LOCAL iresult AS LONG
                 FUNCTION=-1
                 IF ISFALSE ISOBJECT( objvar_IDgnMicBtn ) THEN
                          objvar_IDgnMicBtn = NEWCOM $PROGID_DNSTools_DgnMicBtn
                   END IF
                 IF ISNOTHING( objvar_IDgnMicBtn ) OR ERR THEN
                    EXIT FUNCTION
                 END IF
                 IF ISFALSE ISOBJECT( objvar_IDgnMicBtn ) THEN
                    EXIT FUNCTION
                 END IF
                 IF ISFALSE giregistered_IDgnMicBtn THEN
                      objvar_IDgnMicBtn.REGISTER
                      giregistered_IDgnMicBtn=1
                 END IF
            
                 SELECT CASE itodo
                     CASE 0
                       iresult=objvar_IDgnMicBtn.MicState()
                     CASE 1
                       objvar_IDgnMicBtn.MicState=imicphonechangestate
                       iresult=imicphonechangestate
                 END SELECT
             '     objvar_IDgnMicBtn.UnRegister
                  '%DgnMicStateConstants_dgnmicOff = 1
                  '%DgnMicStateConstants_dgnmicOn = 2
                  '%DgnMicStateConstants_dgnmicSleeping = 3
                  FUNCTION=iresult
            END FUNCTION
            
            
            FUNCTION togglemicophoneonoff() AS LONG
                CONTROL DISABLE ghDlg, %IDC_LABEL1
                CONTROL REDRAW  ghDlg, %IDC_LABEL1
                CONTROL DISABLE ghDlg, %IDC_LABEL2
                CONTROL REDRAW  ghDlg, %IDC_LABEL2
                IF microphoneready THEN
                   IF dragonmicrophonebtncontrol(0,0)<>1 THEN
                      dragonmicrophonebtncontrol(1,1)
                   ELSE
                      dragonmicrophonebtncontrol(1,2)
                   END IF
                END IF
                CONTROL ENABLE ghDlg, %IDC_LABEL2
                CONTROL REDRAW ghDlg, %IDC_LABEL2
                CONTROL ENABLE ghDlg, %IDC_LABEL1
                CONTROL REDRAW ghDlg, %IDC_LABEL1
            END FUNCTION
            
            FUNCTION microphonetosleep() AS LONG
                CONTROL DISABLE ghDlg, %IDC_LABEL2
                CONTROL REDRAW  ghDlg, %IDC_LABEL2
                CONTROL DISABLE ghDlg, %IDC_LABEL1
                CONTROL REDRAW  ghDlg, %IDC_LABEL1
                IF microphoneready THEN
                   IF dragonmicrophonebtncontrol(0,0)<>3 THEN
                      dragonmicrophonebtncontrol(1,3)
                   ELSE
                      dragonmicrophonebtncontrol(1,2)
                   END IF
                END IF
                CONTROL ENABLE  ghDlg, %IDC_LABEL1
                CONTROL REDRAW  ghDlg, %IDC_LABEL1
                CONTROL ENABLE  ghDlg, %IDC_LABEL2
                CONTROL REDRAW  ghDlg, %IDC_LABEL2
            END FUNCTION
            
            
            
            
            FUNCTION microphoneready() AS LONG  'check the status of the micphone to make sure it is not disabled,paused
                   LOCAL iresult AS LONG
                   iresult=dragonmicrophonebtncontrol(0,0)
                   IF iresult>0 AND iresult<4 THEN
                       FUNCTION=1
                   END IF
            END FUNCTION
            
            
            FUNCTION isDragonBarActive() AS LONG
                gidragonbarfound=0
                gbResult =   EnumChildWindows  (  GetDesktopWindow  ,  CODEPTR (FindDragonBarCallback),  0& )
                FUNCTION=gidragonbarfound
            END FUNCTION
            
            FUNCTION  FindDragonBarCallback( BYVAL  hWndChild  AS LONG , lRaram  AS LONG )  AS LONG
                glRes =   GetClassName  (hWndChild, gszClass,  SIZEOF (gszClass))
                 IF gszClass="DgnBarMainWindowCls" THEN gidragonbarfound=1
                FUNCTION = 1
             END FUNCTION
            
            FUNCTION InstanceTest() AS LONG
               'returns 0 if instance exits or cannot create mutex. otherwise returns 1.
               LOCAL UniqueName AS ASCIIZ * %MAX_PATH
               UniqueName = "pdpdragonmicophonestatus"                     '
               IF CreateMutex(BYVAL %Null, 0, UniqueName) = 0 OR GetLastError = %ERROR_ALREADY_EXISTS THEN EXIT FUNCTION  ELSE FUNCTION = 1
            END FUNCTION
            
            FUNCTION setwindowdimensions() AS LONG
               LOCAL stemp AS STRING
               g_windowstartcolumn=9000
               g_windowstartrow=240
               stemp=TRIM$(COMMAND$(1))
               IF LEN(stemp) THEN g_windowstartcolumn=VAL(COMMAND$(1))
               stemp=TRIM$(COMMAND$(2))
               IF LEN(stemp) THEN g_windowstartrow=VAL(COMMAND$(2))
            
              IF g_windowstartcolumn<1 THEN g_windowstartcolumn=1
              IF g_windowstartrow<1 THEN g_windowstartrow=1
            END FUNCTION
            
            FUNCTION removeobjectsfordragon () AS LONG
               IF giregistered_IDgnMicBtn THEN
                  IF ISOBJECT( objvar_IDgnMicBtn ) THEN
                      objvar_IDgnMicBtn.UnRegister
                      objvar_IDgnMicBtn=NOTHING
                   END IF
                  giregistered_IDgnMicBtn=0
                END IF
                IF ISOBJECT( objvar_IDgnEngineControlW ) THEN objvar_IDgnEngineControlW = NOTHING
            END FUNCTION
            
            FUNCTION setpreviouswindowhandleactive() AS LONG
                IF giwindowhandleprior THEN setforegroundwindow(giwindowhandleprior)
            END FUNCTION
            Attached Files
            Last edited by Paul Purvis; 29 Jun 2017, 11:47 AM.
            p purvis

            Comment


            • #7
              Here is a console program that will enumerate through the dragon DgnBarMainWindowCls class window and display the messages if show messages is checked off in dragon program.
              It is dirty code but it works.
              It uses stdout so you can redirect the output to a text file to get a more or less log.
              compiled with pbcc5.05
              You can get this using objects but this will lock up anything to do with dragon's active program which i seem to be doing.
              I am actually using this code to see if dragon is loaded but an altered pieced of code in the above pbwin10 code.
              It is the isDragonBarActive function but it does not read the windows but only checks to see if there is a window class named "DgnBarMainWindowCls".
              If somebody has a faster way, please let me know so that i can reduce cpu cycles in figuring out if dragon is loaded or not.
              The problem I see is that dragon can be loaded and unloaded.

              Code:
              'enumprocessdragon.bas ' bad name but it is only a tool
              'show messages by dragon by enumerating through windows
              'compiled with pbcc5.05
              #COMPILE EXE
              #DIM ALL
              #INCLUDE   "WIN32API.INC"
                 GLOBAL  lRes  AS LONG
                 GLOBAL  szClass AS ASCIIZ  *  %MAX_PATH
                 GLOBAL  szText  AS ASCIIZ  *  %MAX_PATH
                 GLOBAL  szlasttemp1  AS ASCIIZ  *  %MAX_PATH
              
                 FUNCTION PBMAIN AS LONG
                 ON ERROR RESUME NEXT
                   DIM  bResult  AS LONG
                 WHILE 1
                      bResult =   EnumChildWindows  (  GetDesktopWindow  ,  CODEPTR (ParentCallback),  0& )
                 SLEEP 10
                 WEND
                 END FUNCTION
              
                 FUNCTION  ParentCallback ( BYVAL  hWndChild  AS LONG , lRaram  AS LONG )  AS LONG
                  lRes =   GetClassName  (hWndChild, szClass,  SIZEOF (szClass))
                  lRes =   GetWindowText  (hWndChild, szText,  SIZEOF (szText))
                   IF szClass="DgnBarMainWindowCls" THEN
                      lRes =   EnumChildWindows  (hWndChild,  CODEPTR (ChildCallback),  0& )
                   END IF
              
                   FUNCTION  =  1
                 END FUNCTION
              
                 FUNCTION  ChildCallback ( BYVAL  hWndChild  AS LONG , lRaram  AS LONG )  AS LONG
                  lRes =   GetClassName  (hWndChild, szClass,  SIZEOF (szClass))
                  lRes =   GetWindowText  (hWndChild, szText,  SIZEOF (szText))
                     IF szclass="Static"  THEN
                            IF szText="Recognition Mode Indicator" THEN EXIT FUNCTION
                            IF szText="Compatibility Indicator" THEN EXIT FUNCTION
                            IF szText="VU meter" THEN EXIT FUNCTION
                            IF szText=szlasttemp1 THEN EXIT FUNCTION
                            szlasttemp1=szText
              '              CLS
                                STDOUT  szText
                     END IF
              
              
                   FUNCTION  =  1
                 END FUNCTION
              Attached Files
              Last edited by Paul Purvis; 28 Jun 2017, 02:59 PM.
              p purvis

              Comment


              • #8
                I updated(changed) the code in posting number 7 and changed the zipped file containing the source and exe today.
                Coming mostly console programming background, i did not have to worry about trying to set a windows focus to a previous window other than this programs.
                I made enough changes, that if you are using the exe program in post 7 then you will want replace your exe with this one.
                My efforts are to set a previous window active(in focus) after you press one of these buttons(actually using labels here).
                I know i can do better but for now just try this. I have some more changes but that is one that i worried about for the moment.

                p purvis

                Comment


                • #9
                  i think this software is finally ready.
                  I have replace some code functons with much faster functions, mostly to check to see if the dragon bar window is active.
                  This program now keys on the dragon bar window running only. It does not have to be displayed as it is hidden if you choose not see it.
                  This program is intended for the use when you do not want to see the dragon bar on the desktop. The dragon tray is always running in normal situations.
                  If you close down dragon software, this program will stay running in an idle state and the dialog for this program will start back up when dragon is restarted.

                  I have made changes to the priority state at which program runs at to minimize cpu usage and even to an idle state if the dialog is not shown and waiting for dragon to start or restart.
                  I have removed code in hopes the program will execute the on timer events that watches the microphone status.
                  I have widen the dialog and now it can be in 3 width sizes, skinny, fat and huge.
                  The program now has an option to be run on top.
                  The location of the dialog position on the desktop can be changed.
                  You make the changes on the command line.
                  I left out something to say about the program in the beginning. If you click on the color, the program will be minimized.
                  If you close this program by any windows means, this program will stop and remove itself from memory.
                  After pressing a key on the dialog of this program, it will immediately try and return to a dialog that was last used unless you minimized a programs dialog or closed it.
                  Again, this program will NOT have a dialog when the dragon bar is not running.
                  I did some testing on Dragon 12 where i would rapidly click on dragon's microphone button and had some problems with the program not setting focus back to a running dialog.
                  The main purpose of this program was to see if i could control and/or monitor the microphone status of dragon for use in a different specialized GUI program and also try to give something back to the forum community something to use in learning some windows programming techniques.
                  I have not yet tried this program on lower cpu speed computers but i have kept that in mind during all the coding process.
                  Code:
                  'drgnbutn.bas
                  'compiled with pbwin10 version 10.04
                  'program to change and monitor the dragon naturally speaking microphone setting while
                  'the dragonbar window is running from the natspeak.exe program of dragon
                  'tested on dragon 12, 13, and 15
                  'retrieved COM information using the powerbasic pbrow program
                  
                  
                  #COMPILE EXE "drgnbutn.exe"
                  #DIM ALL
                  
                  #INCLUDE ONCE "WIN32API.INC"
                  
                  %IDD_DIALOG1 =  101
                  %IDC_LABEL1 = 1001
                  %IDC_LABEL2= 1002
                  %IDC_LABEL3  = 1004
                  
                  GLOBAL ghDLG AS DWORD
                  GLOBAL gimicrophonestatus AS LONG
                  GLOBAL gimicrophonestatusprior AS LONG
                  GLOBAL gidragonenginerunning AS LONG
                  GLOBAL gidragonenginerunningprior AS LONG
                  GLOBAL gdwdragonbarwindowhandle AS DWORD
                  GLOBAL gdwdragonbarwindowhandleprior AS DWORD
                  GLOBAL gdwwindowhandle AS DWORD
                  GLOBAL gdwwindowhandleprior AS DWORD
                  GLOBAL giregistered_IDgnMicBtn AS LONG
                  GLOBAL girunprogramagain AS LONG
                  GLOBAL g_windowstartcolumn AS LONG
                  GLOBAL g_windowstartrow AS LONG
                  GLOBAL gichangingmicstatusinprocess AS LONG
                  GLOBAL gidialogwidth AS LONG
                  GLOBAL gialwaysontop AS LONG
                  
                  GLOBAL  objvar_IDgnMicBtn AS IDgnMicBtn
                  GLOBAL  objvar_IDgnEngineControlW AS  IDgnEngineControlW
                  
                  
                  ' Version Independent ProgIDs
                  $PROGID_DNSTools_DgnMicBtn = "Dragon.MicBtn"
                  $PROGID_DNSTools_DgnEngineControl = "Dragon.DgnEngineControl"
                  
                  ' Class Identifiers
                  $CLSID_DNSTools_DgnEngineControl = GUID$("{DE2DB781-BE83-11D1-A572-006008AAC4E2}")
                  
                  ' Interface Identifiers
                  $IID_DNSTools_IDgnMicBtn = GUID$("{12212BCA-F242-4168-A982-F083E4F94D86}")
                  $IID_DNSTools_IDgnEngineControlW = GUID$("{F16BE28E-D738-4E66-9807-1C89B4391589}")
                  
                  
                  ' Interface Name  : IDgnEngineControlW
                  ' Class Name      : DgnEngineControl
                  ' ClassID         : $CLSID_DNSTools_DgnEngineControl
                  ' ProgID          : $PROGID_DNSTools_DgnEngineControl
                  ' Version ProgID  : $PROGID_DNSTools_DgnEngineControl1
                  ' This Interface cannot be created directly it can only
                  ' be returned by a Method or Property in this library.
                  INTERFACE IDgnEngineControlW $IID_DNSTools_IDgnEngineControlW
                      INHERIT IUNKNOWN
                  
                      METHOD BaseSpeakerModelsGet(BYREF ppModels AS WSTRINGZ, BYREF pdwSize AS DWORD) AS LONG
                      METHOD BaseTopicModelsGet(BYREF ppModels AS WSTRINGZ, BYREF pdwSize AS DWORD) AS LONG
                      METHOD EngineVersionGet(BYREF INOUT psMajorNum AS INTEGER, BYREF INOUT psMinorNum AS INTEGER, BYREF INOUT psBuildNum AS _
                          INTEGER) AS LONG
                      METHOD ToolsVersionGet(BYREF INOUT psMajorNum AS INTEGER, BYREF INOUT psMinorNum AS INTEGER, BYREF INOUT psBuildNum AS _
                          INTEGER) AS LONG
                      METHOD WindowModuleFileNameGet(BYVAL hWnd AS DWORD, BYREF ppszFileName AS WSTRINGZ) AS LONG
                      METHOD GlobalDictationGet(BYVAL hWndApp AS DWORD, BYREF INOUT pbEnabled AS LONG) AS LONG
                      METHOD GlobalDictationSet(BYVAL hWndApp AS DWORD, BYVAL bEnabled AS LONG) AS LONG
                      METHOD REGISTER(BYVAL dwFlags AS DWORD, BYREF IN riid AS GUID, BYVAL pNotifySinkUnk AS IUNKNOWN) AS LONG
                      METHOD SpeakerCreate(BYREF IN pszSpeakerName AS WSTRINGZ, BYREF IN pszSpeakerBasedOn AS WSTRINGZ) AS LONG
                      METHOD SpeakerModifiedGet(BYREF INOUT pbModified AS LONG) AS LONG
                      METHOD SpeakerTopicSelect(BYREF IN pszSpeaker AS WSTRINGZ, BYREF IN pszTopic AS WSTRINGZ) AS LONG
                      METHOD TopicCreate(BYREF IN pszSpeaker AS WSTRINGZ, BYREF IN pszTopic AS WSTRINGZ, BYREF IN pszTopicBasedOn AS WSTRINGZ) _
                          AS LONG
                      METHOD TopicDelete(BYREF IN pszReserved AS WSTRINGZ, BYREF IN pszTopic AS WSTRINGZ) AS LONG
                      METHOD TopicGet(BYREF ppTopic AS WSTRINGZ) AS LONG
                      METHOD TopicSet(BYREF IN pszTopic AS WSTRINGZ) AS LONG
                      METHOD TopicsGet(BYREF IN pszSpeaker AS WSTRINGZ, BYREF ppTopics AS WSTRINGZ, BYREF pdwSize AS DWORD) AS LONG
                      METHOD UnRegister(BYVAL bLockServer AS LONG) AS LONG
                      METHOD EngineUIGet(BYREF INOUT pEngineUI AS LONG) AS LONG
                      METHOD EngineUISet(BYVAL EngineUI AS LONG) AS LONG
                      METHOD RecognitionMimic(BYVAL dwNumWords AS DWORD, BYREF IN pWords AS WSTRINGZ, BYVAL dwSize AS DWORD, BYVAL dwParam AS _
                          DWORD) AS LONG
                      METHOD ISRCentralGet(BYREF INOUT ppUnk AS IUNKNOWN) AS LONG
                      METHOD SpeakerTrainedGet(BYVAL dwReserved AS DWORD, BYREF INOUT pbTrained AS LONG) AS LONG
                      METHOD EngineRunningGet(BYREF INOUT pbRunning AS LONG) AS LONG
                      METHOD LanguagesGet(BYREF ppLangs AS DWORD, BYREF pdwSize AS DWORD) AS LONG
                      METHOD SpeakerLanguageGet(BYREF IN pszSpeaker AS WSTRINGZ, BYREF INOUT pLang AS LONG) AS LONG
                      METHOD BaseSpeakerModelLanguageGet(BYREF IN pszBaseSpeakerModel AS WSTRINGZ, BYREF INOUT pLang AS LONG) AS LONG
                      METHOD BaseTopicModelLanguageGet(BYREF IN pszBaseTopicModel AS WSTRINGZ, BYREF INOUT pLang AS LONG) AS LONG
                      METHOD AudioSetupCompleteGet(BYREF INOUT pbComplete AS LONG) AS LONG
                      METHOD SpeakerCalibratedGet(BYREF INOUT pbCalibrated AS LONG) AS LONG
                  END INTERFACE
                  
                  ' Interface Name  : IDgnMicBtn
                  ' Description     : IDgnMicBtn Interface
                  ' Class Name      : DgnMicBtn
                  ' ClassID         : $CLSID_DNSTools_DgnMicBtn
                  ' ProgID          : $PROGID_DNSTools_DgnMicBtn
                  ' Version ProgID  : $PROGID_DNSTools_DgnMicBtn1
                  INTERFACE IDgnMicBtn $IID_DNSTools_IDgnMicBtn
                      INHERIT IDISPATCH
                  
                      PROPERTY GET Enabled <1> () AS INTEGER
                      PROPERTY SET Enabled <1> (BYVAL Rhs AS INTEGER)
                      PROPERTY GET MicState <2> () AS LONG
                      PROPERTY SET MicState <2> (BYVAL Rhs AS LONG)
                      PROPERTY GET VUMeterNotify <3> () AS INTEGER
                      PROPERTY SET VUMeterNotify <3> (BYVAL Rhs AS INTEGER)
                      PROPERTY GET AutoRegister <4> () AS INTEGER
                      PROPERTY SET AutoRegister <4> (BYVAL Rhs AS INTEGER)
                      METHOD REGISTER <5> (OPT BYVAL Flags AS VARIANT)
                      METHOD UnRegister <6> ()
                      PROPERTY GET Paused <7> () AS INTEGER
                      METHOD WaveCaptureStart <8> (BYVAL WaveFilePath AS STRING)
                      METHOD WaveCaptureStop <9> ()
                      PROPERTY GET OPTION <10> (BYVAL PB_Option AS LONG) AS VARIANT
                      PROPERTY SET OPTION <10> (BYVAL PB_Option AS LONG, BYVAL Value AS VARIANT)
                  END INTERFACE
                        'for both property MicState above
                        '%DgnMicStateConstants_dgnmicOff = 1
                        '%DgnMicStateConstants_dgnmicOn = 2
                        '%DgnMicStateConstants_dgnmicSleeping = 3
                  
                  
                  DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
                  DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                  
                  FUNCTION PBMAIN()
                     IF INSTR(COMMAND$,"?") THEN
                         commandlinehelp
                         EXIT FUNCTION
                     END IF
                  
                     'Gary Beene's instance checker
                     IF InstanceTest = 0 THEN EXIT FUNCTION
                  
                     gidialogwidth=18  'set default width of dailog
                     setwindowdimensions
                     IF GetDragonBarWindowHandle THEN GOTO LETSRUNTHEPROGRAMAGAIN_GOAROUND
                      WHILE GetDragonBarWindowHandle=0
                        SetPriorityToIdle
                        SLEEP 15000
                      WEND
                  
                  LETSRUNTHEPROGRAMAGAIN:
                      WHILE GetDragonBarWindowHandle=0
                        SetPriorityToIdle
                        SLEEP 8000
                      WEND
                  
                  LETSRUNTHEPROGRAMAGAIN_GOAROUND:
                      SetPriorityToBelowNormal
                      ghDlg=0
                      gimicrophonestatus=0
                      gidragonenginerunning=0
                      gdwdragonbarwindowhandleprior=1
                      gimicrophonestatusprior=-1
                      gidragonenginerunningprior=-1
                      gimicrophonestatusprior=-1
                      giregistered_IDgnMicBtn=0
                      girunprogramagain=0
                      'set the previouse window handle to a variable
                      gdwwindowhandle=GetForeGroundWindow
                      IF (gdwwindowhandle<>ghdlg AND gdwwindowhandle<>0) THEN gdwwindowhandleprior=gdwwindowhandle
                  
                  
                      ShowDIALOG1 %HWND_DESKTOP
                      IF girunprogramagain THEN 'continue the program if dragon was close before this program manually closed
                         SetPriorityToIdle
                         SLEEP 12000
                         GOTO LETSRUNTHEPROGRAMAGAIN
                      END IF
                  
                  
                  END FUNCTION
                  
                  CALLBACK FUNCTION ShowDIALOG1Proc()
                  STATIC hTimer AS LONG
                  
                      SELECT CASE AS LONG CB.MSG
                          CASE %WM_INITDIALOG
                              ' Initialization handler
                              setpreviouswindowhandleactive
                              gichangingmicstatusinprocess=0
                              SetPriorityToIdle
                              'dialogfader(90) 'function is remarked out below
                              DIALOG HIDE CB.HNDL   'hide the dialog to start
                              DIALOG SET COLOR CB.HNDL, %RGB_DODGERBLUE,  %RGB_DODGERBLUE
                              CONTROL SET COLOR CB.HNDL, %IDC_LABEL1, %RGB_WHITE, %RGB_BLACK
                              CONTROL SET COLOR CB.HNDL, %IDC_LABEL2, %RGB_BLACK, %RGB_SANDYBROWN
                              CONTROL SET COLOR CB.HNDL, %IDC_LABEL3, %RGB_BLACK, %RGB_BLACK
                              IF gialwaysontop THEN dialogsetalwaysontop
                  
                              hTimer = SetTimer( CB.HNDL, 1, 300, CODEPTR(TimerProc) )
                  
                          CASE %WM_ACTIVATEAPP
                              'not using function SetPreviousWindowHandle  the code was placed here inline
                               gdwwindowhandle=GetForeGroundWindow
                               IF (gdwwindowhandle<>ghdlg AND gdwwindowhandle<>0) THEN gdwwindowhandleprior=gdwwindowhandle
                  
                              CASE %WM_NCACTIVATE
                              STATIC hWndSaveFocus AS DWORD
                              IF ISFALSE CB.WPARAM THEN
                                  ' Save control focus
                                  hWndSaveFocus = GetFocus()
                              ELSEIF hWndSaveFocus THEN
                                  ' Restore control focus
                                  SetFocus(hWndSaveFocus)
                                  hWndSaveFocus = 0
                              END IF
                  
                        CASE %WM_USER + 996
                               KillTimer CB.HNDL, hTimer
                               removeobjectsfordragon
                               girunprogramagain=1
                               DIALOG GET LOC CB.HNDL TO g_windowstartcolumn,g_windowstartrow
                               DIALOG END CB.HNDL
                               FUNCTION = 1
                  
                         CASE %WM_DESTROY
                              KillTimer CB.HNDL, hTimer
                              removeobjectsfordragon
                               FUNCTION =1
                  
                          CASE %WM_COMMAND
                              ' Process control notifications
                  
                              SELECT CASE AS LONG CB.CTL
                                  CASE %IDC_LABEL1
                                      IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                          gichangingmicstatusinprocess=1
                                          setpreviouswindowhandleactive
                                          IF GetDragonBarWindowHandle THEN
                                             togglemicophoneonoff
                                             updatedialogwithmicrophonestatus
                                          END IF
                                             gichangingmicstatusinprocess=0
                  
                                      END IF
                  
                                  CASE %IDC_LABEL2
                                      IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                          gichangingmicstatusinprocess=1
                                          setpreviouswindowhandleactive
                                          IF GetDragonBarWindowHandle THEN
                                             microphonetosleep
                                             updatedialogwithmicrophonestatus
                                          END IF
                                          gichangingmicstatusinprocess=0
                  
                                      END IF
                                  CASE %IDC_LABEL3
                                      IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                          setpreviouswindowhandleactive
                                          SetPriorityToIdle
                                          DIALOG MINIMIZE ghDlg
                                     END IF
                  
                              END SELECT
                      END SELECT
                  END FUNCTION
                  FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                      LOCAL lRslt AS LONG
                      LOCAL hFont1 AS DWORD
                      LOCAL hDlg  AS DWORD
                      IF gidialogwidth=0 THEN gidialogwidth=24
                      DIALOG NEW hParent, "Mic-", g_windowstartcolumn,g_windowstartrow, gidialogwidth, 74, %WS_POPUP OR %WS_BORDER _
                          OR %WS_DLGFRAME OR %WS_SYSMENU OR _   ' %WS_MINIMIZEBOX _
                          %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
                          %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
                          OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                      CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "Off", 0, 17, gidialogwidth, 24,_
                           %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR  %SS_CENTER OR %SS_CENTERIMAGE, %WS_EX_LEFT OR _
                           %WS_EX_LTRREADING
                      CONTROL ADD LABEL, hDlg, %IDC_LABEL2, "Nap", 0, 47, gidialogwidth, 24,_
                           %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_CENTERIMAGE,  %WS_EX_LEFT OR _
                           %WS_EX_LTRREADING
                  
                      CONTROL ADD LABEL,  hDlg, %IDC_LABEL3, "", 0, 0, gidialogwidth, 14, _
                           %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_LEFT, %WS_EX_LEFT OR _
                           %WS_EX_LTRREADING
                  
                      FONT NEW "Arial", 7, 1, %ANSI_CHARSET TO hFont1
                      CONTROL SET FONT hDlg, %IDC_LABEL1, hFont1
                      CONTROL SET FONT hDlg, %IDC_LABEL2, hFont1
                  
                      ghDlg=hDlg
                      DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                  
                       FONT END hFont1
                      FUNCTION = lRslt
                  END FUNCTION
                  
                  
                  FUNCTION TimerProc( BYVAL hDlg AS LONG, BYVAL Msg AS LONG, BYVAL EvntID AS LONG, BYVAL Time AS LONG ) AS LONG
                     ' IF gichangingmicstatusinprocess THEN EXIT FUNCTION   'this line is mostly for future use with a thread running the timer
                  
                      'not using function SetPreviousWindowHandle  code was placed here inline
                      gdwwindowhandle=GetForeGroundWindow
                      IF (gdwwindowhandle<>ghdlg AND gdwwindowhandle<>0) THEN gdwwindowhandleprior=gdwwindowhandle
                  
                      IF gdwdragonbarwindowhandle<> GetDragonBarWindowHandle THEN
                           makeajustmentsifdragonbarchangesitswindowhandle
                           EXIT FUNCTION
                      END IF
                  
                      'IF gichangingmicstatusinprocess THEN EXIT FUNCTION   'this line is mostly for future use with a thread running the timer
                      'update the dialog if dragon changes the microphone status
                      updatedialogwithmicrophonestatus
                   END FUNCTION 'TimerProc
                  
                  
                  FUNCTION dragonmicrophonebtncontrol(BYVAL itodo AS LONG,BYVAL imicphonechangestate AS LONG) AS LONG
                  'if itodo equal 0 then return the state of the microphone
                  'if itodo equal 1 then change the state of the microphone
                     STATIC iregistered AS LONG
                     LOCAL iresult AS LONG
                       FUNCTION=-1
                       IF ISFALSE ISOBJECT( objvar_IDgnMicBtn ) THEN
                                objvar_IDgnMicBtn = NEWCOM $PROGID_DNSTools_DgnMicBtn
                         END IF
                       IF ISNOTHING( objvar_IDgnMicBtn ) OR ERR THEN
                          EXIT FUNCTION
                       END IF
                       IF ISFALSE ISOBJECT( objvar_IDgnMicBtn ) THEN
                          EXIT FUNCTION
                       END IF
                       IF ISFALSE giregistered_IDgnMicBtn THEN
                            objvar_IDgnMicBtn.REGISTER
                            giregistered_IDgnMicBtn=1
                       END IF
                  
                       SELECT CASE itodo
                           CASE 0
                             iresult=objvar_IDgnMicBtn.MicState()
                           CASE 1
                             objvar_IDgnMicBtn.MicState=imicphonechangestate
                             iresult=imicphonechangestate
                       END SELECT
                   '     objvar_IDgnMicBtn.UnRegister
                        '%DgnMicStateConstants_dgnmicOff = 1
                        '%DgnMicStateConstants_dgnmicOn = 2
                        '%DgnMicStateConstants_dgnmicSleeping = 3
                        FUNCTION=iresult
                  END FUNCTION
                  
                  
                  FUNCTION togglemicophoneonoff() AS LONG
                      CONTROL DISABLE ghDlg, %IDC_LABEL1
                      CONTROL DISABLE ghDlg, %IDC_LABEL2
                      IF microphoneready THEN
                         IF dragonmicrophonebtncontrol(0,0)<>1 THEN
                            dragonmicrophonebtncontrol(1,1)
                         ELSE
                            dragonmicrophonebtncontrol(1,2)
                         END IF
                      END IF
                      CONTROL ENABLE ghDlg, %IDC_LABEL2
                      CONTROL ENABLE ghDlg, %IDC_LABEL1
                  END FUNCTION
                  
                  FUNCTION microphonetosleep() AS LONG
                      CONTROL DISABLE ghDlg, %IDC_LABEL2
                      CONTROL DISABLE ghDlg, %IDC_LABEL1
                      IF microphoneready THEN
                         IF dragonmicrophonebtncontrol(0,0)<>3 THEN
                            dragonmicrophonebtncontrol(1,3)
                         ELSE
                            dragonmicrophonebtncontrol(1,2)
                         END IF
                      END IF
                      CONTROL ENABLE  ghDlg, %IDC_LABEL1
                      CONTROL ENABLE  ghDlg, %IDC_LABEL2
                  END FUNCTION
                  
                  
                  
                  FUNCTION microphoneready() AS LONG  'check the status of the micphone to make sure it is not disabled,paused
                         LOCAL iresult AS LONG
                         iresult=dragonmicrophonebtncontrol(0,0)
                         IF iresult>0 AND iresult<4 THEN
                             FUNCTION=1
                         END IF
                  END FUNCTION
                  
                  
                  FUNCTION GetDragonBarWindowHandle() AS DWORD
                      FUNCTION=FindWindowEx( BYVAL 0,BYVAL 0, "DgnBarMainWindowCls", "" )
                  END FUNCTION
                  
                  FUNCTION dialogsetalwaysontop() AS LONG
                       SetWindowPos ghDlg, %HWND_TOPMOST, 0,0,0,0, %SWP_NOMOVE OR %SWP_NOSIZE  'set the dialog to always on top
                  END FUNCTION
                  
                  
                  FUNCTION InstanceTest() AS LONG
                     'returns 0 if instance exits or cannot create mutex. otherwise returns 1.
                     LOCAL UniqueName AS ASCIIZ * %MAX_PATH
                     UniqueName = "pdpdragonmicophonestatus"                     '
                     IF CreateMutex(BYVAL %Null, 0, UniqueName) = 0 OR GetLastError = %ERROR_ALREADY_EXISTS THEN EXIT FUNCTION  ELSE FUNCTION = 1
                  END FUNCTION
                  
                  FUNCTION setwindowdimensions() AS LONG
                     LOCAL stemp AS STRING
                     g_windowstartcolumn=3000
                     g_windowstartrow=240
                     stemp=TRIM$(COMMAND$(1))
                     IF LEN(stemp) THEN
                         stemp=RETAIN$(stemp, ANY "0123456789")
                         IF stemp=TRIM$(COMMAND$(1)) THEN  g_windowstartcolumn=VAL(COMMAND$(1))
                     END IF
                     stemp=TRIM$(COMMAND$(2))
                     IF LEN(stemp) THEN
                         stemp=RETAIN$(stemp, ANY "0123456789")
                         IF stemp=TRIM$(COMMAND$(2)) THEN  g_windowstartrow=VAL(COMMAND$(2))
                     END IF
                    IF g_windowstartcolumn<1 THEN g_windowstartcolumn=1
                    IF g_windowstartrow<1 THEN g_windowstartrow=1
                    IF INSTR(LCASE$(COMMAND$),"skinny") THEN gidialogwidth=12 'gidialogwidth*1.5
                    IF INSTR(LCASE$(COMMAND$),"fat") THEN gidialogwidth=18 'gidialogwidth*1.5
                    IF INSTR(LCASE$(COMMAND$),"normal") THEN gidialogwidth=18 'gidialogwidth*1.5
                    IF INSTR(LCASE$(COMMAND$),"huge") THEN gidialogwidth=24 'gidialogwidth*2
                    IF INSTR(LCASE$(COMMAND$),"ontop") THEN gialwaysontop=1
                  END FUNCTION
                  FUNCTION commandlinehelp() AS LONG
                        LOCAL stemp AS STRING
                        stemp ="The purpose of this program is to control or monitor the microphone"+$CRLF+_
                               "for Dragon Naturally Speaking software. Version 12,13 and 15 have been tested"+$CRLF+_
                               "There is no guarantee that this program will work or not cause computer realted issues."+$CRLF+_
                               "The user assumes and accepts all risk while using this software."+$CRLF+$CRLF+_
                               "You can place on the command tail a few options."+$CRLF+_
                               "If you want to place the dialog at a certain postion."+$CRLF+_
                               "You must place the column number as the first parameter and"+$CRLF+_
                               "the row as the second parameter."+$CRLF+_
                               "The dialog can be keep always on top-use the word ontop."+$CRLF+_
                               "To make the dialog narrow-use the the word skinny."+$CRLF+_
                               "To make the dialog wider-use the word huge"+$CRLF+_
                               "To make the dialog nornal width-use the word fat or normal."+$CRLF+$CRLF+_
                               "Press on the color to minimize the dialog."+$CRLF+$CRLF+_
                               "Note: only one instance of this program will run at a time."
                        MSGBOX stemp,%MB_OK,EXE.NAME$
                  END FUNCTION
                  
                  
                  
                  FUNCTION removeobjectsfordragon () AS LONG
                     IF giregistered_IDgnMicBtn THEN
                        IF ISOBJECT( objvar_IDgnMicBtn ) THEN
                            objvar_IDgnMicBtn.UnRegister
                            objvar_IDgnMicBtn=NOTHING
                         END IF
                        giregistered_IDgnMicBtn=0
                      END IF
                      IF ISOBJECT( objvar_IDgnEngineControlW ) THEN objvar_IDgnEngineControlW = NOTHING
                  END FUNCTION
                  
                  
                  FUNCTION SetPriorityToIdle() AS LONG
                  'provided by Knuth Konrad
                      ' Constants for SetPriorityClass
                      '%NORMAL_PRIORITY_CLASS             = &H00000020
                      '%IDLE_PRIORITY_CLASS               = &H00000040
                      '%HIGH_PRIORITY_CLASS               = &H00000080
                      '%REALTIME_PRIORITY_CLASS           = &H00000100 <-- Be EXTREMLY careful with that one. I recommend to just not use it.
                      '%BELOW_NORMAL_PRIORITY_CLASS       = &H00004000
                      '%ABOVE_NORMAL_PRIORITY_CLASS       = &H00008000
                      'hProcess = GetCurrentProcess()
                      'lRetval = SetPriorityClass(hProcess, %BELOW_NORMAL_PRIORITY_CLASS)
                    LOCAL hProcess AS LONG
                    LOCAL lRetval AS LONG
                      hProcess = GetCurrentProcess()
                      lRetval = SetPriorityClass(hProcess, %IDLE_PRIORITY_CLASS)
                  END FUNCTION
                  
                  FUNCTION SetPriorityToBelowNormal() AS LONG
                    LOCAL hProcess AS LONG
                    LOCAL lRetval AS LONG
                      hProcess = GetCurrentProcess()
                      lRetval = SetPriorityClass(hProcess, %BELOW_NORMAL_PRIORITY_CLASS)
                  END FUNCTION
                  
                  FUNCTION setpreviouswindowhandleactive() AS LONG
                      IF gdwwindowhandleprior AND gdwwindowhandleprior<>ghdlg THEN
                         IF IsIconic(gdwwindowhandleprior)=0 THEN
                            setforegroundwindow(gdwwindowhandleprior)
                            setactivewindow(gdwwindowhandleprior)
                         END IF
                      END IF
                  END FUNCTION
                  
                  FUNCTION updatedialogwithmicrophonestatus() AS LONG
                  'code remove for now and hoping the dragonbarwindow test makes this code not needed
                  '    IF ISFALSE ISOBJECT( objvar_IDgnEngineControlW ) THEN
                  '          objvar_IDgnEngineControlW = NEWCOM $PROGID_DNSTools_DgnEngineControl
                  '     END IF
                  '    objvar_IDgnEngineControlW.EngineRunningGet(gidragonenginerunning)
                  '    IF gidragonenginerunning<>gidragonenginerunningprior THEN
                  '        IF gidragonenginerunning THEN
                  '           gidragonenginerunningprior=1
                  '           gichangingmicstatusinprocess=0
                  '           SetPriorityToBelowNormal
                  '           DIALOG NORMALIZE ghDlg
                  '        ELSE
                  '           gidragonenginerunningprior=0
                  '           SetPriorityToIdle
                  '           DIALOG HIDE ghDlg
                  '           CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_BLACK
                  '           EXIT FUNCTION
                  '        END IF
                  '    END IF
                      gimicrophonestatus=dragonmicrophonebtncontrol(0,0)
                      IF gimicrophonestatusprior=gimicrophonestatus THEN EXIT FUNCTION
                      gimicrophonestatusprior=gimicrophonestatus
                      SELECT CASE gimicrophonestatus
                          CASE 1
                               DIALOG SET TEXT ghDlg, "Mic-Off"
                                 CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_RED, %RGB_RED
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL1, "On"
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL2, "Nap"
                          CASE 2
                              DIALOG SET TEXT ghDlg, "Mic-On"
                                 CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_LIME, %RGB_LIME
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL1, "Off"
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL2, "Nap"
                          CASE 3
                               DIALOG SET TEXT ghDlg, "Mic-Asleep"
                                 CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_YELLOW, %RGB_YELLOW '%RGB_SANDYBROWN
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL2, "On"
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL1, "Off"
                          CASE ELSE
                              DIALOG SET TEXT ghDlg, "Mic-"
                                 CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_WHITE
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL1, ""
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL2, ""
                      END SELECT
                         'DIALOG REDRAW ghDlg
                          CONTROL REDRAW   ghDlg, %IDC_LABEL1
                          CONTROL REDRAW   ghDlg, %IDC_LABEL2
                          CONTROL REDRAW   ghDlg, %IDC_LABEL3
                  END FUNCTION
                  
                  'did not use this code because it was placed inline to remove cpu cycles
                  'function SetPreviousWindowHandle() as long
                  '    gdwwindowhandle=GetForeGroundWindow
                  '    IF gdwwindowhandle THEN
                  '        if gdwwindowhandle <> ghdlg then gdwwindowhandleprior=gdwwindowhandle
                  '   end if
                  'end function
                  
                  'function for fading the dialog
                  'FUNCTION  fadedialog(byval ifadpercent as long) as long
                  '   SetWindowLong(ghDlg, %GWL_EXSTYLE,  GetWindowLong(ghDlg, %GWL_EXSTYLE) OR %WS_EX_LAYERED)
                  '   SetLayeredWindowAttributes(ghDlg, 0, (255 * ifadpercent) / 100, %LWA_ALPHA)
                  'END FUNCTION
                  
                  
                  FUNCTION makeajustmentsifdragonbarchangesitswindowhandle()AS LONG
                      gdwdragonbarwindowhandle=GetDragonBarWindowHandle
                      IF gdwdragonbarwindowhandle THEN
                          IF gdwdragonbarwindowhandle<>gdwdragonbarwindowhandleprior THEN
                                 gdwdragonbarwindowhandleprior=gdwdragonbarwindowhandle
                                 gichangingmicstatusinprocess=0
                                 SetPriorityToBelowNormal
                                 DIALOG NORMALIZE ghDlg
                          END IF
                      ELSE
                       'dragonbarwindow in dragon is not running  remove the dialog and idle till dragon bar window starts back up
                       '  IF gdwdragonbarwindowhandleprior=gdwdragonbarwindowhandle THEN EXIT FUNCTION 'this line is not needed
                         gdwdragonbarwindowhandleprior=0 'gdwdragonbarwindowhandle
                         gichangingmicstatusinprocess=0
                         CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_BLACK
                         SetPriorityToIdle
                         DIALOG HIDE ghDlg
                         DIALOG POST ghDlg, %WM_USER+996,0,0
                         EXIT FUNCTION
                      END IF
                  END FUNCTION
                  Attached Files
                  p purvis

                  Comment


                  • #10
                    This will likely be my last post on this thread unless i go back and redo the console program i listed first.
                    This program has changed a little because it can change and/or monitor the dictation modes of dragon.
                    There is a mouse mode in Dragon, i am not really sure of what that is yet, but you cannot change to it but you can change out of it with this program and it will display a M for Mouse mode status.
                    Any other code will be placed into a different section.
                    Did some reading up on COM objects and it is clearer but that does not mean the fog has left. lol
                    I tried to keep much of the labels that i am using as buttons to a very minimum in size. There is a huge command line option even though it is does not make create a huge dialog and time will tell. I was thinking about laptop screens when it created this program and trying to keep desktop usage to a minimum.
                    To keep it on top, you have to use the ontop or keepontop command line tail.


                    Code:
                    'drgnbutn.bas
                    'compiled with pbwin10 version 10.04
                    'program to change and monitor the dragon naturally speaking microphone setting while
                    'the dragonbar window is running from the natspeak.exe program of dragon
                    'tested on dragon 12, 13, and 15
                    'retrieved COM information using the powerbasic pbrow program
                    
                    
                    #COMPILE EXE "drgnbutn.exe"
                    #DIM ALL
                    
                    #INCLUDE ONCE "WIN32API.INC"
                    
                    %IDD_DIALOG1 =  101
                    %IDC_LABEL1 = 1001
                    %IDC_LABEL2= 1002
                    %IDC_LABEL3  = 1004
                    
                    %IDC_LABELMODE0  = 1010  'normal mode
                    %IDC_LABELMODE1  = 1011  'dictation mode
                    %IDC_LABELMODE2  = 1012  'Commnad mode
                    %IDC_LABELMODE3  = 1013  'numbers mode
                    %IDC_LABELMODE4  = 1014  'spell mode
                    '%IDC_LABELMODE5  = 1015  'mouse mode
                    
                    
                    
                    
                    GLOBAL ghDLG AS DWORD
                    GLOBAL gimicrophonestatus AS LONG
                    GLOBAL gimicrophonestatusprior AS LONG
                    GLOBAL gidragonenginerunning AS LONG
                    GLOBAL gidragonenginerunningprior AS LONG
                    GLOBAL gdwdragonbarwindowhandle AS DWORD
                    GLOBAL gdwdragonbarwindowhandleprior AS DWORD
                    GLOBAL gdwwindowhandle AS DWORD
                    GLOBAL gdwwindowhandleprior AS DWORD
                    GLOBAL giregistered_IDgnMicBtn AS LONG
                    GLOBAL giobjectstate_IDgnEngine AS LONG
                    GLOBAL girunprogramagain AS LONG
                    GLOBAL g_windowstartcolumn AS LONG
                    GLOBAL g_windowstartrow AS LONG
                    GLOBAL gichangeinprogress AS LONG
                    GLOBAL gidialogwidth AS LONG
                    GLOBAL gialwaysontop AS LONG
                    GLOBAL gidictationmodestatus AS LONG
                    GLOBAL gidictationmodestatusprior AS LONG
                    GLOBAL gsdictationmode AS STRING
                    GLOBAL gsmicrophonestate AS STRING
                    
                    
                    
                    
                    GLOBAL  objvar_IDgnMicBtn AS IDgnMicBtn
                    
                    
                    'removed code
                    '==========================================================================
                    'GLOBAL  objvar_IDgnEngineControlW AS  IDgnEngineControlW
                    '==========================================================================
                    GLOBAL  objvar_IDgnEngine AS  IDgnEngine
                    
                    TYPE Tag__FILETIME
                        dwLowDateTime AS DWORD
                        dwHighDateTime AS DWORD
                    END TYPE
                    
                    ' Version Independent ProgIDs
                    $PROGID_DNSTools_DgnMicBtn = "Dragon.MicBtn"
                    'removed code
                    '==========================================================================
                    $PROGID_DNSTools_DgnEngineControl = "Dragon.DgnEngineControl"
                    '==========================================================================
                    
                    ' Class Identifiers
                    $CLSID_DNSTools_DgnEngineControl = GUID$("{DE2DB781-BE83-11D1-A572-006008AAC4E2}")
                    
                    ' Interface Identifiers
                    $IID_DNSTools_IDgnMicBtn = GUID$("{12212BCA-F242-4168-A982-F083E4F94D86}")
                    'removed code
                    '==========================================================================
                    '$IID_DNSTools_IDgnEngineControlW = GUID$("{F16BE28E-D738-4E66-9807-1C89B4391589}")
                    'removed code
                    '==========================================================================
                    
                    $IID_DNSTools_IDgnEngine = GUID$("{E366EA73-A952-44C3-A448-72553BDA9EAE}")
                    
                    
                    $IID_DNSTools_IDgnNetworkDirectory = GUID$("{C0D45E6C-D820-440B-8936-3DCE6EFA8368}")
                    ' Interface Name  : IDgnNetworkDirectory
                    ' Description     : IDgnNetworkDirectory Interface
                    ' Class Name      : DgnNetworkDirectory
                    ' ClassID         : $CLSID_DNSTools_DgnNetworkDirectory
                    ' ProgID          : $PROGID_DNSTools_DgnNetworkDirectory
                    ' Version ProgID  : $PROGID_DNSTools_DgnNetworkDirectory1
                    INTERFACE IDgnNetworkDirectory $IID_DNSTools_IDgnNetworkDirectory
                        INHERIT IDISPATCH
                    
                        PROPERTY GET DisplayName <0> () AS STRING
                        PROPERTY SET DisplayName <0> (BYVAL PB_Name AS STRING)
                        PROPERTY GET Location <1> () AS STRING
                        PROPERTY SET Location <1> (BYVAL Location AS STRING)
                        PROPERTY GET OPTION <2> (BYVAL PB_Option AS LONG) AS VARIANT
                        PROPERTY SET OPTION <2> (BYVAL PB_Option AS LONG, BYVAL Value AS VARIANT)
                        METHOD RestoreDefaultOptions <3> ()
                    END INTERFACE
                    
                    
                    $IID_DNSTools_IDgnNetworkDirectories = GUID$("{3B6C4C53-4B9D-4EBE-9269-6EE384B5FAC9}")
                    ' Interface Name  : IDgnNetworkDirectories
                    ' Description     : IDgnNetworkDirectories Interface
                    ' This Interface cannot be created directly it can only
                    ' be returned by a Method or Property in this library.
                    INTERFACE IDgnNetworkDirectories $IID_DNSTools_IDgnNetworkDirectories
                        INHERIT IDISPATCH
                    
                        PROPERTY GET ITEM <0> (BYVAL Index AS LONG) AS IDgnNetworkDirectory
                        PROPERTY GET COUNT <1> () AS LONG
                        METHOD ADD <2> (BYVAL NetworkDirectory AS IDgnNetworkDirectory)
                        METHOD Remove <3> (BYVAL Index AS LONG)
                        PROPERTY GET Master <4> () AS LONG
                        PROPERTY SET Master <4> (BYVAL Index AS LONG)
                        PROPERTY GET PropGet__NewEnum <-4> () AS IUNKNOWN
                    END INTERFACE
                    
                    
                    
                    
                    $IID_DNSTools_IDgnDictationSourceConstantsCollection = GUID$("{6612DE80-7C11-4AAC-8D0F-6FDD5F31165E}")
                    ' Interface Name  : IDgnDictationSourceConstantsCollection
                    ' Description     : IDgnDictationSourceConstantsCollection interface.
                    ' This Interface cannot be created directly it can only
                    ' be returned by a Method or Property in this library.
                    INTERFACE IDgnDictationSourceConstantsCollection $IID_DNSTools_IDgnDictationSourceConstantsCollection
                        INHERIT IDISPATCH
                    
                        PROPERTY GET ITEM <0> (BYVAL Index AS LONG) AS LONG
                        PROPERTY GET COUNT <1> () AS LONG
                        PROPERTY GET PropGet__NewEnum <-4> () AS IUNKNOWN
                    END INTERFACE
                    
                    
                    $IID_DNSTools_IDgnLanguageConstantsCollection = GUID$("{5B36E842-980A-4E30-85F4-B49C447032C6}")
                    ' Interface Name  : IDgnLanguageConstantsCollection
                    ' Description     : IDgnLanguageConstantsCollection interface.
                    ' This Interface cannot be created directly it can only
                    ' be returned by a Method or Property in this library.
                    INTERFACE IDgnLanguageConstantsCollection $IID_DNSTools_IDgnLanguageConstantsCollection
                        INHERIT IDISPATCH
                    
                        PROPERTY GET ITEM <0> (BYVAL Index AS LONG) AS LONG
                        PROPERTY GET COUNT <1> () AS LONG
                        PROPERTY GET PropGet__NewEnum <-4> () AS IUNKNOWN
                    END INTERFACE
                    
                    
                    
                    
                    $IID_DNSTools_IDgnBar = GUID$("{2B53FBA1-5456-4D79-AFD7-21EF6DD26B03}")
                    ' Interface Name  : IDgnBar
                    ' Description     : IDgnBar interface.
                    ' This Interface cannot be created directly it can only
                    ' be returned by a Method or Property in this library.
                    INTERFACE IDgnBar $IID_DNSTools_IDgnBar
                        INHERIT IDISPATCH
                    
                        METHOD ShowMessage <1> (BYVAL Flags AS LONG, BYVAL Message AS STRING)
                        METHOD ShowStockMessage <2> (BYVAL Flags AS LONG, BYVAL MessageId AS LONG)
                        PROPERTY GET STATUS <3> () AS LONG
                        PROPERTY SET STATUS <3> (BYVAL Rhs AS LONG)
                        METHOD SetSelectAndSay <4> (BYVAL hWnd AS LONG, BYVAL PB_Enable AS INTEGER)
                    END INTERFACE
                    
                    
                    $IID_DNSTools_IDgnStrings = GUID$("{DC188E5F-B202-11D1-A4B6-00A024A3A678}")
                    ' Interface Name  : IDgnStrings
                    ' Description     : IDgnStrings Interface
                    ' Class Name      : DgnStrings
                    ' ClassID         : $CLSID_DNSTools_DgnStrings
                    ' ProgID          : $PROGID_DNSTools_DgnStrings
                    ' Version ProgID  : $PROGID_DNSTools_DgnStrings1
                    INTERFACE IDgnStrings $IID_DNSTools_IDgnStrings
                        INHERIT IDISPATCH
                    
                        PROPERTY GET ITEM <0> (BYVAL Index AS LONG) AS STRING
                        PROPERTY GET COUNT <1> () AS LONG
                        METHOD ADD <2> (BYVAL PB_String AS STRING)
                        METHOD Remove <3> (BYVAL Index AS LONG)
                        METHOD CLEAR <4> ()
                        PROPERTY GET PropGet__Data <5> () AS VARIANT
                        PROPERTY GET PropGet__NewEnum <-4> () AS IUNKNOWN
                    END INTERFACE
                    $IID_DNSTools_IDgnSpeechEngine = GUID$("{3667B776-8150-4458-9C10-D79FC4C8098D}")
                    ' Interface Name  : IDgnSpeechEngine
                    ' Description     : IDgnSpeechEngine interface.
                    ' This Interface cannot be created directly it can only
                    ' be returned by a Method or Property in this library.
                    INTERFACE IDgnSpeechEngine $IID_DNSTools_IDgnSpeechEngine
                        INHERIT IDISPATCH
                    
                        PROPERTY GET ProductName <1> () AS STRING
                        PROPERTY GET ModeName <2> () AS STRING
                        PROPERTY GET LanguageID <3> () AS LONG
                        PROPERTY GET Dialect <4> () AS STRING
                        PROPERTY GET EngineFeatures <5> () AS LONG
                        PROPERTY GET ModeID <6> () AS STRING
                    END INTERFACE
                    
                    
                    
                    $IID_DNSTools_IDgnSpeechEngines = GUID$("{B5B311C5-78FA-42F5-81F2-F97A8E3A2A2F}")
                    ' Interface Name  : IDgnSpeechEngines
                    ' Description     : IDgnSpeechEngines interface.
                    ' This Interface cannot be created directly it can only
                    ' be returned by a Method or Property in this library.
                    INTERFACE IDgnSpeechEngines $IID_DNSTools_IDgnSpeechEngines
                        INHERIT IDISPATCH
                    
                        PROPERTY GET ITEM <0> (BYVAL Index AS LONG) AS IDgnSpeechEngine
                        PROPERTY GET COUNT <1> () AS LONG
                        PROPERTY GET PropGet__NewEnum <-4> () AS IUNKNOWN
                    END INTERFACE
                    
                    
                    ' Interface Name  : IDgnEngine
                    ' Description     : Dragon IDgnEngine Interface
                    ' Class Name      : DgnEngineControl
                    ' ClassID         : $CLSID_DNSTools_DgnEngineControl
                    ' ProgID          : $PROGID_DNSTools_DgnEngineControl
                    ' Version ProgID  : $PROGID_DNSTools_DgnEngineControl1
                    INTERFACE IDgnEngine $IID_DNSTools_IDgnEngine
                        INHERIT IDISPATCH
                    
                        METHOD REGISTER <1> (OPT BYVAL Flags AS VARIANT)
                        METHOD UnRegister <2> (BYVAL LockServer AS INTEGER)
                        PROPERTY GET Speakers <3> () AS IDgnStrings
                        PROPERTY GET Speaker <4> () AS STRING
                        PROPERTY SET Speaker <4> (BYVAL Rhs AS STRING)
                        METHOD SpeakerCreate <5> (BYVAL SpeakerName AS STRING, OPT BYVAL SpeakerBasedOn AS VARIANT)
                        METHOD SpeakerDelete <6> (BYVAL SpeakerName AS STRING)
                        METHOD SpeakerSave <7> ()
                        PROPERTY GET Topics <8> (BYVAL Speaker AS STRING) AS IDgnStrings
                        PROPERTY GET Topic <9> () AS STRING
                        PROPERTY SET Topic <9> (BYVAL Rhs AS STRING)
                        METHOD TopicCreate <10> (BYVAL Speaker AS STRING, BYVAL Topic AS STRING, BYVAL TopicBasedOn AS STRING)
                        METHOD TopicDelete <11> (BYVAL Speaker AS STRING, BYVAL Topic AS STRING)
                        PROPERTY GET BaseSpeakerModels <12> () AS IDgnStrings
                        PROPERTY GET BaseTopicModels <13> () AS IDgnStrings
                        PROPERTY GET SpeechEngines <14> () AS IDgnSpeechEngines
                        METHOD VocabularyBuilder <15> (BYVAL CommandLine AS STRING)
                        METHOD AudioSetupWizard <16> (BYVAL CommandLine AS STRING)
                        METHOD GeneralTraining <17> (BYVAL CommandLine AS STRING)
                        PROPERTY GET AudioSetupComplete <18> () AS INTEGER
                        PROPERTY GET SpeakerCalibrated <19> () AS INTEGER
                        PROPERTY GET SpeakerTrainingTime <20> () AS LONG
                        METHOD GetToolsVersion <21> (BYREF INOUT MajorNum AS INTEGER, BYREF INOUT MinorNum AS INTEGER, BYREF INOUT BuildNum AS _
                            INTEGER)
                        METHOD GetEngineVersion <22> (BYREF INOUT MajorNum AS INTEGER, BYREF INOUT MinorNum AS INTEGER, BYREF INOUT BuildNum AS _
                            INTEGER)
                        PROPERTY GET SpeechEngine <23> () AS IDgnSpeechEngine
                        PROPERTY GET GlobalDictation <24> (OPT BYVAL hWndApp AS VARIANT) AS INTEGER
                        PROPERTY SET GlobalDictation <24> (OPT BYVAL hWndApp AS VARIANT, BYVAL Rhs AS INTEGER)
                        METHOD NewCommandWizard <25> (BYVAL hWndParent AS LONG)
                        METHOD EditCommandWizard <26> (BYVAL hWndParent AS LONG)
                        PROPERTY GET SpeakerModified <27> () AS INTEGER
                        METHOD EngineSelect <28> (BYVAL Engine AS IDgnSpeechEngine)
                        METHOD GetWindowModuleFileName <29> (BYVAL hWnd AS LONG) AS STRING
                        METHOD SpeakerTopicSelect <30> (BYVAL Speaker AS STRING, BYVAL Topic AS STRING)
                        PROPERTY SET GlobalDictationWindowClassSet <31> (BYVAL WindowClass AS STRING, BYVAL Rhs AS INTEGER)
                        METHOD LogMessage <1000> (BYVAL MessageString AS STRING)
                        PROPERTY GET ISRCentral <1001> () AS IUNKNOWN
                        PROPERTY GET EngineParam <1002> (BYVAL RegName AS STRING, BYVAL UserOrAppName AS STRING, BYVAL ValueName AS STRING) AS _
                            STRING
                        PROPERTY SET EngineParam <1002> (BYVAL RegName AS STRING, BYVAL UserOrAppName AS STRING, BYVAL ValueName AS STRING, _
                            BYVAL Rhs AS STRING)
                        PROPERTY GET RecogParam <1003> (BYVAL PB_Name AS STRING) AS STRING
                        PROPERTY SET RecogParam <1003> (BYVAL PB_Name AS STRING, BYVAL Rhs AS STRING)
                        PROPERTY GET EngineUI <100> () AS LONG
                        PROPERTY SET EngineUI <100> (BYVAL Rhs AS LONG)
                        METHOD AudioPushCLSID <101> (BYVAL PB_clsid AS STRING, BYVAL AutoPop AS INTEGER, BYREF INOUT ppIUnkAudioFile AS IUNKNOWN, _
                            BYREF INOUT Key AS LONG)
                        METHOD AudioPop <102> (BYVAL PB_Key AS LONG)
                        PROPERTY GET AudioQuery <103> () AS LONG
                        PROPERTY GET SpeakerTrained <104> (BYVAL Reserved AS VARIANT) AS INTEGER
                        METHOD DlgStatusGet <105> (BYVAL PB_Dialog AS LONG) AS LONG
                        METHOD DlgShow <106> (BYVAL PB_Dialog AS LONG, BYVAL hWndParent AS LONG, OPT BYVAL PB_Data AS VARIANT, OPT BYVAL Flags _
                            AS VARIANT)
                        PROPERTY GET EngineRunning <107> () AS INTEGER
                        PROPERTY GET DragonBar <201> () AS IDgnBar
                        PROPERTY GET Languages <202> () AS IDgnLanguageConstantsCollection
                        PROPERTY GET SpeakerLanguage <203> (BYVAL Speaker AS STRING) AS LONG
                        PROPERTY GET BaseSpeakerModelLanguage <204> (BYVAL BaseSpeakerModel AS STRING) AS LONG
                        PROPERTY GET BaseTopicModelLanguage <205> (BYVAL BaseTopicModel AS STRING) AS LONG
                        PROPERTY GET CompatibilityModule <206> (BYVAL eModule AS LONG, BYVAL hWndApp AS LONG) AS INTEGER
                        PROPERTY SET CompatibilityModule <206> (BYVAL eModule AS LONG, BYVAL hWndApp AS LONG, BYVAL Rhs AS INTEGER)
                        PROPERTY GET OPTION <207> (BYVAL PB_Option AS LONG) AS VARIANT
                        PROPERTY SET OPTION <207> (BYVAL PB_Option AS LONG, BYVAL Rhs AS VARIANT)
                        PROPERTY GET ItnOption <208> (BYVAL PB_Option AS LONG) AS INTEGER
                        PROPERTY SET ItnOption <208> (BYVAL PB_Option AS LONG, BYVAL Rhs AS INTEGER)
                        METHOD SpeakerExport <209> (BYVAL SpeakerName AS STRING, BYVAL DestinationDirectory AS STRING, OPT BYVAL Flags AS _
                            VARIANT)
                        PROPERTY GET SpeakerDirectory <210> () AS STRING
                        PROPERTY SET SpeakerDirectory <210> (BYVAL Rhs AS STRING)
                        PROPERTY GET SpeakersInDirectory <211> (BYVAL SpeakerDirectoryPath AS STRING) AS IDgnStrings
                        METHOD SpeakerClose <212> ()
                        PROPERTY GET MyCommandsActiveState <213> () AS STRING
                        PROPERTY SET MyCommandsActiveState <213> (BYVAL Rhs AS STRING)
                        METHOD DictationSourceNameGet <214> (BYVAL DictationSource AS LONG) AS STRING
                        METHOD SpeakerCreateWithDictationSource <215> (BYVAL SpeakerName AS STRING, BYVAL DictationSource AS LONG, BYVAL _
                            TopicBasedOn AS STRING)
                        METHOD SpeakerTopicDictationSourceSelect <216> (BYVAL Speaker AS STRING, BYVAL Topic AS STRING, BYVAL DictationSource AS _
                            LONG)
                        METHOD DictationSourceCreate <217> (BYVAL DictationSource AS LONG, OPT BYVAL Speaker AS VARIANT)
                        METHOD DictationSourceDelete <218> (BYVAL DictationSource AS LONG, OPT BYVAL Speaker AS VARIANT)
                        PROPERTY GET DictationSources <219> (OPT BYVAL Speaker AS VARIANT) AS IDgnDictationSourceConstantsCollection
                        PROPERTY GET DictationSource <220> () AS LONG
                        PROPERTY SET DictationSource <220> (BYVAL Rhs AS LONG)
                        PROPERTY GET RoamingUserOption <221> (BYVAL PB_Option AS LONG) AS VARIANT
                        PROPERTY SET RoamingUserOption <221> (BYVAL PB_Option AS LONG, BYVAL Rhs AS VARIANT)
                        METHOD PromptValue <222> (BYVAL Values AS DWORD, BYVAL Description AS STRING, OPT BYVAL X AS LONG, OPT BYVAL Y AS LONG) _
                            AS STRING
                        PROPERTY GET DefaultSpeakerDirectory <223> () AS STRING
                        PROPERTY GET BaseTopicModel <224> (BYVAL Speaker AS STRING, BYVAL Topic AS STRING) AS STRING
                        PROPERTY GET BaseSpeakerModel <225> (BYVAL Speaker AS STRING, BYVAL DictationSource AS LONG) AS STRING
                        PROPERTY GET MostRecentlyUsedSpeaker <226> () AS STRING
                        PROPERTY GET SpeakerLMECompleted <227> () AS INTEGER
                        PROPERTY GET SpeakerDictationSourceTrained <228> (OPT BYVAL Speaker AS VARIANT, OPT BYVAL DictationSource AS VARIANT) AS _
                            INTEGER
                        METHOD RoamingUserBreakLockNow <229> ()
                        METHOD ImportMyCommands <230> (BYVAL FileName AS STRING, OPT BYVAL vbValidateByDTD AS INTEGER) AS LONG
                        METHOD RecognitionMimic <231> (BYVAL Utterance AS STRING, OPT BYVAL Parameter AS VARIANT)
                        PROPERTY GET SpeakerIsRoamingUserCache <232> (OPT BYVAL Speaker AS VARIANT) AS INTEGER
                        PROPERTY GET RoamingUserNetworkDirectories <233> () AS IDgnNetworkDirectories
                        PROPERTY GET BestBaseSpeakerModel <234> (BYVAL DictationSource AS LONG, BYVAL BaseTopicModel AS STRING) AS STRING
                        METHOD SpeakerCreateWithDictationSourceEx <235> (BYVAL SpeakerName AS STRING, BYVAL DictationSource AS LONG, BYVAL _
                            BaseSpeakerModel AS STRING)
                        METHOD DictationSourceCreateEx <236> (BYVAL DictationSource AS LONG, BYVAL BaseSpeakerModel AS STRING, OPT BYVAL _
                            SpeakerName AS VARIANT)
                        METHOD GetToolsVersionEx <237> (BYREF INOUT MajorNum AS INTEGER, BYREF INOUT MinorNum AS INTEGER, BYREF INOUT BuildNum _
                            AS INTEGER, BYREF INOUT InternalBuildNum AS INTEGER)
                        METHOD SpeakerGetVersion <238> (BYVAL SpeakerName AS STRING, BYREF INOUT MajorNum AS INTEGER, BYREF INOUT MinorNum AS _
                            INTEGER, BYREF INOUT reserved1 AS INTEGER, BYREF INOUT reserved2 AS INTEGER)
                        PROPERTY GET IsBusy <239> () AS INTEGER
                        PROPERTY GET IServiceProvider <240> () AS IUNKNOWN
                        METHOD EnterAdministrationMode <241> (BYVAL ParentHWND AS LONG)
                        METHOD LeaveAdministrationMode <242> ()
                        PROPERTY GET RecognitionMode <243> () AS LONG
                        PROPERTY SET RecognitionMode <243> (BYVAL RecognitionMode AS LONG)
                        METHOD LoadCompatibilityModules <244> ()
                        METHOD UnloadCompatibilityModules <245> ()
                        PROPERTY GET AdministrativeSetting <246> (BYVAL PB_Option AS LONG) AS VARIANT
                        PROPERTY SET AdministrativeSetting <246> (BYVAL PB_Option AS LONG, BYVAL Value AS VARIANT)
                        METHOD AudioSourceEnable <247> (BYVAL Channels AS LONG, BYVAL SamplesPerSecond AS LONG, BYVAL BitsPerSample AS LONG)
                        METHOD AudioSourceDisable <248> ()
                        METHOD AudioSourcePushData <249> (BYREF IN Buffer AS BYTE, BYVAL BufferSize AS DWORD, BYVAL EndOfData AS INTEGER)
                        METHOD MergeMyCommands <250> (BYVAL DstFileName AS STRING, BYVAL SrcFileName AS STRING) AS LONG
                        METHOD RecognitionMimicEx <251> (BYVAL PB_type AS LONG, BYVAL Format AS LONG, BYVAL Utterance AS STRING, OPT BYVAL _
                            Parameter AS VARIANT)
                        PROPERTY GET LocaleIdentifier <252> () AS LONG
                        PROPERTY GET DateFormatList <253> () AS IDgnStrings
                        METHOD TrainWordsFromFile <254> (BYVAL WavFileName AS STRING, BYVAL PhraseWrittenForm AS STRING)
                        METHOD GetWaveFileSNR <255> (BYVAL WaveFile AS STRING) AS DOUBLE
                        METHOD AudioSourcePushDataEx <256> (BYVAL Buffer AS DWORD, BYVAL EndOfData AS INTEGER)
                        METHOD LogMsg <257> (BYVAL ftEventMomentUTC AS Tag__FILETIME, BYVAL llCPUtimestamp AS QUAD, BYVAL dwProcessID AS DWORD, _
                            BYVAL dwThreadID AS DWORD, BYVAL MessageString AS STRING)
                        METHOD LogMsgFromCsharp <258> (BYVAL i64EventMomentUTC AS QUAD, BYVAL llCPUtimestamp AS QUAD, BYVAL dwProcessID AS DWORD, _
                            BYVAL dwThreadID AS DWORD, BYVAL MessageString AS STRING)
                        METHOD ExportMyCommands <259> (BYVAL FileName AS STRING)
                    END INTERFACE
                    
                    
                    'removed code
                    '==========================================================================
                    '' Interface Name  : IDgnEngineControlW
                    '' Class Name      : DgnEngineControl
                    '' ClassID         : $CLSID_DNSTools_DgnEngineControl
                    '' ProgID          : $PROGID_DNSTools_DgnEngineControl
                    '' Version ProgID  : $PROGID_DNSTools_DgnEngineControl1
                    '' This Interface cannot be created directly it can only
                    '' be returned by a Method or Property in this library.
                    'INTERFACE IDgnEngineControlW $IID_DNSTools_IDgnEngineControlW
                    '    INHERIT IUNKNOWN
                    '
                    '    METHOD BaseSpeakerModelsGet(BYREF ppModels AS WSTRINGZ, BYREF pdwSize AS DWORD) AS LONG
                    '    METHOD BaseTopicModelsGet(BYREF ppModels AS WSTRINGZ, BYREF pdwSize AS DWORD) AS LONG
                    '    METHOD EngineVersionGet(BYREF INOUT psMajorNum AS INTEGER, BYREF INOUT psMinorNum AS INTEGER, BYREF INOUT psBuildNum AS _
                    '        INTEGER) AS LONG
                    '    METHOD ToolsVersionGet(BYREF INOUT psMajorNum AS INTEGER, BYREF INOUT psMinorNum AS INTEGER, BYREF INOUT psBuildNum AS _
                    '        INTEGER) AS LONG
                    '    METHOD WindowModuleFileNameGet(BYVAL hWnd AS DWORD, BYREF ppszFileName AS WSTRINGZ) AS LONG
                    '    METHOD GlobalDictationGet(BYVAL hWndApp AS DWORD, BYREF INOUT pbEnabled AS LONG) AS LONG
                    '    METHOD GlobalDictationSet(BYVAL hWndApp AS DWORD, BYVAL bEnabled AS LONG) AS LONG
                    '    METHOD REGISTER(BYVAL dwFlags AS DWORD, BYREF IN riid AS GUID, BYVAL pNotifySinkUnk AS IUNKNOWN) AS LONG
                    '    METHOD SpeakerCreate(BYREF IN pszSpeakerName AS WSTRINGZ, BYREF IN pszSpeakerBasedOn AS WSTRINGZ) AS LONG
                    '    METHOD SpeakerModifiedGet(BYREF INOUT pbModified AS LONG) AS LONG
                    '    METHOD SpeakerTopicSelect(BYREF IN pszSpeaker AS WSTRINGZ, BYREF IN pszTopic AS WSTRINGZ) AS LONG
                    '    METHOD TopicCreate(BYREF IN pszSpeaker AS WSTRINGZ, BYREF IN pszTopic AS WSTRINGZ, BYREF IN pszTopicBasedOn AS WSTRINGZ) _
                    '        AS LONG
                    '    METHOD TopicDelete(BYREF IN pszReserved AS WSTRINGZ, BYREF IN pszTopic AS WSTRINGZ) AS LONG
                    '    METHOD TopicGet(BYREF ppTopic AS WSTRINGZ) AS LONG
                    '    METHOD TopicSet(BYREF IN pszTopic AS WSTRINGZ) AS LONG
                    '    METHOD TopicsGet(BYREF IN pszSpeaker AS WSTRINGZ, BYREF ppTopics AS WSTRINGZ, BYREF pdwSize AS DWORD) AS LONG
                    '    METHOD UnRegister(BYVAL bLockServer AS LONG) AS LONG
                    '    METHOD EngineUIGet(BYREF INOUT pEngineUI AS LONG) AS LONG
                    '    METHOD EngineUISet(BYVAL EngineUI AS LONG) AS LONG
                    '    METHOD RecognitionMimic(BYVAL dwNumWords AS DWORD, BYREF IN pWords AS WSTRINGZ, BYVAL dwSize AS DWORD, BYVAL dwParam AS _
                    '        DWORD) AS LONG
                    '    METHOD ISRCentralGet(BYREF INOUT ppUnk AS IUNKNOWN) AS LONG
                    '    METHOD SpeakerTrainedGet(BYVAL dwReserved AS DWORD, BYREF INOUT pbTrained AS LONG) AS LONG
                    '    METHOD EngineRunningGet(BYREF INOUT pbRunning AS LONG) AS LONG
                    '    METHOD LanguagesGet(BYREF ppLangs AS DWORD, BYREF pdwSize AS DWORD) AS LONG
                    '    METHOD SpeakerLanguageGet(BYREF IN pszSpeaker AS WSTRINGZ, BYREF INOUT pLang AS LONG) AS LONG
                    '    METHOD BaseSpeakerModelLanguageGet(BYREF IN pszBaseSpeakerModel AS WSTRINGZ, BYREF INOUT pLang AS LONG) AS LONG
                    '    METHOD BaseTopicModelLanguageGet(BYREF IN pszBaseTopicModel AS WSTRINGZ, BYREF INOUT pLang AS LONG) AS LONG
                    '    METHOD AudioSetupCompleteGet(BYREF INOUT pbComplete AS LONG) AS LONG
                    '    METHOD SpeakerCalibratedGet(BYREF INOUT pbCalibrated AS LONG) AS LONG
                    'END INTERFACE
                    '==========================================================================
                    
                    ' Interface Name  : IDgnMicBtn
                    ' Description     : IDgnMicBtn Interface
                    ' Class Name      : DgnMicBtn
                    ' ClassID         : $CLSID_DNSTools_DgnMicBtn
                    ' ProgID          : $PROGID_DNSTools_DgnMicBtn
                    ' Version ProgID  : $PROGID_DNSTools_DgnMicBtn1
                    INTERFACE IDgnMicBtn $IID_DNSTools_IDgnMicBtn
                        INHERIT IDISPATCH
                    
                        PROPERTY GET Enabled <1> () AS INTEGER
                        PROPERTY SET Enabled <1> (BYVAL Rhs AS INTEGER)
                        PROPERTY GET MicState <2> () AS LONG
                        PROPERTY SET MicState <2> (BYVAL Rhs AS LONG)
                        PROPERTY GET VUMeterNotify <3> () AS INTEGER
                        PROPERTY SET VUMeterNotify <3> (BYVAL Rhs AS INTEGER)
                        PROPERTY GET AutoRegister <4> () AS INTEGER
                        PROPERTY SET AutoRegister <4> (BYVAL Rhs AS INTEGER)
                        METHOD REGISTER <5> (OPT BYVAL Flags AS VARIANT)
                        METHOD UnRegister <6> ()
                        PROPERTY GET Paused <7> () AS INTEGER
                        METHOD WaveCaptureStart <8> (BYVAL WaveFilePath AS STRING)
                        METHOD WaveCaptureStop <9> ()
                        PROPERTY GET OPTION <10> (BYVAL PB_Option AS LONG) AS VARIANT
                        PROPERTY SET OPTION <10> (BYVAL PB_Option AS LONG, BYVAL Value AS VARIANT)
                    END INTERFACE
                          'for both property MicState above
                          '%DgnMicStateConstants_dgnmicOff = 1
                          '%DgnMicStateConstants_dgnmicOn = 2
                          '%DgnMicStateConstants_dgnmicSleeping = 3
                    
                    
                    
                    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
                    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                    
                    FUNCTION PBMAIN()
                       IF INSTR(COMMAND$,"?") THEN
                           commandlinehelp
                           EXIT FUNCTION
                       END IF
                    
                       'Gary Beene's instance checker
                       IF InstanceTest = 0 THEN EXIT FUNCTION
                    
                       gidialogwidth=18  'set default width of dailog
                       setwindowdimensions
                       IF GetDragonBarWindowHandle THEN GOTO LETSRUNTHEPROGRAMAGAIN_GOAROUND
                        WHILE GetDragonBarWindowHandle=0
                          SetPriorityToIdle
                          SLEEP 15000
                        WEND
                    
                    LETSRUNTHEPROGRAMAGAIN:
                        WHILE GetDragonBarWindowHandle=0
                          SetPriorityToIdle
                          SLEEP 8000
                        WEND
                    
                    LETSRUNTHEPROGRAMAGAIN_GOAROUND:
                        SetPriorityToBelowNormal
                        ghDlg=0
                        gimicrophonestatus=0
                        gidragonenginerunning=0
                        gdwdragonbarwindowhandleprior=1
                        gimicrophonestatusprior=-1
                        gidragonenginerunningprior=-1
                        gimicrophonestatusprior=-1
                        gidictationmodestatusprior=-1
                        giregistered_IDgnMicBtn=0
                        girunprogramagain=0
                        gsdictationmode=""
                        'set the previouse window handle to a variable
                        gdwwindowhandle=GetForeGroundWindow
                        IF (gdwwindowhandle<>ghdlg AND gdwwindowhandle<>0) THEN gdwwindowhandleprior=gdwwindowhandle
                    
                    
                        ShowDIALOG1 %HWND_DESKTOP
                    
                        removeobjectsfordragon
                        IF girunprogramagain THEN 'continue the program if dragon was close before this program manually closed
                           SetPriorityToIdle
                           SLEEP 12000
                           GOTO LETSRUNTHEPROGRAMAGAIN
                        END IF
                    
                    
                    END FUNCTION
                    
                    CALLBACK FUNCTION ShowDIALOG1Proc()
                    STATIC hTimer AS LONG
                    
                        SELECT CASE AS LONG CB.MSG
                            CASE %WM_INITDIALOG
                                ' Initialization handler
                                initalizedialog
                    
                                hTimer = SetTimer( CB.HNDL, 1, 300, CODEPTR(TimerProc) )
                    
                            CASE %WM_ACTIVATEAPP
                                'not using function SetPreviousWindowHandle  the code was placed here inline
                                 gdwwindowhandle=GetForeGroundWindow
                                 IF (gdwwindowhandle<>ghdlg AND gdwwindowhandle<>0) THEN gdwwindowhandleprior=gdwwindowhandle
                    
                                CASE %WM_NCACTIVATE
                                STATIC hWndSaveFocus AS DWORD
                                IF ISFALSE CB.WPARAM THEN
                                    ' Save control focus
                                    hWndSaveFocus = GetFocus()
                                ELSEIF hWndSaveFocus THEN
                                    ' Restore control focus
                                    SetFocus(hWndSaveFocus)
                                    hWndSaveFocus = 0
                                END IF
                    
                          CASE %WM_USER + 996
                                 KillTimer CB.HNDL, hTimer
                                 removeobjectsfordragon
                                 girunprogramagain=1
                                 DIALOG GET LOC CB.HNDL TO g_windowstartcolumn,g_windowstartrow
                                 DIALOG END CB.HNDL
                                 FUNCTION = 1
                    
                           CASE %WM_DESTROY
                                KillTimer CB.HNDL, hTimer
                                removeobjectsfordragon
                                 FUNCTION =1
                    
                            CASE %WM_COMMAND
                                ' Process control notifications
                    
                                SELECT CASE AS LONG CB.CTL
                                    CASE %IDC_LABEL1
                                        IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                            gichangeinprogress=1
                                            setpreviouswindowhandleactive
                                            IF GetDragonBarWindowHandle THEN
                                               togglemicophoneonoff
                                               updatedialogwithmicrophonestatus
                                            END IF
                                               gichangeinprogress=0
                                        END IF
                    
                                    CASE %IDC_LABEL2
                                        IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                            gichangeinprogress=1
                                            setpreviouswindowhandleactive
                                            IF GetDragonBarWindowHandle THEN
                                               microphonetosleep
                                               updatedialogwithmicrophonestatus
                                            END IF
                                            gichangeinprogress=0
                                        END IF
                    
                                    CASE %IDC_LABELMODE0    'Change to normal mode
                                        IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                            gichangeinprogress=1
                                            setpreviouswindowhandleactive
                                            IF GetDragonBarWindowHandle THEN
                                               SetDictationMode(0)
                                               updatedialogwithmicrophonestatus
                                            END IF
                                            gichangeinprogress=0
                                        END IF
                    
                    
                                    CASE %IDC_LABELMODE1   'change to dictation mode
                                        IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                            gichangeinprogress=1
                                            setpreviouswindowhandleactive
                                            IF GetDragonBarWindowHandle THEN
                                               SetDictationMode(1)
                                               updatedialogwithmicrophonestatus
                                            END IF
                                            gichangeinprogress=0
                                        END IF
                    
                                    CASE %IDC_LABELMODE2   'change to command mode
                                        IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                            gichangeinprogress=1
                                            setpreviouswindowhandleactive
                                            IF GetDragonBarWindowHandle THEN
                                               SetDictationMode(2)
                                               updatedialogwithmicrophonestatus
                                            END IF
                                            gichangeinprogress=0
                                        END IF
                    
                                    CASE %IDC_LABELMODE3    'change to number mode
                                        IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                            gichangeinprogress=1
                                            setpreviouswindowhandleactive
                                            IF GetDragonBarWindowHandle THEN
                                               SetDictationMode(3)
                                               updatedialogwithmicrophonestatus
                                            END IF
                                            gichangeinprogress=0
                                        END IF
                    
                                    CASE %IDC_LABELMODE4     'change to spell mode
                                        IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                            gichangeinprogress=1
                                            setpreviouswindowhandleactive
                                            IF GetDragonBarWindowHandle THEN
                                               SetDictationMode(4)
                                               updatedialogwithmicrophonestatus
                                            END IF
                                            gichangeinprogress=0
                                        END IF
                    
                                    'CASE %IDC_LABELMODE5      'change to mouse mode
                                    '    IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                    '        gichangeinprogress=1
                                    '        setpreviouswindowhandleactive
                                    '        IF GetDragonBarWindowHandle THEN
                                    '           SetDictationMode(5)
                                    '           updatedialogwithmicrophonestatus
                                    '        END IF
                                    '        gichangeinprogress=0
                                    '    END IF
                    
                    
                                    CASE %IDC_LABEL3
                                        IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                            setpreviouswindowhandleactive
                                            SetPriorityToIdle
                                            DIALOG MINIMIZE ghDlg
                                       END IF
                    
                                END SELECT
                        END SELECT
                    END FUNCTION
                    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                        LOCAL lRslt AS LONG
                        LOCAL hFont1 AS DWORD
                        LOCAL hFont2 AS DWORD
                        LOCAL hFont3 AS DWORD
                    
                        LOCAL hDlg  AS DWORD
                        IF gidialogwidth=0 THEN gidialogwidth=24
                        DIALOG NEW hParent, "Mic-", g_windowstartcolumn,g_windowstartrow, gidialogwidth, 156, %WS_POPUP OR %WS_BORDER _
                            OR %WS_DLGFRAME OR %WS_SYSMENU OR _   ' %WS_MINIMIZEBOX _
                            %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
                            %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
                            OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                        CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "Off", 0, 90, gidialogwidth, 24,_
                             %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR  %SS_CENTER OR %SS_CENTERIMAGE, %WS_EX_LEFT OR _
                             %WS_EX_LTRREADING
                        CONTROL ADD LABEL, hDlg, %IDC_LABEL2, "Nap", 0, 120, gidialogwidth, 32,_
                             %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_CENTERIMAGE,  %WS_EX_LEFT OR _
                             %WS_EX_LTRREADING
                    
                        CONTROL ADD LABEL,  hDlg, %IDC_LABEL3, "", 0, 0, gidialogwidth, 12, _
                             %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_CENTERIMAGE, %WS_EX_LEFT OR _
                             %WS_EX_LTRREADING
                        CONTROL ADD LABEL,  hDlg, %IDC_LABELMODE0, "Norm", 0, 16, gidialogwidth, 10, _
                             %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_CENTERIMAGE, %WS_EX_LEFT OR _
                             %WS_EX_LTRREADING
                        CONTROL ADD LABEL,  hDlg, %IDC_LABELMODE1, "Dict", 0, 30, gidialogwidth, 10, _
                             %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_CENTERIMAGE, %WS_EX_LEFT OR _
                             %WS_EX_LTRREADING
                        CONTROL ADD LABEL,  hDlg, %IDC_LABELMODE2, "Comm", 0, 44, gidialogwidth, 10, _
                             %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_CENTERIMAGE, %WS_EX_LEFT OR _
                             %WS_EX_LTRREADING
                        CONTROL ADD LABEL,  hDlg, %IDC_LABELMODE3, "Numb", 0, 58, gidialogwidth, 10, _
                             %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_CENTERIMAGE, %WS_EX_LEFT OR _
                             %WS_EX_LTRREADING
                        CONTROL ADD LABEL,  hDlg, %IDC_LABELMODE4, "Spell", 0, 72, gidialogwidth, 10, _
                             %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_CENTERIMAGE, %WS_EX_LEFT OR _
                             %WS_EX_LTRREADING
                    '    CONTROL ADD LABEL,  hDlg, %IDC_LABELMODE5, "Mouse", 0, 93, gidialogwidth, 12, _
                    '         %SS_NOTIFY OR  %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_CENTERIMAGE, %WS_EX_LEFT OR _
                    '         %WS_EX_LTRREADING
                    
                        FONT NEW "Arial", 7, 1, %ANSI_CHARSET TO hFont1
                        FONT NEW "Arial", 12, 1, %ANSI_CHARSET TO hFont2
                        FONT NEW "Arial", 7, 1, %ANSI_CHARSET TO hFont3
                        CONTROL SET FONT hDlg, %IDC_LABEL1, hFont1
                        CONTROL SET FONT hDlg, %IDC_LABEL2, hFont1
                        CONTROL SET FONT hDlg, %IDC_LABEL3, hFont2
                        CONTROL SET FONT hDlg, %IDC_LABELMODE0, hFont3
                        CONTROL SET FONT hDlg, %IDC_LABELMODE1, hFont3
                        CONTROL SET FONT hDlg, %IDC_LABELMODE2, hFont3
                        CONTROL SET FONT hDlg, %IDC_LABELMODE3, hFont3
                        CONTROL SET FONT hDlg, %IDC_LABELMODE4, hFont3
                     '   CONTROL SET FONT hDlg, %IDC_LABELMODE5, hFont3
                    
                    
                    
                        ghDlg=hDlg
                        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                    
                         FONT END hFont1
                         FONT END hFont2
                         FONT END hFont3
                    
                    
                        FUNCTION = lRslt
                    END FUNCTION
                    
                    
                    FUNCTION TimerProc( BYVAL hDlg AS LONG, BYVAL Msg AS LONG, BYVAL EvntID AS LONG, BYVAL Time AS LONG ) AS LONG
                       ' IF gichangeinprogress THEN EXIT FUNCTION   'this line is mostly for future use with a thread running the timer
                    
                        'not using function SetPreviousWindowHandle  code was placed here inline
                        gdwwindowhandle=GetForeGroundWindow
                        IF (gdwwindowhandle<>ghdlg AND gdwwindowhandle<>0) THEN gdwwindowhandleprior=gdwwindowhandle
                        IF GetDictationMode<>gidictationmodestatusprior THEN displaydictationmode
                        IF gdwdragonbarwindowhandle<> GetDragonBarWindowHandle THEN
                             makeadjustmentsifdragonbarchangesitswindowhandle
                             EXIT FUNCTION
                        END IF
                    
                        'IF gichangeinprogress THEN EXIT FUNCTION   'this line is mostly for future use with a thread running the timer
                        'update the dialog if dragon changes the microphone status
                        updatedialogwithmicrophonestatus
                     END FUNCTION 'TimerProc
                    
                    
                    FUNCTION dragonmicrophonebtncontrol(BYVAL itodo AS LONG,BYVAL imicphonechangestate AS LONG) AS LONG
                    'if itodo equal 0 then return the state of the microphone
                    'if itodo equal 1 then change the state of the microphone
                       STATIC iregistered AS LONG
                       LOCAL iresult AS LONG
                         FUNCTION=-1
                         IF ISFALSE ISOBJECT( objvar_IDgnMicBtn ) THEN
                                  objvar_IDgnMicBtn = NEWCOM $PROGID_DNSTools_DgnMicBtn
                           END IF
                         IF ISNOTHING( objvar_IDgnMicBtn ) OR ERR THEN
                            EXIT FUNCTION
                         END IF
                         IF ISFALSE ISOBJECT( objvar_IDgnMicBtn ) THEN
                            EXIT FUNCTION
                         END IF
                         IF ISFALSE giregistered_IDgnMicBtn THEN
                              objvar_IDgnMicBtn.REGISTER
                              giregistered_IDgnMicBtn=1
                         END IF
                    
                         SELECT CASE itodo
                             CASE 0
                               iresult=objvar_IDgnMicBtn.MicState()
                             CASE 1
                               objvar_IDgnMicBtn.MicState=imicphonechangestate
                               iresult=imicphonechangestate
                         END SELECT
                     '     objvar_IDgnMicBtn.UnRegister
                          '%DgnMicStateConstants_dgnmicOff = 1
                          '%DgnMicStateConstants_dgnmicOn = 2
                          '%DgnMicStateConstants_dgnmicSleeping = 3
                          FUNCTION=iresult
                    END FUNCTION
                    
                    
                    FUNCTION togglemicophoneonoff() AS LONG
                        CONTROL DISABLE ghDlg, %IDC_LABEL1
                        CONTROL DISABLE ghDlg, %IDC_LABEL2
                        IF microphoneready THEN
                           IF dragonmicrophonebtncontrol(0,0)<>1 THEN
                              dragonmicrophonebtncontrol(1,1)
                           ELSE
                              dragonmicrophonebtncontrol(1,2)
                           END IF
                        END IF
                        CONTROL ENABLE ghDlg, %IDC_LABEL2
                        CONTROL ENABLE ghDlg, %IDC_LABEL1
                    END FUNCTION
                    
                    FUNCTION microphonetosleep() AS LONG
                        CONTROL DISABLE ghDlg, %IDC_LABEL2
                        CONTROL DISABLE ghDlg, %IDC_LABEL1
                        IF microphoneready THEN
                           IF dragonmicrophonebtncontrol(0,0)<>3 THEN
                              dragonmicrophonebtncontrol(1,3)
                           ELSE
                              dragonmicrophonebtncontrol(1,2)
                           END IF
                        END IF
                        CONTROL ENABLE  ghDlg, %IDC_LABEL1
                        CONTROL ENABLE  ghDlg, %IDC_LABEL2
                    END FUNCTION
                    
                    
                    
                    FUNCTION microphoneready() AS LONG  'check the status of the micphone to make sure it is not disabled,paused
                           LOCAL iresult AS LONG
                           iresult=dragonmicrophonebtncontrol(0,0)
                           IF iresult>0 AND iresult<4 THEN
                               FUNCTION=1
                           END IF
                    END FUNCTION
                    
                    
                    FUNCTION GetDragonBarWindowHandle() AS DWORD
                        FUNCTION=FindWindowEx( BYVAL 0,BYVAL 0, "DgnBarMainWindowCls", "" )
                    END FUNCTION
                    
                    FUNCTION dialogsetalwaysontop() AS LONG
                         SetWindowPos ghDlg, %HWND_TOPMOST, 0,0,0,0, %SWP_NOMOVE OR %SWP_NOSIZE  'set the dialog to always on top
                    END FUNCTION
                    
                    
                    FUNCTION InstanceTest() AS LONG
                       'returns 0 if instance exits or cannot create mutex. otherwise returns 1.
                       LOCAL UniqueName AS ASCIIZ * %MAX_PATH
                       UniqueName = "pdpdragonmicophonestatus"                     '
                       IF CreateMutex(BYVAL %Null, 0, UniqueName) = 0 OR GetLastError = %ERROR_ALREADY_EXISTS THEN EXIT FUNCTION  ELSE FUNCTION = 1
                    END FUNCTION
                    
                    FUNCTION setwindowdimensions() AS LONG
                       LOCAL stemp AS STRING
                       g_windowstartcolumn=3000
                       g_windowstartrow=240
                       stemp=TRIM$(COMMAND$(1))
                       IF LEN(stemp) THEN
                           stemp=RETAIN$(stemp, ANY "0123456789")
                           IF stemp=TRIM$(COMMAND$(1)) THEN  g_windowstartcolumn=VAL(COMMAND$(1))
                       END IF
                       stemp=TRIM$(COMMAND$(2))
                       IF LEN(stemp) THEN
                           stemp=RETAIN$(stemp, ANY "0123456789")
                           IF stemp=TRIM$(COMMAND$(2)) THEN  g_windowstartrow=VAL(COMMAND$(2))
                       END IF
                      IF g_windowstartcolumn<1 THEN g_windowstartcolumn=1
                      IF g_windowstartrow<1 THEN g_windowstartrow=1
                      IF INSTR(LCASE$(COMMAND$),"skinny") THEN gidialogwidth=12 'gidialogwidth*1.5
                      IF INSTR(LCASE$(COMMAND$),"fat") THEN gidialogwidth=18 'gidialogwidth*1.5
                      IF INSTR(LCASE$(COMMAND$),"normal") THEN gidialogwidth=18 'gidialogwidth*1.5
                      IF INSTR(LCASE$(COMMAND$),"huge") THEN gidialogwidth=24 'gidialogwidth*2
                      IF INSTR(LCASE$(COMMAND$),"ontop") THEN gialwaysontop=1
                    END FUNCTION
                    FUNCTION commandlinehelp() AS LONG
                          LOCAL stemp AS STRING
                          stemp ="The purpose of this program is to control or monitor the microphone"+$CRLF+_
                                 "for Dragon Naturally Speaking software. Version 12,13 and 15 have been tested"+$CRLF+_
                                 "There is no guarantee that this program will work or not cause computer realted issues."+$CRLF+_
                                 "The user assumes and accepts all risk while using this software."+$CRLF+$CRLF+_
                                 "You can place on the command tail a few options."+$CRLF+_
                                 "If you want to place the dialog at a certain postion."+$CRLF+_
                                 "You must place the column number as the first parameter and"+$CRLF+_
                                 "the row as the second parameter."+$CRLF+_
                                 "The dialog can be keep always on top-use the word ontop."+$CRLF+_
                                 "To make the dialog narrow-use the the word skinny."+$CRLF+_
                                 "To make the dialog wider-use the word huge"+$CRLF+_
                                 "To make the dialog nornal width-use the word fat or normal."+$CRLF+$CRLF+_
                                 "Press on the color to minimize the dialog."+$CRLF+$CRLF+_
                                 "Note: only one instance of this program will run at a time."
                          MSGBOX stemp,%MB_OK,EXE.NAME$
                    END FUNCTION
                    
                    
                    
                    FUNCTION removeobjectsfordragon () AS LONG
                       IF giregistered_IDgnMicBtn THEN
                          IF ISOBJECT( objvar_IDgnMicBtn ) THEN
                              objvar_IDgnMicBtn.UnRegister    'you must use unregister to keep natspeak from being loaded in memory
                              objvar_IDgnMicBtn=NOTHING
                           END IF
                          giregistered_IDgnMicBtn=0
                        END IF
                       IF giobjectstate_IDgnEngine THEN
                          IF ISOBJECT( objvar_IDgnEngine ) THEN
                              objvar_IDgnEngine = NOTHING
                          END IF
                          giobjectstate_IDgnEngine=0
                       END IF
                    'removed code
                    '==========================================================================
                    '    IF ISOBJECT( objvar_IDgnEngineControlW ) THEN objvar_IDgnEngineControlW = NOTHING
                    '==========================================================================
                    END FUNCTION
                    
                    
                    FUNCTION SetPriorityToIdle() AS LONG
                    'provided by Knuth Konrad
                        ' Constants for SetPriorityClass
                        '%NORMAL_PRIORITY_CLASS             = &H00000020
                        '%IDLE_PRIORITY_CLASS               = &H00000040
                        '%HIGH_PRIORITY_CLASS               = &H00000080
                        '%REALTIME_PRIORITY_CLASS           = &H00000100 <-- Be EXTREMLY careful with that one. I recommend to just not use it.
                        '%BELOW_NORMAL_PRIORITY_CLASS       = &H00004000
                        '%ABOVE_NORMAL_PRIORITY_CLASS       = &H00008000
                        'hProcess = GetCurrentProcess()
                        'lRetval = SetPriorityClass(hProcess, %BELOW_NORMAL_PRIORITY_CLASS)
                      LOCAL hProcess AS LONG
                      LOCAL lRetval AS LONG
                        hProcess = GetCurrentProcess()
                        lRetval = SetPriorityClass(hProcess, %IDLE_PRIORITY_CLASS)
                    END FUNCTION
                    
                    FUNCTION SetPriorityToBelowNormal() AS LONG
                      LOCAL hProcess AS LONG
                      LOCAL lRetval AS LONG
                        hProcess = GetCurrentProcess()
                        lRetval = SetPriorityClass(hProcess, %BELOW_NORMAL_PRIORITY_CLASS)
                    END FUNCTION
                    
                    FUNCTION setpreviouswindowhandleactive() AS LONG
                        IF gdwwindowhandleprior AND gdwwindowhandleprior<>ghdlg THEN
                           IF IsIconic(gdwwindowhandleprior)=0 THEN
                              setforegroundwindow(gdwwindowhandleprior)
                              setactivewindow(gdwwindowhandleprior)
                           END IF
                        END IF
                    END FUNCTION
                    
                    FUNCTION updatedialogwithmicrophonestatus() AS LONG
                    'code remove for now and hoping the dragonbarwindow test makes this code not needed
                    '    IF ISFALSE ISOBJECT( objvar_IDgnEngineControlW ) THEN
                    '          objvar_IDgnEngineControlW = NEWCOM $PROGID_DNSTools_DgnEngineControl
                    '     END IF
                    '    objvar_IDgnEngineControlW.EngineRunningGet(gidragonenginerunning)
                    '    IF gidragonenginerunning<>gidragonenginerunningprior THEN
                    '        IF gidragonenginerunning THEN
                    '           gidragonenginerunningprior=1
                    '           gichangeinprogress=0
                    '           SetPriorityToBelowNormal
                    '           DIALOG NORMALIZE ghDlg
                    '        ELSE
                    '           gidragonenginerunningprior=0
                    '           SetPriorityToIdle
                    '           DIALOG HIDE ghDlg
                    '           CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_BLACK
                    '           EXIT FUNCTION
                    '        END IF
                    '    END IF
                        gimicrophonestatus=dragonmicrophonebtncontrol(0,0)
                        IF gimicrophonestatusprior=gimicrophonestatus THEN EXIT FUNCTION
                        gimicrophonestatusprior=gimicrophonestatus
                        SELECT CASE gimicrophonestatus
                            CASE 1
                                 gsmicrophonestate="Off"
                                 DIALOG SET TEXT ghDlg, "Mic-"+gsmicrophonestate+"-"+gsdictationmode
                                 CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, RGB(253,96,167) '%RGB_WILDWATERMELON is not this color
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL1, "On"
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL2, "Nap"
                            CASE 2
                                 gsmicrophonestate="On"
                                 DIALOG SET TEXT ghDlg, "Mic-"+gsmicrophonestate+"-"+gsdictationmode
                                 CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, RGB(153,255,0) '%RGB_LIME
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL1, "Off"
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL2, "Nap"
                            CASE 3
                                 gsmicrophonestate="Asleep"
                                 DIALOG SET TEXT ghDlg, "Mic-"+gsmicrophonestate+"-"+gsdictationmode
                                 CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_YELLOW '%RGB_SANDYBROWN
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL1, "Off"
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL2, "On"
                            CASE ELSE
                                 gsmicrophonestate=""
                                 DIALOG SET TEXT ghDlg, "Mic"
                                 CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_WHITE
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL1, ""
                                 CONTROL SET TEXT  ghDlg, %IDC_LABEL2, ""
                        END SELECT
                           'DIALOG REDRAW ghDlg
                            CONTROL REDRAW   ghDlg, %IDC_LABEL1
                            CONTROL REDRAW   ghDlg, %IDC_LABEL2
                            CONTROL REDRAW   ghDlg, %IDC_LABEL3
                    END FUNCTION
                    
                    'did not use this code because it was placed inline to remove cpu cycles
                    'function SetPreviousWindowHandle() as long
                    '    gdwwindowhandle=GetForeGroundWindow
                    '    IF gdwwindowhandle THEN
                    '        if gdwwindowhandle <> ghdlg then gdwwindowhandleprior=gdwwindowhandle
                    '   end if
                    'end function
                    
                    'function for fading the dialog
                    'FUNCTION  fadedialog(byval ifadpercent as long) as long
                    '   SetWindowLong(ghDlg, %GWL_EXSTYLE,  GetWindowLong(ghDlg, %GWL_EXSTYLE) OR %WS_EX_LAYERED)
                    '   SetLayeredWindowAttributes(ghDlg, 0, (255 * ifadpercent) / 100, %LWA_ALPHA)
                    'END FUNCTION
                    
                    
                    FUNCTION makeadjustmentsifdragonbarchangesitswindowhandle()AS LONG
                        gdwdragonbarwindowhandle=GetDragonBarWindowHandle
                        IF gdwdragonbarwindowhandle THEN
                            IF gdwdragonbarwindowhandle<>gdwdragonbarwindowhandleprior THEN
                                   gdwdragonbarwindowhandleprior=gdwdragonbarwindowhandle
                                   gichangeinprogress=0
                                   SetPriorityToBelowNormal
                                   DIALOG NORMALIZE ghDlg
                            END IF
                        ELSE
                         'dragonbarwindow in dragon is not running  remove the dialog and idle till dragon bar window starts back up
                         '  IF gdwdragonbarwindowhandleprior=gdwdragonbarwindowhandle THEN EXIT FUNCTION 'this line is not needed
                           gdwdragonbarwindowhandleprior=0 'gdwdragonbarwindowhandle
                           gichangeinprogress=0
                           CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_WHITE
                           SetPriorityToIdle
                           DIALOG HIDE ghDlg
                           DIALOG POST ghDlg, %WM_USER+996,0,0
                           EXIT FUNCTION
                        END IF
                    END FUNCTION
                    
                    
                    FUNCTION GetDictationMode() AS LONG
                        IF giobjectstate_IDgnEngine=0 THEN loadobjectIDgnEngine
                        FUNCTION=objvar_IDgnEngine.RecognitionMode()
                    END FUNCTION
                    
                    FUNCTION SetDictationMode(BYVAL idictationmode AS LONG) AS LONG
                        IF giobjectstate_IDgnEngine=0 THEN loadobjectIDgnEngine
                        objvar_IDgnEngine.RecognitionMode=idictationmode
                    END FUNCTION
                    
                    
                    FUNCTION displaydictationmode()AS LONG
                       LOCAL stext AS STRING
                            gidictationmodestatusprior=GetDictationMode
                            stext=""
                    
                            SELECT CASE  gidictationmodestatusprior
                             CASE 0
                                 stext="N"
                                 gsdictationmode="normal"
                             CASE 1
                                 stext="D"
                                 gsdictationmode="dictate"
                             CASE 2
                                 stext="C"
                                 gsdictationmode="command"
                             CASE 3
                                 stext="#"
                                 gsdictationmode="number"
                             CASE 4
                                 stext="S"
                                 gsdictationmode="spell"
                             CASE 5
                                 stext="mouse"
                                 gsdictationmode="mouse"
                             CASE ELSE
                                 gsdictationmode=""
                            END SELECT
                            CONTROL SET TEXT ghDlg, %IDC_LABEL3, stext
                            DIALOG SET TEXT ghDlg, "Mic-"+gsmicrophonestate+"-"+gsdictationmode
                    
                    END FUNCTION
                    
                    
                    
                    FUNCTION loadobjectIDgnEngine() AS LONG
                        IF ISFALSE ISOBJECT( objvar_IDgnEngine ) THEN
                              objvar_IDgnEngine = NEWCOM $PROGID_DNSTools_DgnEngineControl
                         END IF
                         IF ISFALSE giobjectstate_IDgnEngine THEN
                              giobjectstate_IDgnEngine=1
                         END IF
                    END FUNCTION
                    
                    
                    FUNCTION initalizedialog() AS LONG
                                  setpreviouswindowhandleactive
                                gichangeinprogress=0
                                SetPriorityToIdle
                                'dialogfader(90) 'function is remarked out below
                                DIALOG HIDE ghDlg   'hide the dialog to start
                                DIALOG SET COLOR ghDlg, %RGB_DODGERBLUE,  %RGB_DODGERBLUE
                                CONTROL SET COLOR ghDlg, %IDC_LABEL1, %RGB_WHITE, %RGB_BLACK
                                CONTROL SET COLOR ghDlg, %IDC_LABEL2, %RGB_BLACK, %RGB_SANDYBROWN
                                CONTROL SET COLOR ghDlg, %IDC_LABEL3, %RGB_BLACK, %RGB_BLACK
                                IF gialwaysontop THEN dialogsetalwaysontop
                                IF gidialogwidth=12 THEN
                                   CONTROL SET TEXT  ghDlg, %IDC_LABELMODE0, "Nor"
                                   CONTROL SET TEXT  ghDlg, %IDC_LABELMODE1, "Dict"
                                   CONTROL SET TEXT  ghDlg, %IDC_LABELMODE2, "Cmd"
                                   CONTROL SET TEXT  ghDlg, %IDC_LABELMODE3, "# #"
                                   CONTROL SET TEXT  ghDlg, %IDC_LABELMODE4, "Spl"
                                  ' CONTROL SET TEXT  ghDlg, %IDC_LABELMODE5, "M"
                                END IF
                    
                                IF gidialogwidth=24 THEN
                                   CONTROL SET TEXT  ghDlg, %IDC_LABELMODE0, "Normal"
                                   CONTROL SET TEXT  ghDlg, %IDC_LABELMODE1, "Dictate"
                                   CONTROL SET TEXT  ghDlg, %IDC_LABELMODE2, "Comand"
                                   CONTROL SET TEXT  ghDlg, %IDC_LABELMODE3, "Number"
                                   CONTROL SET TEXT  ghDlg, %IDC_LABELMODE4, "Spell"
                                  ' CONTROL SET TEXT  ghDlg, %IDC_LABELMODE5, "Mouse"
                                END IF
                    END FUNCTION
                    Attached Files
                    p purvis

                    Comment

                    Working...
                    X