How can I convert rich text to plain text in advanced scripting? - naturallyspeaking

I would like to write a voice command to paste the clipboard in plain text. How can I convert rich text to plain text in advanced scripting?
I use Dragon NaturallySpeaking 12.5 professional with Windows 7 SP1 x64 Ultimate.

I haven't found any solution using advanced scripting.
As a pis-aller, I have set up a shortcut that copies content to the clipboard using PureText 3.0:
The following AHK script should also work, but might be unfriendly with Unicode characters:
^!v::
ClipboardTemp = %ClipBoardAll%
ClipBoard = %ClipBoard%
Send ^v
sleep, 30
ClipBoard = %ClipboardTemp%
Return

Related

Why can my AutoHotkey script only type some emoji?

I have set up a small AutoHotkey script that uses hotstrings to allow me to type a few emoji and other special characters:
#SingleInstance force
#Hotstring * ?
::–::–
::†::†
::π::𝜋
::&shrug;::¯\_(ツ)_/¯
::&tm;::™
::&c;::©
::&r;::®
::&tableflip;::(╯°□°)╯︵ ┻━┻
::&music;::♫
::&piano;::🎹
::&cmark;::✓
::&xmark;::✗
::&hourglass;::⌛
The script is also available on PasteBin.
It all works in my text editor:
However, some replacements don't work everywhere, for example in Telegram Desktop:
Both emoji were originally copied from Telegram Desktop, so they are definitely supported in it.
Why isn't this working as expected?
I'm running AutoHotkey Unicode 64-Bit in version 1.1.23.3 on Windows 10 (version 1511), Sublime Text 3 (3103) and Telegram Desktop 0.9.28.
I answered a similar question in the past: Autohotkey Replace 2 specific character with one
I don't really know what the problem was, but we managed to get around the problem by making use of the clipboard. Maybe the same method can be used for your scenario.

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.

microsoft word: copy without formatting

When I copy a text from Microsoft Word and the text is a heading in the clipboard I see it included a paragraph number. Then in another application I must remove the number manually.
Can I copy just a text without any additional information?
(The same is with Chrome when you copy a URL it adds a http:// automatically)
Method 1:-
one way is right mouse click and use this paste special option
Method 2:-
assign a shortcut(Ctrl+Shift+V) for this operation (Note: by default Ms word not set shortcut for it so we need to set it by own)
File > Options > Customize Ribbon > Keyboard shortcuts: Customize.
on Left Categories List section, click on All Commands
Under right Commands List, select for PasteTextOnly
then Set the keyboard shortcut for PasteTextOnly as Ctrl+Shift+V
Method 3 permanent/Default Settings
use this option which will each time paste as plain text by default
Try this
Sub FormatFreeTextCopy()
Dim ffText As DataObject
Set ffText = New DataObject
ffText.setText Selection.Text
ffText.PutInClipboard
End Sub
Note: You would have to Reference to Microsoft Forms Object Library
There is a generic "paste plain text" solution using autohotkey open-source automation software:
^+v:: ; Text–only paste from ClipBoard
Clip0 = %ClipBoardAll%
ClipBoard = %ClipBoard% ; Convert to text
Send ^v ; For best compatibility: SendPlay
Sleep 50 ; Don't change clipboard while it is pasted! (Sleep > 0)
ClipBoard = %Clip0% ; Restore original ClipBoard
VarSetCapacity(Clip0, 0) ; Free memory
Return
Save this code to paste_plain_text.ahk script
Install autohotkey
Execute your script
It will paste plain text using Ctrl+Shift+V shortcut. You can put your script at Startup directory so it loads on Windows startup.

Windows notepad not supporting newline character '\n'

From my iPhone application I'm outputting data from text to a file. When opened with windows notepad, the data is all on one line and where there should be a new line a block character is present (showing that it's an unrecognized character or something). When opened with windows wordpad, it displays just fine. Would there be something wrong in my code? I'm simply output '\n' when i want a new line.
NOTE : It's working fine with other editors like textedit, MS Word on mac as well as on windows.
Windows default is to use \r\n as end-of-line marker. Notepad only recognises that, other text editors may know about other line-end styles and render correctly.
EDIT
As VonC answers Notepad had an update (in 2018) where it now can recognize non-Windows end-of-line sequences.
I'm simply output '\n' when i want a new line.
And starting May 2018 (6 years later), you will get a newline!
See "Introducing extended line endings support in Notepad" by Michel Lopez (and his tweet)
For many years, Windows Notepad only supported text documents containing Windows End of Line (EOL) characters - Carriage Return (CR) & Line Feed (LF). This means that Notepad was unable to correctly display the contents of text files created in Unix, Linux and macOS.
Today, we’re excited to announce that we have fixed this issue!
Starting with the current Windows 10 Insider build, Notepad will support Unix/Linux line endings (LF), Macintosh line endings (CR), and Windows Line endings (CRLF) as usual.
New files created within Notepad will use Windows line ending (CRLF) by default, but it will now be possible to view, edit, and print existing files, correctly maintaining the file’s current line ending format.
Also note that the status bar indicates the detected EOL format of the currently open file.
See an .bashrc finally displayed correctly!
This is because \n does not represent a full line break in Windows. Using \n is "the Unix" way of doing line breaks.
On Windows, there are text-editors like Notepad++ which handle both, but Notepad is really dumb in that respect.
I suggest you create a setting in your iPhone application where the user can choose between Windows and Unix line endings - then it's his responsibility :-)
Recently ran into this issue and I was convinced that it was my code which is doing this but turns out Notepad has problems rendering the file in the right format.
How do we fix this?
There is no fix available of this behavior of notepad but here is a list of workarounds that can be performed in order to read the contents correctly.
Workaround
You can use Windows WordPad to open the file or just paste the contents of the file into WordPad and back into Notepad . This should fix the problem .
You can also use Notepad++ to open the files which is a third-party text reader and can be installed on a windows system.
Microsoft recently (October 2018) announced that Notepad has been fixed in Windows 10 version 1809 so updating your system to windows 10 should resolve this issue (Windows versions before 1809 are impacted)
Microsoft fixed this after 33 years !!! Gee thats a long time to fix the issue aint it ?

Notepad++: Writing a run command using an installed plugin

I am trying to find a way to take the syntax highlighted text from N++ and then open it within say MS Word. I have found the plugin NppExport which can save the highlighted text to a rtf file. But it seems N++'s macros are not able to really utilize it. Any suggestions to automate this process? Thanks!
Basic steps are
1) call "Export to RTF"
2) Save to ${FULL_PATH_NAME}.RTF
3) open the RTF file
3) Open MS word
Note: I have 4 figured out using
"C:\Program Files\Microsoft Office\Office12\Winword.exe" /f "$(FULL_CURRENT_PATH)"
Since you are meshing two programs (Notepad++ and Word). It may be difficult to do totally in the macros. I haven't had much luck with the macros beyond repetitive text manipulation. But I can recommend the tool AutoHotKey (autohotkey.com) which makes implementing these tasks super simple. Here is a little example that I tried out. Yes it works.
^#R::
WinMenuSelectItem , ahk_class Notepad++,,Plugins, NppExport, Copy RTF to clipboard
SetTitleMatchMode, 2 ;find by partial title
WinActivate Microsoft Word
Send ^v
This will copy the text in RTF switch the active window to word and paste the code. It would be relatively simple to change the command to open a new window instead.