KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: A Couple of Know-Brainer Scripting Questions
Topic Summary: Insert Date in Word07, and use argument to select macro to invoke
Created On: 11/10/2008 11:23 AM
Status: Post and Reply
Linear : Threading : Single : Branch
 A Couple of Know-Brainer Scripting Questions   - pdberger - 11/10/2008 11:23 AM  
 A Couple of Know-Brainer Scripting Questions   - R. Wilke - 11/10/2008 06:34 PM  
 A Couple of Know-Brainer Scripting Questions   - pdberger - 11/10/2008 08:52 PM  
 A Couple of Know-Brainer Scripting Questions   - Lunis Orcutt - 11/11/2008 01:22 AM  
 A Couple of Know-Brainer Scripting Questions   - pdberger - 11/11/2008 11:12 AM  
 A Couple of Know-Brainer Scripting Questions   - Lunis Orcutt - 11/13/2008 04:48 AM  
 A Couple of Know-Brainer Scripting Questions   - pdberger - 11/14/2008 12:18 AM  
 A Couple of Know-Brainer Scripting Questions   - edmart - 11/15/2008 02:54 AM  
 A Couple of Know-Brainer Scripting Questions   - pdberger - 11/16/2008 10:32 AM  
 A Couple of Know-Brainer Scripting Questions   - edmart - 11/16/2008 10:53 AM  
 A Couple of Know-Brainer Scripting Questions   - Jomark - 11/16/2008 02:16 PM  
Keyword
 11/10/2008 11:23 AM
User is offline View Users Profile Print this message


pdberger
Junior Member

Posts: 10
Joined: 10/06/2008

I would like to create a script in which I say, "Letter to John" and it creates the following:

[Today's Date]

John Q. Doe
123 Main St.
Anywhere, KS   34567

Dear John;

I'd be able to use the same script for Jim, Sam, Mary, Janet, and Fred, each time picking up the correct name and address.  I've created Dragon macros called "John Header", "Jim Header", "Sam Header", etc.  So an overall macro should insert the date, then select the correct header information.

I have two problems:

  1. I can't get the "insert date" to work correctly.  When I dictate "Insert Date" in Word 07, it opens up the date window but I then have to say, "Click OK".  I created the following script, which doesn't work:

HeardWord "insert" ;"date"
Wait 1000
ControlPick "OK"

and I get an error message saying it can't find the 'OK' button to click.  What's the problem?  Do I need to switch window focus?  If so, how?

   2.  How do I use the "John"?  Is that part of a SendKeys command, or a HeardWord command?

I think once I understand these two problems, I'll be able to do a whole bunch of other things I've got planned...

Thanks in advance.

 11/10/2008 06:34 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 4391
Joined: 03/04/2007

Quote:
2. How do I use the "John"? Is that part of a SendKeys command, or a HeardWord command?

No, for this you have to use a list command, I'm not sure how you can use this in Knowbrainer, might be something like <listvar ...>, try looking it up, otherwise, it might be done via Advanced Scripting using utility.provider...

At any event, you have define lists containing entries like "John", "Jerry", or whatever.

Rüdiger



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

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

 11/10/2008 08:52 PM
User is offline View Users Profile Print this message


pdberger
Junior Member

Posts: 10
Joined: 10/06/2008

Yep, I figured it would be something like that.  Just not sure if it's

HeardWord "Letter";"to";"<listvar"

or some other technique.

Any thoughts on the Insert Date problem?

Thanks for your help.

 11/11/2008 01:22 AM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 22612
Joined: 10/01/2006

Our 1st example would be the simplest solution where you create a separate command for each address. Note that KnowBrainer also includes a hidden Todays Date command which is different from the NaturallySpeaking embedded insert date command. See following:

HeardWord "Todays","Date"
Wait 500
SendKeys "{Enter 2}John Doe{Enter}123 Main St.{Enter}Winfield, KS 67156{Enter 2}Dear John;"

The following is a repair of your original code. Note that your original code is actually correct but unfortunately NaturallySpeaking has a difficult time with ControlPick “OK” so we recommend avoiding it entirely by substituting something like the following:

HeardWord "insert","date"
Wait 1000
SendKeys "{Enter}"


If you prefer the 2nd form of the Microsoft Word date command you could alternatively substitute the following:

HeardWord "insert","date"
Wait 1000
SendKeys "{Down}{Enter}"


Listing commands require 2 separate commands. The 1st command would be called something like
<Personal> Greeting and look as follows:

HeardWord "Todays","Date"
Wait 500
If _arg1 = "Makers" then SendKeys "{Enter 2}Makers Mark{Enter}123 Main St.{Enter}Winfield, KS 67156{Enter 2}Dear John;"
If _arg1 = "Jim" then SendKeys "{Enter 2}Jim Beam{Enter}123 Main St.{Enter}Winfield, KS 67156{Enter 2}Dear John;"
If _arg1 = "Jack" then SendKeys "{Enter 2}Jack Black{Enter}123 Main St.{Enter}Winfield, KS 67156{Enter 2}Dear John;"

The 2nd command would be called something like Personal (must be EXACTLY the same name that is surrounded by <> in the previous command) and look as follows:

Makers
Jim
Jack


Note that you will need to also change the 2nd command from the default Type S (Script) to Type L (listing) because it is hooked to the 1st command. It would probably be simpler for you to examine one of the KnowBrainer global Advanced-Scripting listing commands. Look up the KnowBrainer
Open <files> command and note the arguments and the <files> part of the command name. Now look up the files command. Note that the files command is a listing command and is directly hooked to the Open <files> command. You'll find more information in our patent pending VerbalBasic guide.



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


Click KB 2012 REV D to Download a 30 Day Evaluation of KnowBrainer 2012 


 


 


 

 11/11/2008 11:12 AM
User is offline View Users Profile Print this message


pdberger
Junior Member

Posts: 10
Joined: 10/06/2008

Thanks, but it's still not working.

When I try the "todays date" version, I just get a blank line.  When I try the line with ControlPick "{Enter}", I get an error message saying that it can't find a control with an {Enter} option.  I tried with with {OK} and with {Down}{Enter} and got similar error messages. 

Thanks in advance for any suggestions you can offer.

 11/13/2008 04:48 AM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 22612
Joined: 10/01/2006

Please re-examine our command again. Nowhere in our 4 examples do we use ControlPick “{Enter}” it is SendKeys “{Enter}”. As we stated earlier, NaturallySpeaking hates ControlPick commands so only use them as a last resort. You can usually substitute SendKeys “{Enter}” and if the button that you want to click on isn't the preset default, utilize SendKeys “{Tab}” or SendKeys “{Tab 2}” etc. to get there and then follow up with SendKeys “{Enter}”.

You might want to consider our virtual on-site technical support which you'll find in our Tech Support Options because we are not certain that we can make this any clearer on a forum and typing the code virtually on your computer, from our computer, would probably be considerably easier and faster at this point.


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


Click KB 2012 REV D to Download a 30 Day Evaluation of KnowBrainer 2012 


 


 


 

 11/14/2008 12:18 AM
User is offline View Users Profile Print this message


pdberger
Junior Member

Posts: 10
Joined: 10/06/2008

Got it!  (When I actually paid attention to your script...)  Works great.  Less filling.

 Nope, I think I'd rather display my ignorance in the forum, so I can serve as a cautionary tale to others.  Thanks for your help.  Really looking forward to seeing what edmart came up with...

 11/15/2008 02:54 AM
User is offline View Users Profile Print this message

Author Icon
edmart
Top-Tier Member

Posts: 454
Joined: 10/07/2006

Dear pdberger - this is how I deal with letters:-

 

1.                  I create a template (in Word 2003 as it happens), with six bookmarks in the form that allows you to select them by using the “Number <1-100>” command. I have removed my firm’s name etc from the template, so it looks pretty odd, but it is attached, called “Letter template”. Note that the automatic date is taken care of from within Word. Press ‘Alt+F9’ to reveal the FieldCode. I happen to prefer ‘9th’ over ‘9’: you may not, but you can adjust that as you think fit - I can’t think offhand how you do it, but it can be done. This is the basic document, and everything else relies on the bookmarks.

 

2.                  I have amended the “Number <1-100>” command (in KnowBrainer 2008 Rev D) by the addition of the following two lines, because I found that if I just left the bookmark ‘selected’, things did not invariably pan out the way I wanted: I don’t know why. Also I wanted “Bookmark 5” in particular to start capitalised, and it did not matter if all the others were theoretically capitalised, so I went for it:-

SendKeys "{Backspace 2}"

HeardWord "\Cap"

 

3.                  Now look at the attachment called Command Screenshots, at 'Screen 1', which shows the script for the Dragon command “Address <initials>”. This is the key Dragon command. You need to have a keystroke command in Word that brings up the “Letter template” template - in this instance you will see that it is “Alt+c”, but that is just what I assigned to the Word macro when I created it. I am assuming you know how, or can find out how, to do that: but please post back if you need help.

 

4.                  Keep working through ‘Screen1’. With luck, using the green explanations, you’ll follow what is happening. Yelp if you don’t.

 

5.                  You’ll get to the point where it calls some initials, and then presses F3 to run the Autotext associated with those initials. That is the address. Now move on to ‘Screen 2’. You want to create a list called (if you are me….) “initials”. So you do that. [If you call it “bloggins” remember that the name of your command will then not be “Address <initials>” but “Address <bloggins>”]. Now move on to ‘Screen 3’, and you will see a whole load of people’s names, preceded by their initials and a backslash. Each set of initials is the shortcut to an address block in Autotext. I am sure you use Autotext! So, when I write a letter to Anthony Bartlett, the command is “Address Anthony Bartlett”. Don’t be fazed by seeing that several initials and names are duplicated in that list. God knows how that happened! But it doesn’t seem to upset the Dragon, so why worry?

 

6.                  What is the effect of that? Well:-

 

(a)               It brings up the “Letter template”. It moves the cursor down four to the address box. It runs off to the ‘initials’ list and finds that Anthony Bartlett is a pseudonym for ‘abb’, so bungs ‘abb’ in the address box. Then it hits F3 to actually PUT the address there.

 

(b)               Then it saves the document to directory “Y:\” and waits for me to put in the name I want it saved under. And that is that.

 

7.                  Now, a few points:-

 

(a)               You can save to whatever directory you want. So “Z:\letters\november 2008\work” would be just as good a command line. It’s up to you how you save your documents.

 

(b)               I used to allow myself I think it was three seconds [“Wait 3”] after arriving at ‘Y:\” to type in the name of the document, and then I added an [“{Enter}”] command. But I am getting slow in my old age, and I can actually use a keyboard. So I abolished that - but you could go with it if you wanted to: it all depends how much mechanisation suits you.

 

(c)                You could go a stage further (mind you, if you do, please send me the code, because I would welcome it!), and add code, once the document had been saved, to go to bookmark 4 and put in ‘Anthony’ if you were writing to Anthony Bartlett. I gave up at that point, thinking of the enormous list of Christian names that I was going to need to create, and not quite fathoming how to do the “IF Anthony Bartlett in the original command THEN ‘Anthony’ when I get to bookmark 4” command. [NB, any other kind souls who want to write that command for me, are more than welcome!]

 

(d)               Of course if, when writing to (e.g.) Anthony Bartlett, the subject was invariably “Development of Littlehampton Green”, then you could amend your command from the previous paragraph and add that as well. I suspect that may be a bridge too far, but mention it for completeness. I don't sufficiently often write to the same person with precisely the same subject in the heading.

 

8.                  Finally, when I get to the end of the letter, I have a command called ‘Finish letter’. Sorry, I don’t have a picture of it to hand, but it:-

Presses 'Enter' two times

Types “Yours sincerely”

Presses the key combination which in my office galvanises the print macro which prints off a top        copy and carbon

Saves the document (remember, it already has a ‘name’, so just ‘Ctrl+s&rdquo

Closes the document

Presses “Ctrl+/” which is my combination for Print Layout view in Word 2003: I really HATE ‘Normal’ view.

 

9.                  And then you are ready to roll all over again!

 

I hope that all makes sense and is helpful. If I can clarify anything, just ask. Much more important, I hope it is what you had in mind.

 

Best wishes,

 

Ed

 

 

 






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

DNS 12 Pro, Windows 7 Professional, SP1, i7-2700K 3.50 Ghz Sandybridge, 16Gb DDR3 PC3-160000C9 2000Mhz dual channel RAM, SpeechMike 5276 and Samson Airline 77

 11/16/2008 10:32 AM
User is offline View Users Profile Print this message


pdberger
Junior Member

Posts: 10
Joined: 10/06/2008

Edmart -- 

 Many thanks!  Since I don't have DNS Pro, I couldn't use your approach.  Maybe I'll save up and spring for it.  In the meantime, you helped me to this solution:

1)  I've made a number of address-block DNS commands.  Each is named something like, "Header Alfred", and looks like this:

     Alfred E. Neuman
     c/o Mad Magazine
     101 5th Ave.
     New York, NY   12345

     Dear Alfred:

 

2)  I made a KB command called, "Letter to <names>, which looks like this:

     HeardWord "todays","date"
     If _arg1 = "Alfred" then HeardWord "Letter","to","Alfred"
     If _arg1 = "Jim" then HeardWord "Letter","to","Jim"
               ...etc.

Set up the list of names.  Works great.  Less filling. 

My next step will be to create something like "Send <happy/angry> letter to <names>".  The objective is to make a set of interlocking commands to put together fairly complicated, but ultimately predictable, paragraphs and documents.

I'd love to figure out how to invoke AutoText building blocks from Word07, but I'm having troubles figuring out how to get KB or DNS to pick an option on the new clever Office 'ribbon'.  Maybe I'll just have to click on a mouse location, although that seems kind of clutzy --  I'd prefer to figure out how to make a menu selection.  So far, things like "MenuPick" don't seem to be working for me.

Anyway, thanks again for your help.

 11/16/2008 10:53 AM
User is offline View Users Profile Print this message

Author Icon
edmart
Top-Tier Member

Posts: 454
Joined: 10/07/2006

Very happy that it offered you a few pointers - can't help re Office 2007: tried the Beta and loathed it!

Good luck!

Ed 



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

DNS 12 Pro, Windows 7 Professional, SP1, i7-2700K 3.50 Ghz Sandybridge, 16Gb DDR3 PC3-160000C9 2000Mhz dual channel RAM, SpeechMike 5276 and Samson Airline 77

 11/16/2008 02:16 PM
User is offline View Users Profile Print this message


Jomark
Top-Tier Member

Posts: 1302
Joined: 10/19/2006

The approach that I use is to set up a Word template using fields (similar to bookmarks but with text to tell me what must go into the field). I have then created pop up lists in Word for my addresses and I can then select the address that I want from the list either manually or by voice. Pop up lists can be created for whatever you want and inserted wherever you need them in a Word document.

My address list is relatively short as I only deal with a small number of Companies on a regular basis but there is no reason why it cannot include as many items as you wish to suit your particular need.

These pop up lists use autotext entries using the autotextlist field and it works in Word2003 and Word2007.

The list is activated by selecting and rightclicking on the field or if using KB, select the field and say the command Context Menu

For more information goto

 http://word.mvps.org/faqs/tblsfldsfms/AutoTextListContent.htm

this document explains the procedure for creating a pop up in Word2003 but is also applicable in Word2007.

I started with this in Word2003 but now use it in  Word2007

 



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

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