![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: Shortening the italicize command Topic Summary: Is it possible to create a macro or make a script to customize (shorten) the italicize command? Created On: 02/19/2021 04:10 PM Status: Post and Reply |
|
![]() |
![]() |
- dinotalking | - 02/19/2021 04:10 PM |
![]() |
![]() |
- Alan Cantor | - 02/19/2021 08:27 PM |
![]() |
![]() |
- Edgar | - 02/20/2021 10:55 AM |
![]() |
![]() |
- Alan Cantor | - 02/20/2021 12:36 PM |
![]() |
![]() |
- Edgar | - 02/21/2021 10:27 AM |
![]() |
![]() |
- dinotalking | - 02/22/2021 08:13 PM |
![]() |
![]() |
- dilligence | - 02/22/2021 10:38 PM |
![]() |
![]() |
- Alan Cantor | - 02/22/2021 11:55 PM |
![]() |
![]() |
- dinotalking | - 02/23/2021 01:19 PM |
![]() |
![]() |
- dilligence | - 02/23/2021 04:12 PM |
![]() |
![]() |
- dinotalking | - 02/24/2021 10:43 AM |
![]() |
![]() |
- Alan Cantor | - 02/24/2021 10:45 AM |
![]() |
![]() |
- Alan Cantor | - 02/24/2021 10:54 AM |
![]() |
![]() |
- Alan Cantor | - 02/24/2021 11:39 PM |
![]() |
![]() |
- dinotalking | - 02/27/2021 01:42 PM |
![]() |
![]() |
- Alan Cantor | - 02/27/2021 04:50 PM |
![]() |
![]() |
- dinotalking | - 03/01/2021 11:03 AM |
![]() |
![]() |
- Alan Cantor | - 03/01/2021 11:48 AM |
![]() |
![]() |
- dinotalking | - 03/01/2021 12:14 PM |
![]() |
![]() |
- Alan Cantor | - 03/01/2021 12:30 PM |
![]() |
![]() |
- dinotalking | - 03/01/2021 01:25 PM |
![]() |
|
Hello, I’ve managed to add some commands to Dragon that I like, such as the shortened terms "OQ" and "CQ" for open quotation marks and close quotation marks. One thing I’ve never known how to do is simplify the standard “italicize” command. The main way to do it, as you know, is to say "Italicize last x words," which is a bit cumbersome. Is there a way to create a macro or a bit of scripting to simplify this – i.e. so that one might say something like "i6" and have that recognized as "italicize last six words"? I do a lot of note-taking on books (I’m a retired academic), so I would be glad to shorten the italicize command, which comes up pretty often for book titles and whatnot. Thanks. Al ------------------------- DPI 15.61.200.010, Sennheiser ME3 Microphone, Lenovo Legion V laptop with 16GB RAM, AMD Ryzen 7 Mobile 4800H Processor (2.9Ghz-4.2Ghz), Realtek (R) Audio 6.0.9003.1. Windows 10 Home 64-bit, Office 2013 Pro. |
|
|
|
![]() |
|
In Dragon circa 2009, you could add lines like these to options.ini:
enx Italicize XYZ Command=Eye enx Italicize From XYZ Command=Eye "enx" refers to the language you are using (English in this example). "Eye" is my substitute command for "Italicize" So I could say "Eye language you are using" (to italicize the four words, above) and "Eye from refer to example" (to italicize a longer phrase). Not sure these work anymore. If they do work, I wouldn't use "eye" as the replacement, as that would be an invitation to undesirable side effects. The case of words might matter. I might try these: enx italicize XYZ command=eye yi enx italicize from XYZ command=eye yi If these work, you'd be able to say "eye yi Not sure these work" but probably not "eye yi last four words." |
|
|
|
![]() |
|
It should certainly be possible to do this with a script but the script might have to be "application-specific". Imagine that in one application you highlighted a selection of words and then pressed "control + i" to italicize that selection. In another application, after highlighting the selection, you pressed "shift + ctrl + j" to achieve the same italization. It's fairly easy to write a script that parses "the last XXX words" (where XXX is some numeral) to figure out the number of words desired. Most applications also use the exact same keypress sequence to select a given number of words (either forward or backward). So, once you figure out what the keypress sequence is to italicize the rest is pretty easy.
------------------------- -Edgar |
|
|
|
![]() |
|
Most applications also use the exact same keypress sequence to select a given number of words (either forward or backward). I wish navigating and selecting word by word was consistent. It isn't. The key sequences to navigate and select by word is the same in MS-Word, WordPad, DragonPad, the Dictation Box, and Excel. But the sequences are different in Notepad and in browsers. In some web applications, the developers have created their own navigation and selection methods, so key sequences work differently or don't work... period! I think the variations are most conspicuous around the handling of punctuation marks and line/paragraph breaks. For example: Is the punctuation mark at the end of a sentence or phrase part of the word that it clings to? For Notepad, the answer is "yes." For Word, the answer is "no." (Starting with the insertion point at the end of the previous paragraph, select the entire sentence by pressing Ctrl + Left arrow SIX times in Notepad, or NINE times in MS-Word!) During the 1990s, I developed a set of rules for word-by-word navigation and selection. I implemented the rules in the DOS-based word processor I used at the time. I thought my method was promising -- it shaved days, maybe weeks, from the process of drafting, editing, and polishing my Masters thesis. The method was internally consistent, and logical (or so I thought.) I showed my method around, but at that time the geeks in my life were going gaga for doing everything via mouse. So I was the sole beneficiary of my method. When I started using Windows in the mid-1990s, I was disappointed about the inconsistencies of word-by-word navigation and selection across programs. 25 years later, the inconsistencies have multiplied. I think that's because most developers don't take seriously keyboard-only access. |
|
|
|
![]() |
|
So true! That is why I mentioned that some of the work would have to be application-specific. If trying to generalize something that will work for everyone everywhere, the task would be daunting. Fortunately, most of individuals don't use a whole lot of editors that are capable of italicizing. One general solution that works in Word (or whatever their primary rich text editor is), which demonstrates the concept, would probably be good enough and easily extended by minor modifications of the selection section of the code for application-specific situations. ------------------------- -Edgar |
|
|
|
![]() |
|
Thanks for your insights, Alan and Edgar. Much obliged.
Al ------------------------- DPI 15.61.200.010, Sennheiser ME3 Microphone, Lenovo Legion V laptop with 16GB RAM, AMD Ryzen 7 Mobile 4800H Processor (2.9Ghz-4.2Ghz), Realtek (R) Audio 6.0.9003.1. Windows 10 Home 64-bit, Office 2013 Pro. |
|
|
|
![]() |
|
Is there a way to create a macro or a bit of scripting to simplify this – i.e. so that one might say something like "i6" and have that recognized as "italicize last six words"?
Assuming you are working in applications that follow the standard Ctrl+i convention (Word, WordPad, DragonPad, Apache Open Office Writer etc.) this fast DVC command works (you can use any list you want, in this case I used the standard 1to10 list):
IT <amountofwords>
If _arg1 = "1" then SendKeys "{Ctrl+Shift+Left}{Ctrl+i}" If _arg1 = "2" then SendKeys "{Ctrl+Shift+Left 2}{Ctrl+i}" If _arg1 = "3" then SendKeys "{Ctrl+Shift+Left 3}{Ctrl+i}" If _arg1 = "4" then SendKeys "{Ctrl+Shift+Left 4}{Ctrl+i}" If _arg1 = "5" then SendKeys "{Ctrl+Shift+Left 5}{Ctrl+i}" If _arg1 = "6" then SendKeys "{Ctrl+Shift+Left 6}{Ctrl+i}" If _arg1 = "7" then SendKeys "{Ctrl+Shift+Left 7}{Ctrl+i}" If _arg1 = "8" then SendKeys "{Ctrl+Shift+Left 8}{Ctrl+i}" If _arg1 = "9" then SendKeys "{Ctrl+Shift+Left 9}{Ctrl+i}" If _arg1 = "10" then SendKeys "{Ctrl+Shift+Left 10}{Ctrl+i}"
I used the “IT” prefix because I previously used “I” in another command and now Dragon is not responding to that anymore, but you can probably use it.
Here’s what it looks like in my Command Browser:
------------------------- |
|
|
|
![]() |
|
Nice! To force the same command to deselect the selection and restore the cursor position, try this DVC script: |
|
|
|
![]() |
|
Thanks to Dilligence and Alan! This looks like the ticket, and I'll add it in today. Have wanted to shorten the italicize command for a long time, so this is fantastic. By the way, the earlier problem I mentioned several days ago in my initial post on this forum -- the spotty quality of how Dragon is handling numbers/numerals, I've come around to simply unchecking the auto-correct option for numbers "greater than or equal to...." At least that choice seems to be stable from one firing-up of Dragon to the next, and it offers the benefit of typing terms like "fourteenth century" spelled out fully and not having to correct them. It's easy enough just to say "numeral 2" when I want "2" rather than "two." Thanks again, much obliged for the scripting help.
------------------------- DPI 15.61.200.010, Sennheiser ME3 Microphone, Lenovo Legion V laptop with 16GB RAM, AMD Ryzen 7 Mobile 4800H Processor (2.9Ghz-4.2Ghz), Realtek (R) Audio 6.0.9003.1. Windows 10 Home 64-bit, Office 2013 Pro. |
|
|
|
![]() |
|
Following Alan's approach, you can also catch it in a DVC loop (you can use the same list and you can replace "c" with anything else):
c = _arg1 Do Until c = z SendKeys "{Ctrl+Shift+Left}" c = c-1 Loop SendKeys "{Ctrl+i}" SendKeys "{Right}" ------------------------- |
|
|
|
![]() |
|
Hello,
Here's what I input into Dragon's MyCommands box, but when I try to save it, I get a message telling me "please correct syntax error for your macro before saving." Can someone let me know where the mistake lies? (I picked "advanced scripting" as the option): between sub (main) and end sub, I have: If_arg1 = "1" Then SendKeys "{Ctrl+Shift+Left}-{Ctrl+i}" If_arg1 = "2" Then SendKeys "{Ctrl+Shift+Left 2}-{Ctrl+i}" If_arg1 = "3" Then SendKeys "{Ctrl+Shift+Left 3}-{Ctrl+i}" If_arg1 = "4" Then SendKeys "{Ctrl+Shift+Left 4}-{Ctrl+i}" If_arg1 = "5" Then SendKeys "{Ctrl+Shift+Left 5}-{Ctrl+i}" If_arg1 = "6" Then SendKeys "{Ctrl+Shift+Left 6}-{Ctrl+i}" If_arg1 = "7" Then SendKeys "{Ctrl+Shift+Left 7}-{Ctrl+i}" If_arg1 = "8" Then SendKeys "{Ctrl+Shift+Left 8}-{Ctrl+i}" If_arg1 = "9" Then SendKeys "{Ctrl+Shift+Left 9}-{Ctrl+i}" If_arg1 = "10" Then SendKeys "{Ctrl+Shift+Left 10}-{Ctrl+i}" SendKeys "{Ctrl+Shift+Left " & _arg1 & "}" SendKeys "{Ctrl+i}" SendKeys "{Right}" ------------------------- DPI 15.61.200.010, Sennheiser ME3 Microphone, Lenovo Legion V laptop with 16GB RAM, AMD Ryzen 7 Mobile 4800H Processor (2.9Ghz-4.2Ghz), Realtek (R) Audio 6.0.9003.1. Windows 10 Home 64-bit, Office 2013 Pro. |
|
|
|
![]() |
|
Remove the hyphens before {Ctrl+i} |
|
|
|
![]() |
|
Advanced Scripting uses a different syntax for SendKeys.
1. Change "SendKeys" to "SendDragonKeys" or "SendSystemKeys" or 2. Change Ctrl to "^" and Shift to "+" E.g., SendKeys "+^{Left 2}" This probably won't make a critical difference, but it's considered good form to do this: SendKeys "+^{Left 2}", True |
|
|
|
![]() |
|
Dinotalking, |
|
|
|
![]() |
|
Alan,
Thanks for the insight. I'm still trying to get the code to work, so I would be very interested to know what additional change I'd need to make for advanced script. It's been years since I did anything with programming, so even my novice understanding is still rusty! ------------------------- DPI 15.61.200.010, Sennheiser ME3 Microphone, Lenovo Legion V laptop with 16GB RAM, AMD Ryzen 7 Mobile 4800H Processor (2.9Ghz-4.2Ghz), Realtek (R) Audio 6.0.9003.1. Windows 10 Home 64-bit, Office 2013 Pro. |
|
|
|
![]() |
|
Here it is as an Advanced Scripting command: |
|
|
|
![]() |
|
Hello Alan and all,
That works wonderfully, thanks. I just added a line towards the end to de-italicize the text following the italicized section, so the final version of the shortcut italicize command looks like this: Sub Main Dim x as String Let x = ListVar1 SendDragonKeys "{Ctrl+Shift+Left " & x & "}" SendDragonKeys "{Ctrl+i}" SendDragonKeys "{Right}" SendDragonKeys "{Ctrl+i}" End Sub One should keep in mind that MS Word counts punctuation as a "word," so if, say, a book title contains a comma or a colon, etc., that counts as a word. If you want to italicize the title Henry VIII, or, All for Love it would be counted as 8 words, and you would say "IT 8" even though there are only six actual words. That brings up a question -- what code should be added if you want to adjust the command so that it will ignore punctuation for the purpose of counting, but still italicize that punctuation since it's part of the phrase that needs italicizing? In the Henry VIII example, the commas would be italicized since they are part of the title. The reason for making the adjustment would be that it's easier to ignore the commas and whatnot if you're counting the words of a longish phrase or title. Regards, Al ------------------------- DPI 15.61.200.010, Sennheiser ME3 Microphone, Lenovo Legion V laptop with 16GB RAM, AMD Ryzen 7 Mobile 4800H Processor (2.9Ghz-4.2Ghz), Realtek (R) Audio 6.0.9003.1. Windows 10 Home 64-bit, Office 2013 Pro. |
|
|
|
![]() |
|
what code should be added if you want to adjust the command so that it will ignore punctuation for the purpose of counting, but still italicize that punctuation since it's part of the phrase that needs italicizing? In the Henry VIII example, the commas would be italicized since they are part of the title. The reason for making the adjustment would be that it's easier to ignore the commas and whatnot if you're counting the words of a longish phrase or title. It's a good question. The challenge would be that different applications handle punctuation differently when selecting by word. Some apps include punctuation as part of the word, some don't. |
|
|
|
![]() |
|
Yes, I see. What if you're only planning to use it for Microsoft Word?
------------------------- DPI 15.61.200.010, Sennheiser ME3 Microphone, Lenovo Legion V laptop with 16GB RAM, AMD Ryzen 7 Mobile 4800H Processor (2.9Ghz-4.2Ghz), Realtek (R) Audio 6.0.9003.1. Windows 10 Home 64-bit, Office 2013 Pro. |
|
|
|
![]() |
|
Something like this might help. But I think you may find this script will occasionally give unpredictable results.
One can spend a lot of time trying to "tweak" a script like this to work under every imaginable condition, but even at this relatively undeveloped stage, the time saving may already be beyond the point of diminishing returns. Considering taking those punctuation marks into account when issuing the existing command. Sub Main Dim x, y, z As String Dim Diff As Integer Let x = ListVar1 SendDragonKeys "{Ctrl+Shift+Left " & x & "}" SendDragonKeys "{Ctrl+c}" Wait .1 Let y = Clipboard Let z = y Let z = Replace(z, ",", "") Let z = Replace(z, ".", "") Let z = Replace(z, "?", "") Let z = Replace(z, "!", "") Let z = Replace(z, ";", "") Let z = Replace(z, ":", "") Let z = Replace(z, Chr$(34), "") ' Double quote mark Let Diff = Len(y) - Len(z) If Diff > 0 Then SendDragonKeys "{Ctrl+Shift+Left " & Diff & "}" End If SendDragonKeys "{Ctrl+i}" SendDragonKeys "{Right}" SendDragonKeys "{Ctrl+i}" End Sub |
|
|
|
![]() |
|
Yes, agreed. Thanks for the script!
------------------------- DPI 15.61.200.010, Sennheiser ME3 Microphone, Lenovo Legion V laptop with 16GB RAM, AMD Ryzen 7 Mobile 4800H Processor (2.9Ghz-4.2Ghz), Realtek (R) Audio 6.0.9003.1. Windows 10 Home 64-bit, Office 2013 Pro. |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2021 FuseTalk™ Inc. All rights reserved.