How can I we represent a new line character in the Clipboard in an Advanced Scripting command? - naturallyspeaking

I am writing an Advanced Scripting voice command in Dragon NaturallySpeaking Professional 11.5 to write some MATLAB usual figure commands by voice, namely:
title('')
xlabel('')
ylabel('')
As I would like to write these three lines in one voice command, and the fastest way two output text using Advanced Scripting is to put the text within the keyboard and press Ctr+v, I'm looking for a way to represent new line characters in the Clipboard.
My current script is the following:
Sub Main
Clipboard("title(''); xlabel('') ; ylabel('');")
SendKeys "^v"
SendKeys "{Enter}"
End Sub
and output:
title(''); xlabel('') ; ylabel('');

vbCrLf will add a new line:
Sub Main
Clipboard("title('')" & vbCrLf & "xlabel('')" & vbCrLf & "ylabel('')")
SendKeys "^v"
SendKeys "{Enter}"
End Sub
will output:
title('')
xlabel('')
ylabel('')

Related

How can I access the recognition history from an advanced scripting voice command in Dragon NaturallySpeaking?

I am writing a voice command in advanced scripting in Dragon NaturallySpeaking. I would like to access the last element of the recognition history (e.g., to place it in the clipboard, or repeat). How cannot achieve that?
For example, given this recognition history:
I would like to have a voice command so that when I say repeat Dragon NaturallySpeaking sends the keys show recognition history.
Well, I don't know if this is what you intend, but whatever the command name is will be the last recognition. Do you mean the recognition before that one? That is, the one you said before you say the command? In that case, try the following, but be advised, it's not like saying the phrase again. It's literally copying out what Dragon heard you say (recognized). So if you say at the start of a sentence "this is a test period" to have Dragon type out "This is a test.", your new command will type out "this is a test period".
Sub Main
Dim engine As New DgnEngineControl
engine.DlgShow(dgndlgRecognitionHistory,0,,0) ' Call up Recognition History
Wait .5 ' Need a short delay
SendKeys "{Up}", True ' move up to prior utterance
SendKeys "{Tab}", True ' move to utterance selection
Wait .3
SendKeys "^c", True ' Copy to the clipboard
Wait .5 ' Need a short delay for clipboard
SendKeys "{Esc}", True ' Close recognition history
Wait .3
SendKeys "^v", True ' Paste from clipboard
End Sub
To convert the recognition to a newly recognized utterance requires some additional work.
Hth

How achieve a two line Prompt?

In the batch language of Microsoft's CMD.EXE console window, I never liked having my command start at the far right, after a long display of the directory path. So in my Control Panel → System → Advanced System Settings → Environment Variables I saved the following assignment, where $_ is like a Soft Return:
PROMPT=[$P\]$_$+$G$S
The displayed prompt was two lines like this:
[C:\Temp\]
>
(The $+ tracks pushd and popd, the fancier than chdir commands. $S is space. By the way, the ^ character a line wrap/continuation character in batch, just as backtick ` is in PowerShell.)
Now I want the same-ish two line prompt in PowerShell. There is good news and bad news.
The good news is I can achieve that in my open PowerShell window by typing at the > prompt:
function prompt {'[' + $(get-location) + '\] SHIFTENTER > '
(By SHIFTENTER I mean press Shift+Enter, what I think might be called a "soft return"?)
....... BAD NEWS, PROBLEM ......
I want to put the above function prompt ... line into my profile PowerShell script, namely Microsoft.PowerShell_profile.ps1 (at path $Profile). But how?
Notepad.exe has no support for Shift+Enter.
MS Word understands Shift+Enter, but when I SaveAs .txt, and then examine with Notepad++, I see a plain CR-LF (meaning \r\n, 0x0d 0x0a).
Notepad++ menu Edit → Character Panel enables me to insert special ASCII characters into my .txt / .ps1 file, such as 0x0b called VT (for "vertical tab"). But despite some claims on websites, VT is not behaving like a Soft Return when I use it in my function prompt ... profile .ps1 file (I also run the profile .ps1 script to retest).
Can the prompt I want be established by a profile .ps1 script?
The PowerShell equivalent of your batch-prompt is:
function prompt { "[$(Get-Location)\]`r`n$("+"*(Get-Location -Stack).Count)>" }
#`r`n is just a shorter way of writing [System.Environment]::NewLine
Add it to the profile to suits your needs:
AllUsersAllHosts:
C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
AllUsersPowerShell:
C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
AllUsersISE:
C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1
CurrentUserAllHosts:
C:\Users\username\Documents\WindowsPowerShell\profile.ps1
CurrentUserPowerShell:
C:\Users\username\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
CurrentUserISE:
C:\Users\username\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

WScript Sendkey doesn't accept Unicode Characters

I am trying to send char "ä" using WScript Sendkeys.Seems its not working . I found one post Does or Can VBscript's SendKeys support Unicode?
My Code:
Set sh = WScript.CreateObject("WScript.Shell")
sh.Run "notepad.exe", 9
WScript.Sleep 1000 'wait a while to load notepad app'
sh.SendKeys " äää Hello World!" //buggy line
sh.SendKeys "{ENTER}"
WScript.Sleep 100'
sh.SendKeys "^p"
but i am unable to understand the solution. Would be great if you teach me in plain simple code (for solution). I am not good at WScript(as its not my area).
I know i am begging for code(Pz forgive me). but plz understand my situation.
Many thanks in advance!!
Windows Script Host's SendKeys doesn't support Unicode.
Alternatives to WSH/SendKeys:
Use the free tool AutoIt for GUI automation. You can use AutoIt's Send, ControlSend or ControlSetText commands to automate text input.
Run('notepad.exe')
WinWaitActive("[CLASS:Notepad]", "", 10)
ControlSend("[CLASS:Notepad]", "", "Edit1", "äää Hello World!")
Write code in another programming language (C++, C# etc) and call the Windows API SendInput function with the KEYEVENTF_UNICODE flag.
The comment is wrong. There is no such thing as a unicode, or any other code, keyboard except for keyboard codes called scancodes. If you can't enter it at the keyboard then neither can sendkeys. They are keystrokes not characters. The meaning depends on the keyboard layout you are using. Use the same keystrokes as the keyboard. Windows converts it into a ascii character if the Window was created with CreateWindowA or a unicode character if the window was created with CreateWindowW.

How can I move the cursor quickly to a specific location in a text I have just copy pasted in an Advanced Scripting command?

I am writing an Advanced Scripting voice command in Dragon NaturallySpeaking Professional 11.5 to write SQL commands by voice. Regarding the ORDER BY variable_name ASC command, I would like to move cursor right before ASC:
Sub Main
Clipboard(" ORDER BY ASC ")
SendKeys "^v"
End Sub
How can I do so efficiently as in the built-in double quotes command?
Add some arrow keys right after ^v:
Sub Main
Clipboard(" ORDER BY ASC ")
SendKeys "^v^{LEFT}{LEFT}"
End Sub

MS Word commands from command line

I need to start MS Word from command line. Now, I pass these commands /q /n /mFilePrintDefault /mFileExit to it. In this case, I need manually press "No" on "save yes/no" dialog at the end (to close Word). What commands need to pass, to skip this (without saving or with saving doc) and automatically close Word?
In Word, create a macro in Normal.dotm using this code:
Sub CloseWithoutSaving()
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Application.Quit
End Sub
Then pass /q /n /mFilePrintDefault /mCloseWithoutSaving
I assume you are trying to print the document from the command line. You might want to do it the same way MS does it with right-click print. You can see details on this here:
http://www.robvanderwoude.com/ddecommandline.php