KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Saving files
Topic Summary: Looking for code which saves a file to a specified folder
Created On: 05/26/2020 11:02 AM
Status: Post and Reply
Linear : Threading : Single : Branch
 Saving files   - Brevitatis - 05/26/2020 11:02 AM  
 Saving files   - Alan Cantor - 05/26/2020 12:31 PM  
 Saving files   - Brevitatis - 05/27/2020 04:37 AM  
 Saving files   - Lunis Orcutt - 05/26/2020 09:30 PM  
 Saving files   - Brevitatis - 05/27/2020 04:39 AM  
 Saving files   - Alan Cantor - 05/27/2020 08:36 AM  
 Saving files   - Brevitatis - 05/27/2020 11:03 AM  
 Saving files   - kkkwj - 05/27/2020 03:24 PM  
 Saving files   - Alan Cantor - 05/28/2020 02:20 PM  
 Saving files   - kkkwj - 05/29/2020 03:30 AM  
 Saving files   - Alan Cantor - 05/29/2020 12:15 PM  
 Saving files   - kkkwj - 06/01/2020 12:13 PM  
 Saving files   - Lunis Orcutt - 06/01/2020 03:08 PM  
 Saving files   - newbiecoder - 06/16/2020 01:22 PM  
 Saving files   - Karen Willenken - 07/18/2020 02:21 PM  
 Saving files   - Matt_Chambers - 07/18/2020 04:25 PM  
 Saving files   - Karen Willenken - 08/15/2020 12:36 PM  
Keyword
 05/26/2020 11:02 AM
User is offline View Users Profile Print this message

Author Icon
Brevitatis
New Member

Posts: 12
Joined: 06/12/2019

I've been immersing myself in DNS for weeks because of lockdown but I can't find what I'm looking for!

I would like to save a file (usually a Word document) into a folder which I name in the voice instruction. I think ListVar1 has something to do with it but I cannot find any example which shows me how to do it. Anybody any idea?!

 05/26/2020 12:31 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 3841
Joined: 12/08/2007

I haven't tested this. This is for Word, which uses "F12" as "Save As..."  Not every program uses this hotkey. I have indicated more general key sequence in the code.

 

Save To <folders>

 

SendDragonKeys "{F12}"   ' Save As...

Wait .3

' SendDragonKeys "{Alt+f}"  ' File menu

' Wait .3

' SendDragonkeys "a" ' Save As...

' Wait .3

' SendDragonKeys "o" ' Browse. (This extra step is needed in recent versions of Office)

' Wait .3

Path = Mid(ListVar1, 1, Instr(ListVar1, "|" ) -1 )

SendDragonKeys Path

' You may or may not need to press Enter key at this point to navigate to the folder

 

<folders> consists of lines like this. The | character separates the spoken form from the written form.

 

John|c:\users\hello\goodbye\

Budget|c:\users\budget\

Temporary|p:\tmp\

 05/27/2020 04:37 AM
User is offline View Users Profile Print this message

Author Icon
Brevitatis
New Member

Posts: 12
Joined: 06/12/2019

Many thanks indeed Alan for taking the time to message me with your intriguing code! I've not seen this command before (Path =Mid(List....-1) but I'll give it a go and let you know how I get on. Exciting

 05/26/2020 09:30 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 37978
Joined: 10/01/2006

                    Welcome (See Mission Statement)


Let's have some fun and note that the following 2 commands have been added to KnowBrainer 2017 Build 05-25-2020. The following KnowBrainer command can be copied into Dragon as an Advanced-Scripting command. However, you will need to define your <ComputerFolder> list via the Name Editor button. We have only included My Documents, Documents and Desktop in our list. Assuming you wish to save your Microsoft Word documents in other places you will need to add your personal list of addresses to your script and the Name Editor (2 different places). As an example, you can trigger the following command by saying Save To <Desktop>. You will see that the Same As Window will pre-populate the address. When you are saving a Microsoft Word document for the 1st time. Microsoft Word tries to help you by copying the 1st line of your document into the Save As Window. KnowBrainer will give you the option of saving Microsoft's recommendation if you like but if you don't like it, KnowBrainer was already highlighted the name so that you can dictate over the selected text. This command includes a verbal prompt where you will be prompted to say Save As 
<dictation>. For example, if you say Save As <caveman bondage> KnowBrainer will name your file “Caveman Bondage” (notice that it's also saved in Title Case for an extra kick) and as soon as you stop speaking (stop dictating the name) your file will save itself. Note that the Save As <dictation> command is Window specific and will only work when the Save As Windows open.

Save To <ComputerFolder>

 

Sub Main
SetMicrophone 0 'turns microphone off
SendKeys "{F12}" 'save as
Wait 0.5 ' 1\2 second timeout
SendKeys "{Home}" 'moves cursor to beginning of line to avoid removing Word's recomment title
Wait 0.5
If ListVar1 = "Documents" Then SendKeys "{%}UserProfile{%}\Documents\"
If ListVar1 = "My Documents" Then SendKeys "{%}UserProfile{%}\Documents\"
If ListVar1 = "Desktop" Then SendKeys "{%}UserProfile{%}\Desktop\"
Wait 0.5
SendKeys "+{End}" 'selects original name
TTSPlayString "save as?" 'verbally prompts you 
Wait 0.5
SetMicrophone 1 'turns microphone back on
End Sub

 

Save As <dictation>

 

Sub Main
Str = ListVar1
arrStr = Split(Str," ")
For i=0 To UBound(arrStr)
word = LCase(Trim(arrStr(i)))
word = Replace(word,Mid(word,1,1),Chr(Asc(Mid(word,1,1))-32),1,1)
str1 = str1 & word & " "
Next
SendKeys str1
Wait 1
SendKeys "%s"
End Sub


PS: KnowBrainer also includes a global combination of both commands. The only current limitation is needing to do this in an Office 365 application like Excel, Word, PowerPoint etc. You're also limited to specific addresses such as Documents, Desktop, Downloads, Pictures etc. If you already have KnowBrainer 2017 (if not you will find a trial in our signature tag) try creating a new Microsoft Word document and saying Save To <desktop> As <This Command Kicks>. Note that most of the previous command scipts were created hands-free with VerbalBasic



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

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1

 05/27/2020 04:39 AM
User is offline View Users Profile Print this message

Author Icon
Brevitatis
New Member

Posts: 12
Joined: 06/12/2019

Excellent! I'm extremely grateful to you. Take the day off! No I insist.
 05/27/2020 08:36 AM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 3841
Joined: 12/08/2007

Brevitatis,

I'm glad my code sample helped.

Many people were taught that the way to navigate from one folder to another is to perform a series of mouse clicks. But I don't use a mouse, at least not often. I've learned I can also navigate to a folder by typing its path in the "Name" or "Address" fields.

It gets tedious to type paths, so the next logical step is to use macros to output path information. I use a handful of keyboard macros and voice macros to jump around from folder to folder. The technique requires no targeting of small objects with the mouse (or any other kind of mouse action). The technique is extremely reliable -- it rarely fails. And the technique is fast: I arrive at the folder I want to get to in a fraction of the time that it would take me by pointing, clicking, scrolling, and dragging.



 05/27/2020 11:03 AM
User is offline View Users Profile Print this message

Author Icon
Brevitatis
New Member

Posts: 12
Joined: 06/12/2019

Thanks again. That's also very helpful.
I previously tried to navigate between folders by simply recording the number of times I pressed the tab key, but ended up tied up in knots! I hadn't thought of copying the folder paths, despite having regularly used them with the AppBringUp command. it's amazing how easy it is to miss the obvious!
 05/27/2020 03:24 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 484
Joined: 11/05/2015

Hi Alan, you say you use macros to output path information - do you mean the macro you posted above that has your folders in a Listvar? I am interested in the contents of your "handful of keyboard macros and voice macros to jump around from folder to folder." Would you be willing to post the macro names, functions, and the supporting lists that they use? (I imagine they encode all the folders that you jump around to.)

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

Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones

 05/28/2020 02:20 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 3841
Joined: 12/08/2007

I currently use two macros to output paths. (There have been times I have had more.) Both macros output the paths to folders that bring me to, or close, to the folders I regularly go to.

Neither macro is for Dragon. But voice-enabling the scripts would be easy. For voice control, I would think outputting path information would be best when combined with another operation, such as saving to a particular folder or opening files within specific folders.

I made the scripts in Macro Express. They are activated by typing key sequences that always start with a comma. For example:

1. When I type ,alan

The macro outputs "C:\Users\Me\Documents\Alan"

 

Virtually all of the subfolders I navigate to regularly are in this folder. My File Explorer settings combined with my folder-naming convention makes it easy to navigate to the folder I want to open by either typing the first few characters, or if I am using Dragon, by saying the name of the folder.

2. When I type ,pix

The macro outputs the path to the area of my hard drive where I store photos. I have organized my photos into years; the name of the folder for the current year is "2020". This macro automatically outputs the current year as part of the path. The script looks like this (in pseudo code):

Let %CurrentYear% = the current date/time using "YYYY" format
Type "C:\Users\1234\Documents\Pictures\%CurrentYear%"



 05/29/2020 03:30 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 484
Joined: 11/05/2015

Ah, I see. You get into a FileOpen dialog textbox that wants a path, then use a short keyboard macro to expand and type out the long form of the path you want. Very efficient! I think I'll try that. Heavens knows I spend enough time clicking and up and down folder hierarchies to get to the places I want to go.

I had Macro Express installed at one time a year or two ago along with AHK, but I didn't want to invest the time into those tools when I was trying to develop my voice skills and macros. There is so much to learn. Thank you for making yet another educational post!

(Someone should write a book on all these kinds of tips that you, PG, Phil, Chuck, Lunis, Lindsay, Rob, (and others) have built up over the years. It's a long, unguided road for a newbie!)



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

Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones



 05/29/2020 12:15 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 3841
Joined: 12/08/2007

You can use either Macro Express or AutoHotkey to make these kinds of typing shortcuts to output paths. (Or make Dragon commands so you can say them instead of type them.)

In Macro Express, I prefer to use "prefix Shortkeys," which means the initial character (or characters) that are typed signals a macro is about to be activated. (In contrast, a "suffix" Shortkey is triggered by its final character, usually the space-bar, Enter key, or punctuation mark.)

I don't recall what prefix-activated typing shortcuts are called in AutoHotkey. But I'm almost sure AutoHotkey supports them.

The learning curve for Macro Express is significantly shorter than for AutoHotkey. I found Macro Express fairly easy to figure out. AutoHotkey was more challenging, but it is ultimately more versatile. I use Macro Express 80% or 90% of the time, and AutoHotkey for the remainder. (Not counting Dragon commands....)

There is a modest cost for Macro Express, whereas AutoHotkey is free. You can use Macro Express for free for one month. But don't let the cost of Macro Express dissuade you from using it. For me, Macro Express paid for itself (in terms of getting more stuff done quickly and easily) in a day or less.
 06/01/2020 12:13 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 484
Joined: 11/05/2015

Hi Lunis, I see that you turned the microphone off and on in the script you posted above:

Save To Folder Script:

Sub Main
SetMicrophone 0 'turns microphone off
...
TTSPlayString "save as?" 'verbally prompts you
...
SetMicrophone 1 'turns microphone back on
End Sub

Is it best practice to turn the microphone off/on under particular circumstances? (Maybe it has to do with the TTSPlayString sound?) Thank you



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

Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones



 06/01/2020 03:08 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 37978
Joined: 10/01/2006

You nailed it. If the TTSPlayString is too loud, it can be heard by your microphone and produce undesired results. We also make a habit of turning the Dragon microphone off and on in circumstances where a command is going to take 10 seconds or more.



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

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1



 06/16/2020 01:22 PM
User is offline View Users Profile Print this message

Author Icon
newbiecoder
New Member

Posts: 8
Joined: 04/29/2019

Probably a better way to do it, but this seems to work for me not only in word but in Adobe.  You would have to name the document after the macro runs – but you can dictate that, of course.

 

Sub Main

              SendSystemKeys "{alt+f}"

              Wait 0.3

              SendSystemKeys "a"

              Wait 1.9

              SendKeys "C:\Users\Documents\newfolder\"

 

End Sub

 07/18/2020 02:21 PM
User is offline View Users Profile Print this message

Author Icon
Karen Willenken
Power Member

Posts: 45
Joined: 04/16/2015

On the topic of navigating/typing folders, I have several commands that rely on a list of shortcut phrases, e.g. "Case 1 working papers" and "Case 2 court file". I have commands that have a bunch of lines with this general format:

If ListVar1 = "Case 1 working papers" Then sendkeys "[full folder path of the Case 1 working papers directory" ' for typing the directory address into a File Open or Save dialog box, or into the Windows Explorer address bar

or

If ListVar1 = "Case 2 court file" Then AppBringUp "[full folder path of the Case 1 working papers directory" ' opens a new instance of the directory in Windows Explorer

Alan Cantor's complex list approach is new to me and might work better (easier to update), but as clunky as my commands are, I find them enormously useful. I'd seen complex lists in the Larry Allen book but they use "\" as the delimiter, which obviously doesn't work if your string has backslashes in it. I'll have to try Alan's approach the next time I update my directory lists.
 07/18/2020 04:25 PM
User is offline View Users Profile Print this message

Author Icon
Matt_Chambers
Top-Tier Member

Posts: 254
Joined: 08/09/2018

Originally posted by: Karen Willenken On the topic of navigating/typing folders, I have several commands that rely on a list of shortcut phrases, e.g. "Case 1 working papers" and "Case 2 court file". I have commands that have a bunch of lines with this general format: If ListVar1 = "Case 1 working papers" Then sendkeys "[full folder path of the Case 1 working papers directory" ' for typing the directory address into a File Open or Save dialog box, or into the Windows Explorer address bar or If ListVar1 = "Case 2 court file" Then AppBringUp "[full folder path of the Case 1 working papers directory" ' opens a new instance of the directory in Windows Explorer Alan Cantor's complex list approach is new to me and might work better (easier to update), but as clunky as my commands are, I find them enormously useful. I'd seen complex lists in the Larry Allen book but they use "\" as the delimiter, which obviously doesn't work if your string has backslashes in it. I'll have to try Alan's approach the next time I update my directory lists.

Karen,

Another option is to set up the List of folder paths using something other than a backslash.  For example, I have a command (and used to have a bunch more before I retired) that uses a "."  in place of the backslash (you could use an *, I suppose).  I have Dragon use the Larry Allen method of extracting everything before the "\", take what is extracted, and use the Replace command to replace all the "."  with "\".  So an item name would be something like:

C:.Users.matth.Box.No-Action Letters\no action letters where I would say something like "explore no action letters" and the command would take "C:.Users.matth.Box.No-Action Letters" and convert it to "C:.Users\matth\Box\No-Action Letters" by using these lines:

a=Mid(ListVar1,1,InStr(ListVar1,"\")-1)

a=Replace (a, ".", "\")

Just another approach.

Matt

 

 08/15/2020 12:36 PM
User is offline View Users Profile Print this message

Author Icon
Karen Willenken
Power Member

Posts: 45
Joined: 04/16/2015

Thanks, Matt! That's a really good point. I'm in the process of updating my commands now to use this functionality. I have several commands that all rely on the same list -- "get me" triggers an AppBringUp, but sometimes I want to "hyperlink to" something (e.g. in an email to colleagues) or simply "type" one of the items in the list (e.g. in the Save As dialog box). Until now I have not updated these commands as frequently as I'd like because each command had a long list of "if [spoken form] then [function]" commands, each of which had to be updated. Now I can keep the commands the same, and only update the list!

Next step is to develop a script that will allow me to quickly edit the list, which includes a) file paths of folders I might want to access or save to (I have an unusually large number of these because I use a complex, standardized file structure with a different shared directory for each case, rather than saving documents to my "Documents" folders); b) addresses of websites I access fairly frequently; c) fullpaths of files I access frequently (such as Larry Allen's scripting guide). The more frequently I update this list, the more time I will save with my commands.


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

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