KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Auto numbering websites using Dragon States
Topic Summary: Using SetState to keep track of what is being numbered
Created On: 09/16/2020 11:24 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 Auto numbering websites using Dragon States   - PG LTU - 09/16/2020 11:24 PM  
 Auto numbering websites using Dragon States   - Alan Cantor - 09/17/2020 12:07 AM  
 Auto numbering websites using Dragon States   - PG LTU - 09/17/2020 12:45 AM  
 Auto numbering websites using Dragon States   - Mav - 09/17/2020 03:12 AM  
 Auto numbering websites using Dragon States   - wristofdoom - 02/12/2022 11:37 AM  
Keyword
 09/16/2020 11:24 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2202
Joined: 03/21/2007

Thanks to a paricular odd suggestion by Mav about using States to store information got me thinking.  Here to show the potential is a set of browser "numbering" commands that use State to keep track of what is being numbered. 

 

So the application-specific command (for edge or chrome, etc or one app-specific commands for each) is "Pick [browsercontrol]" and it numbers all the matching browser elements from this list:

 

Button

Check

Check Box

Edit

Edit Box

Image

Link

Radio

Radio Button

Text

Text Field

 

 

and it sets the State to that element type.

 

Here is the command:

 

Sub Main

    If GetState <> "" Then Wait 2.5
    EngineControl.RecognitionMimic("click " & LCase(ListVar1))
    SetState Left(ListVar1, InStr(ListVar1 & " ", " ") -1)
End Sub

 

 

Now the fun part.  The application-specific command to choose the number is "Pick [1to200]" but you have to also add the following States as well: 

 

Button, Check, Edit, Image, Link, Radio, and Text

 

and the command will click the numbered element and go to the new page and then renumber all the elements on the new page (by seeing what the state is that the earlier commnd set).  Here's that command:

 

Sub Main

    EngineControl.RecognitionMimic("choose " & Left(ListVar1, InStr(ListVar1 & "\","\")-1))
    EngineControl.RecognitionMimic("pick " & GetState)
End Sub

 

 

Lemme know if you try it...



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




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



 09/17/2020 12:07 AM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4313
Joined: 12/08/2007

The recent mention of states got me wondering, and a few days ago, I sort-of figured out how to take advantage of states.

The first command provides an easier way to navigate in drop-down lists within Word documents. These drop downs are not particularly Dragon friendly. This command sets a state.

The second command is only recognized when the state has been set by the first command. The name of the second command is "OK". The command accepts the selected item on the drop-down, navigates to the next drop-down list, and then opens another drop-down list. When this command runs, the state is turned off.

This means "OK" is recognized as a command in drop-down lists in Microsoft Word documents, but as a regular word in a Word document.

Command: Jump To <1-5>

Sub Main

' Do something

SetState "drop-down-focused"
End Sub

Command: OK
[Recognizable in State drop-down-focused]

Sub Main
SendKeys "{Enter}"
SendKeys "{Tab}", True
SendSystemKeys "{Alt+Down}"

SetState ""

End Sub
 09/17/2020 12:45 AM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2202
Joined: 03/21/2007

Cool. If you really want to learn states, check out the Sample structured state commands and compare the WordPad to the Dragon Pad approaches.

My commands are not about that, so much as using the name of the state as info to be used in the command - essentially storing info about the type of element to be numbered by some later-called subsequent command.

My first command both numbers the particular browser elements, and sets one of the six states depending on the list (and particularly the first word of the list element). And the second command works *Only* if one of those six states are indeed active; and if so, "chooses" the numbered element (by looking at the [1to200] list, which can be normal or complex or a mix of both), effectively clicking on it to bring up a new page (or focus on an element), and then calls that first numbering command again using the State that was set as the [browsercontrol] list result so the same element types are numbered on the new page.

 

Note, this is all Dragon's built-in numbering and no fancy add-ons required - I can even do it at work!

Have fun.



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




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



 09/17/2020 03:12 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 501
Joined: 10/02/2008

Cool!

I've looked at the state sample commands and also found that you can only SetState for states which have be defined in voice commands outside the script, defying the idea to use dynamic values for states.

Did you find a way to create a voice command from within a script that's bound to a certain state?

 

mav

 02/12/2022 11:37 AM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Top-Tier Member

Posts: 322
Joined: 09/03/2020

I would love some way to use states with the global scope, so that a set of state-based commands would work across various applications when I'm doing certain types of work.

For example, when I say "heading one", that could mean different things depending on whether I am writing in plain text, HTML, or markdown.

But it seems like is limited to Application-specific commands. (I wonder why?)

Is there any sort of workaround that would allow me to set a stay globally? I tried creating a command called `set global state` that set a new variable myGlobalState to "testing" and then created a completely separate command called `print global state` that does `Sendkeys myGlobalState` but that didn't work. I understand why we would want to have variables scoped within an individual command, but is there some way to make a variable global?


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

Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017.

Statistics
32305 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 458 guests browsing this forum, which makes a total of 458 users using this forum.

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