Jump to content
Sign in to follow this  
hogfan

Reliable way to copy text globally and strip formatting?

Recommended Posts

hogfan

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

Share this post


Link to post
Share on other sites
jdelaney

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.

Share this post


Link to post
Share on other sites
hogfan

Thanks.  That should get me going in the right direction.

Share this post


Link to post
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
Sign in to follow this  

×