Windows: Convert formatted text in clipboard to plain text

Hi,

when you often have to copy some text between HTML/Browser pages, browser based content management systems, Office Documents and terminal emulators you know the problem: Text from browsers and office documents also contains format attributes like font size, fonts etc. which causes an unexpected layout or format.

For example, if you copy a text from LibreOffice to wordpress(Yes of course, you could paste the test  into wordpress by using the “paste plain text” toolbar buttons. But this is one step more and I prefer Ctrl V Ctrl C for copy and paste).

Formatted Office text
Formatted Office text
Formatted Office text in wordpress

I wrote a small tool which eliminates all formats from text in the clipboard. What the tool does.

  • It resides in systray respective notification area

    Tool in Notification area

  • It registers a global Hotfix, default Ctrl-S, when pressed, the text in clipboard is “unformatted”
  • It has an automatic mode. If a text is copied to the clipboard, the text is immediately “unformatted” and copied back to clipboard.
  • When  a text is unformatted, it displays a Ballontip with the text  for a few seconds.

    Tool in Notification area

  • It converts Office double quotes „Your Text“ to double quotes used in command lines “Your Text” (replace mode) https://lookup-phone-prefix.com , also the minus character is converted.

The tool is written in C#. Binaries (Folder \bin\Release\unformatClipboardText.exe) and Visual Studio 2013 project files are attached in the zip package below. Modify it for your own needs!

Update: V1.1 has also the ability to convert all text to upper- and lowercase.

Update: V1.2 If a valid MAC Address is found in Clipboard, unformatClipboardText can convert it to one of the following formats

  • 0123456789AB
  • 01:23:45:67:89:AB
  • 01-23-45-67-89-AB
  • 0123.4567.89AB

this version also can remove leading and trailing spaces.
Update: V1.2.2 Its possible to switch off the Global hotkey
Update: V1.2.3.1 Its possible to disable the balloon tip on unformat
Update: V1.2.3.4 More stable
Update: v1.3.0.0 All clipboard activities can logged to a file
Update: V1.4.0.0 Only one program instance can start
Update: V1.4.4.0 Logfile can viewed within the program. Bugfixes
Update: V1.4.4.3 Logfileformat changed from UTF BOM to UTF. Logview Autoscroll can be disabled
Update: V1.4.4.5 Fixes the null pointer exception which sometimes occures

Michael

Credits and honor  to Christian Liensberger and CooLMinE for technics to register a global hotkey and a clipboard change detect in C#.

Converts formatted text in Windows clipboard to plain text
unformatClipboardText.7z
Version: 1.4.4.5

Converts formatted text in Windows clipboard to plain text

Author:Michael Albert
Category:C#
License:GNU General Public License
Date:October 16, 2014
267.6 KiB
479 Downloads
Details...

23 thoughts on “Windows: Convert formatted text in clipboard to plain text”

  1. Hi Michael,

    Unformat does excactly what i want it to do, but with the anoying CTRL+S hotkey. This hotkey is used to save documents in about all programs. Is there any way i can remove this?

    Thanks

    -Kim

  2. Dear Michael,

    thanks for giving us unformatClipboardText !

    Can we please have a portable version with an EXE
    which doesn´t need to be installed be Setup ?

    Regards,

    Bernhard

    1. Hi Bernhard,

      checkout V1.2.3.1. A View menu entry is available to disable the balloon tip.

      You do not have to use Setup. You can use the precompilied version in the bin\release folder.

      Michael

  3. Dear Michael,

    I´ve tested version v1.2.3.1 and this works well for me:
    BalloonTips can be disabled disabled by menu.

    But I´ve tried to disabled balloon tips and Global Hotkey via “INI-File”:
    unformatClipboardText.exe.config
    but unformatClipboardText.exe seems to refuse the settings on startup ?

    Regards,

    Bernhard

    1. Hi Bernhard,

      the settings are stored persistent and loaded at startup as you set it by menu.

      Did you edit the correct config file? AFAIK for each program version an own file is created.

      Michael

  4. Dear Michael,

    tried last v1.2.3.1 and it doesn´t store the settings on exit here by me.
    Can´t find another unformatClipboardText.exe.config else than in the programs directory itself (bin\Release).

    If I delete this unformatClipboardText.exe.config and than start unformatClipboardText.exe there´s an MS .NET error that Config File can´t be accessed. I suggest to check on existance of the Config-File, and if not, create a new one ?

    If I change anything in the config-file, nothing seems to be read-out from it while starting the EXE. And nothing seem to be stored in the Config-File when I close the EXE. (I´m not shure about the Balloon-Tip Option, but Global Hotkey Option is enabled every time I start the EXE regardless of a settings this to False in the Config-File.

    Regards,

    Bernhard

    1. Hi Bernhard,

      I missunderstood your previous comments 🙂

      unformatClipboardText.exe.config is just for the first start of unformatClipboardText.exe, leave it untouched.

      The config is stored in the AppData Folder of your profile, for example:
      C:\Users\michael\AppData\Local\michlstechblog.info\unformatClipboardText.exe_Url_qkoqqkczywmemqwxh1wuozeyydsndncf\1.2.3.1\user.config

      it is created at the first time you change a property from its default value.

      Michael

  5. Dear Michael,

    thank you for poiting that out. The file-name is user.config
    here´s my path:
    C:\Users\User\AppData\Local\michlstechblog.info\unformatClipboardText.exe_Url_cdtaclc3kg5mwl202tuol5pc3gsq4mtl\1.2.3.1\user.config

    Maybe I found an error:
    Seems, the when disabling “Global Hotkey” a True is stored for “EnableGlobalHotKey”
    in the User.Config File instead of a False ?!

    Also: Editing this Config.File manually with an editor seems to rise an .NET Error
    (only changes via right-click menu seem to be well stored (except of GlobalHotkey-Setting as described above).

    Regards,

    Bernhard

    Regards,

    Bernhard

  6. Dear Michael,

    please check v1.2.3.2 again. When trying to disable the Global Hotkey, it still saves “True” for “EnableGlobalHotKey” instead of “False” ?!

    Otherwise – works well now for me.

    Bernhard

  7. OK. Sorry, but I must say, other things don´t work now anymore:

    Saving the “EnableGlobalHotkey” now seems works,
    but when I close the EXE with Exit,
    it rises an Microsoft .NET Framework Error “Object reference not set to an object instance .”

    Bernhard

  8. Hello Michael,

    now I´ve v1.2.3.4 some working for me,
    and rarely it crashes with the .NET error I´ll paste.

    I can not yet find out a sample of “whats copied” which causes the error,
    and when I restart “unformatClipboardText” and copy it again, it works without crashing.

    At the moment it seems to happen when I copy something from within Outlook,
    but can not say this for sure. When I find out, I´ll mail you.

    Regards,

    Bernhard

    Informationen über das Aufrufen von JIT-Debuggen
    anstelle dieses Dialogfelds finden Sie am Ende dieser Meldung.

    ************** Ausnahmetext **************
    System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
    bei info.michlstechblog.unformatClipboardText.MainForm.WndProc(Message& m) in d:\Ablage\CS\unformatClipboardText\unformatClipboardText\MainForm.cs:Zeile 56.
    bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    ************** Geladene Assemblys **************
    mscorlib
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.6.1063.1 built by: NETFXREL3STAGE.
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll.
    —————————————-
    unformatClipboardText
    Assembly-Version: 1.2.3.4.
    Win32-Version: 1.2.3.4.
    CodeBase: file:///E:/WIN95PGM/unformatClipboardText/unformatClipboardText/bin/Release/unformatClipboardText.exe.
    —————————————-
    System.Windows.Forms
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.6.1038.0 built by: NETFXREL2.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll.
    —————————————-
    System
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.6.1038.0 built by: NETFXREL2.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll.
    —————————————-
    System.Drawing
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.6.1038.0 built by: NETFXREL2.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll.
    —————————————-
    System.Configuration
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.6.1038.0 built by: NETFXREL2.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll.
    —————————————-
    System.Core
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.6.1038.0 built by: NETFXREL2.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll.
    —————————————-
    System.Xml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.6.1038.0 built by: NETFXREL2.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll.
    —————————————-
    mscorlib.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.6.1038.0 built by: NETFXREL2.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_de_b77a5c561934e089/mscorlib.resources.dll.
    —————————————-
    System.Windows.Forms.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.6.1038.0 built by: NETFXREL2.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_de_b77a5c561934e089/System.Windows.Forms.resources.dll.
    —————————————-

    ************** JIT-Debuggen **************
    Um das JIT-Debuggen (Just-In-Time) zu aktivieren, muss in der
    Konfigurationsdatei der Anwendung oder des Computers
    (machine.config) der jitDebugging-Wert im Abschnitt system.windows.forms festgelegt werden.
    Die Anwendung muss mit aktiviertem Debuggen kompiliert werden.

    Zum Beispiel:

    Wenn das JIT-Debuggen aktiviert ist, werden alle nicht behandelten
    Ausnahmen an den JIT-Debugger gesendet, der auf dem
    Computer registriert ist, und nicht in diesem Dialogfeld behandelt.

  9. Dear Michael,

    another thing:

    Can you please add an option to add a “copy option” to automatically remove one line of two consecutive empty lines ?

    This can happen some time when we copy some text from Outlook or Word.
    (In Outlook or Word it looks like one empty line, but while copying/pasting to e.g. Notepad it inserts those text with two empty lines). That´s no problem of your program but somenthing with the line-spacing-formatting in Outlook/Word.

    I you like, we can talk in german ?

    Regards,

    Bernhard

  10. Still have sometimes problems with latest V1.4.4.3 when copying things from e.g. IE adress line or Outlook Email-Adress field:

    Informationen über das Aufrufen von JIT-Debuggen
    anstelle dieses Dialogfelds finden Sie am Ende dieser Meldung.

    ************** Ausnahmetext **************
    System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
    bei info.michlstechblog.unformatClipboardText.MainForm.WndProc(Message& m) in d:\Ablage\CS\unformatClipboardText\unformatClipboardText\MainForm.cs:Zeile 105.
    bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    ************** Geladene Assemblys **************
    mscorlib
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2101.1 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll.
    —————————————-
    unformatClipboardText
    Assembly-Version: 1.4.4.3.
    Win32-Version: 1.4.4.3.
    CodeBase: file:///E:/WIN95PGM/unformatClipboardText/unformatClipboardText/bin/Debug/unformatClipboardText.exe.
    —————————————-
    System
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2093.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll.
    —————————————-
    System.Windows.Forms
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2094.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll.
    —————————————-
    System.Drawing
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll.
    —————————————-
    System.Configuration
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll.
    —————————————-
    System.Core
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2099.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll.
    —————————————-
    System.Xml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll.
    —————————————-
    mscorlib.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_de_b77a5c561934e089/mscorlib.resources.dll.
    —————————————-
    System.Windows.Forms.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_de_b77a5c561934e089/System.Windows.Forms.resources.dll.
    —————————————-

    ************** JIT-Debuggen **************
    Um das JIT-Debuggen (Just-In-Time) zu aktivieren, muss in der
    Konfigurationsdatei der Anwendung oder des Computers
    (machine.config) der jitDebugging-Wert im Abschnitt system.windows.forms festgelegt werden.
    Die Anwendung muss mit aktiviertem Debuggen kompiliert werden.

    Zum Beispiel:

    Wenn das JIT-Debuggen aktiviert ist, werden alle nicht behandelten
    Ausnahmen an den JIT-Debugger gesendet, der auf dem
    Computer registriert ist, und nicht in diesem Dialogfeld behandelt.

Leave a Reply Cancel reply