Jump to content

Remove formatting from clipboard


remin
 Share

Recommended Posts

I use this function since many many years (hotkey: ctrl-g).

Func _ClearAndPaste() ; CTRL+g
    ; serve _Clipboard.au3 in include
    Local $aClip
    _Clipboard_GetAll($aClip) ; save clipboard contents
    Local $sClip = ClipGet() ; get clipboard as plain text
    ClipPut($sClip) ; put clear text back on clipboard
    Send("^v") ; paste it
    _Clipboard_PutAll($aClip) ; restore previous contents (clears current contents)
    _Clipboard_MemFree($aClip)
EndFunc

It does not work anymore. It just paste the Rich text.

Has anything changed in windows as far as the clipboard is concerned?

ps: I did not change autoit version. Still the same as before (3.3.14.5)

Edited by remin
more info
Link to comment
Share on other sites

Yes I tried it. Strange things are happening now:

If I copy a formatted text and put the cursor a line below the formatted text and use the hotkey Ctrl-g the formatting is removed. If I put the cursor after the formatted text and use the same hotkey the formatting is not removed.

Edited by remin
Link to comment
Share on other sites

You will get better help if you provide something that runs and reproduces your issue.  The smallest amount of script possible.

 

What does your string look like?  I have no idea.

 

What does your function do?   No clue,  you didn't provide it.

Edited by jdelaney
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

On 2/8/2020 at 12:25 AM, jdelaney said:

You will get better help if you provide something that runs and reproduces your issue.  The smallest amount of script possible.

 

What does your string look like?  I have no idea.

 

What does your function do?   No clue,  you didn't provide it.

It captures the clipboard text, removes the formatting and paste it in the text.

Please see the comments tags after the code in above function.

Link to comment
Share on other sites

On 2/7/2020 at 10:21 PM, Danp2 said:

That sounds more like an issue with the program you are pasting into than the script.

Have you tried the following --

; send actual text instead of pasting it from the clipboard
Send($sClip)

 

Thanks for your answer.

I tried this, but nothing changes.
I don't understand what's going on.
The script doesn't work anymore (without me changing anything).

Link to comment
Share on other sites

Like I stated previously, I believe this behavior is controlled by the program in use when you paste the string. For example, I experience the exact same behavior you describe when testing with MS Word. However, I can add the following line to "reset" the formatting before the paste occurs --

Send("^{SPACE}{SPACE}")

 

Link to comment
Share on other sites

1 hour ago, Danp2 said:

Like I stated previously, I believe this behavior is controlled by the program in use when you paste the string. For example, I experience the exact same behavior you describe when testing with MS Word. However, I can add the following line to "reset" the formatting before the paste occurs --

Send("^{SPACE}{SPACE}")

 

Thanks. If the formatted text is underlined the pasted text will start with an empty underline character.

Link to comment
Share on other sites

Word uses the Ctrl+Space shortcut to clear formatting. Obviously, that doesn't work if Wordpad doesn't offer the same functionality.

I've shown you an example to make your script work with Word. You haven't told us the actual program you are using, so I don't see how we can be of further assistance.

Link to comment
Share on other sites

3 hours ago, Danp2 said:

Word uses the Ctrl+Space shortcut to clear formatting. Obviously, that doesn't work if Wordpad doesn't offer the same functionality.

I've shown you an example to make your script work with Word. You haven't told us the actual program you are using, so I don't see how we can be of further assistance.

Thank you. I use it in all programs. Never had any problem before. Yesterday I added sleep() before an after the send command and it worked again but not in Wordpad. Not a problem. Thank you for your help. Have a nice day.

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...