Jump to content

Reliable way to copy text globally and strip formatting?


Recommended Posts

I am familiar with using the ClipPut() & ClipGet() functions, but I am looking for a reliable way to do the following in autoit:

1.) Copy the currently selected/highlighted text globally (in any application) to the clipboard.

2.) Strip ANY and ALL formatting so it's plain text only.

3.) I guess I use ClipGet() function to get the plaintext from the clipboard to paste.

 

I am going to add a "Copy Plain Text" as an option to the Windows right-click context menu.  That shortcut will run my compiled AutoIT application that will basically copy the selected text to the windows clipboard, strip the formatting, and add it back to the clipboard so when it is pasted there is no formatting.

What functions should I be looking at to do this easily.   I do a ton of copy & paste for work each day and I NEVER want to keep the formatting between Excel, Outlook, and several Company applications.  

The reason something like Puretext doesn't work for me is I have to manually start it everyday. Can't get it to start from the startup programs folder (probably some Group Policy).  I do most of my driving with the mouse so I use a lot of "Right-click" copy & paste.  It drives me crazy that Windows has no useful clipboard options.

- jeremy

Link to comment
Share on other sites

Something like this?  You'll have to sub in your actual string modifications.

$iLastCopy = ""

While True
    $iCurrentCopy = ClipGet()
    If StringLen ($iCurrentCopy) = 0 Then ContinueLoop
    If $iCurrentCopy <> $iLastCopy Then
        ; format your stuff here
        $sFormat = String($iCurrentCopy)
        $iLastCopy = $sFormat
        MsgBox(1,1,$iLastCopy)
        ClipPut($iLastCopy)
    EndIf
    Sleep(500)
WEnd
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...