KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: "Switch to" not working in script using HeardWord
Topic Summary: A specific app doesn't respond to HeardWord
Created On: 03/12/2021 04:13 AM
Status: Post and Reply
Linear : Threading : Single : Branch
 "Switch to" not working in script using HeardWord   - carningli - 03/12/2021 04:13 AM  
 "Switch to" not working in script using HeardWord   - Mav - 03/12/2021 04:45 AM  
 "Switch to" not working in script using HeardWord   - carningli - 03/12/2021 05:12 AM  
 "Switch to" not working in script using HeardWord   - Mav - 03/12/2021 06:08 AM  
 "Switch to" not working in script using HeardWord   - monkey8 - 03/12/2021 06:15 AM  
 "Switch to" not working in script using HeardWord   - carningli - 03/12/2021 03:19 PM  
 "Switch to" not working in script using HeardWord   - Alan Cantor - 03/12/2021 07:52 AM  
 "Switch to" not working in script using HeardWord   - dilligence - 03/12/2021 11:16 AM  
Keyword
 03/12/2021 04:13 AM
User is offline View Users Profile Print this message

Author Icon
carningli
New Member

Posts: 15
Joined: 02/08/2017

If I say "Switch to Memsource Editor", the Memsource Editor application screen is activated and brought to the front, as one would expect.

If I use the script below, it does not switch to the Memsource Editor screen. It does switch successfully to Notepad after the wait clause. It makes no difference whether the Notepad part is there or not.

I cannot work out why "Switch to Memsource Editor" works in normal speech but not in the script - any ideas?

Thanks

Dan

 

'#Language "WWB-COM"

Option Explicit

Sub Main
    HeardWord "Switch", "to", "Memsource", "Editor"
    Wait 0.5
    HeardWord "Switch", "to", "Notepad"
End Sub

 03/12/2021 04:45 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 426
Joined: 10/02/2008

Have you tried

HeardWord "Switch", "to", "Memsource"

instead of using 4 words?

I think Dragon uses a prefix search for the application name.

 

You could also use the AppSwapWith command directly instead of emulating a recognition of this very command.

 

hth,

mav

 

 

 03/12/2021 05:12 AM
User is offline View Users Profile Print this message

Author Icon
carningli
New Member

Posts: 15
Joined: 02/08/2017

Originally posted by: Mav Have you tried

...instead of using 4 words?

Thanks Mav. Three words doesn't work, and AppSwapWith seems not to do anything. Tried with AppBringUp but that started a separate instance.

Dan

 

 

 03/12/2021 06:08 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 426
Joined: 10/02/2008

It's hard to tell what Dragon is looking at exactly if you try to reference a visible window.

Could be the executable name, the description, part of the window title or even some other details.

If you find your Memsource editor executable and look at the properties for this file, you should be able to at least see the executable name and the description. Does it work if you use one of these properties as application name?

I've tried switching to a Word windows using different names (switch to Word, switch to Microsoft Word, switch to Winword, switch to Example.docx) and all variants worked.

Perhaps you can look up what Dragon actually recognized when you said "switch to memsource editor" in the recognition history and use this information for your command.

 

I guess the reason why AppBringUp starts a new instance is that you don't know which appName (the first parameter) Dragon assigned to the running instance.

Will subsequent AppBringUp commands at least bring up the second instance instead of starting a third/fourth/... one?

 

hth,

mav

 03/12/2021 06:15 AM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 3816
Joined: 01/14/2008

Try the following:
HeardWord "Switch", "to", "Memsource Editor"
If that doesn't work the following should:
Sub Main
    Dim EngineControl As New DgnEngineControl
    EngineControl.Register
    EngineControl.RecognitionMimic "Switch to Memsource Editor"
End Sub

This is all presuming that the capitalisation you see in the results box when the command works by voice is matching what is in the RecognitionMimic quotation marks in the script.



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



 03/12/2021 03:19 PM
User is offline View Users Profile Print this message

Author Icon
carningli
New Member

Posts: 15
Joined: 02/08/2017

Originally posted by: monkey8

Try the following:
HeardWord "Switch", "to", "Memsource Editor"
Thank you, this seemed to have fixed it.
Thanks also to everybody else who commented. All grist to the mill!
Dan
 03/12/2021 07:52 AM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4155
Joined: 12/08/2007

Whenever I've used HeardWord to switch windows, the word "switch" has been lowercase.

 03/12/2021 11:16 AM
User is offline View Users Profile Print this message

Author Icon
dilligence
Top-Tier Member

Posts: 1407
Joined: 08/16/2010

With the Advanced Application Activation module in SP 6 PRO there is no need to write scripts. You can natively activate *ANYTHING* you see in the taskbar: program windows, files, folders, MSG boxes, pop-ups.

 

The cool part is that it mostly dynamically adjusts if your window name changes. You won't even have to use the complete window or application name. In case of Memsource Editor any of the following commands will work to bring it to the front (our prefix is "Focus"):

 

focus Mem

focus source

focus editor

focus source editor

 

It will even work with child/sub/pop-up windows that are opened but not even visible in the taskbar, like for instance the Memsource Preferences window. In that case "Focus Preferences" or even "Focus Prefs" will work.

 

When it comes to Notepad a simple "Focus note" will work to activate the window. You can even focus that window by calling the "*" in front of the window name in the notepad: "Focus asterix", or use the notepad file name itself.

 

Contrary to the Dragon switch to <application> commands  SP Advanced Application Activation also supports multiple windows of the same application. It doesn't matter how many of them you have opened. As long as they are visible in the taskbar.

 

And if you do want to include any of the SP commands in a scripting command then you can easily create a fast DVC command:

 

HeardWord "Focus","Mem"

Wait 500

HeardWord "Focus","note"

 

You can see the module in action here



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


Auto Box© Demo now available



Statistics
32132 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 0 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 448 guests browsing this forum, which makes a total of 448 users using this forum.

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