Jump to content
Sign in to follow this  
Guy_

Filtering out Returns from webpage & pdf txt

Recommended Posts

Guy_

I'd like all Returns to disappear in my saved clipboard text, mainly from webpages and pdf files.

I've tried

$savedClip = ClipGet()
$savedClip = StringStripCR ( StringStripWS ( $savedClip, 3 ))

and it does something I want, but never seems to strip returns from web text...(haven't tried pdf yet)

None of the parameters seem to do that?

(btw, the manual uses the 3 parameter but doesn't document it on the StringStripWS page?)

Do I need a whole routine like this trimmer maybe?

Thank you :)

Edited by Guy_

Share this post


Link to post
Share on other sites
BrewManNH

3 means add options 1 and 2 together, strip leading and trailing whitespace.

PDFs aren't text so it's not going to remove anything from them. The HTML files use <br> or <P> for end of line carriage returns, the actual line endings have no meaning for the most part as far as HTML goes, they're just coded text files. This is my understanding of how HTML works, I don't write web pages so I'm not 100% sure.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Guy_

Thx for "3" :)

I don't think these html codes are copied from a webpage? You're copying text after all, not from the source html?

I used to filter out these returns when I used to use a FileMaker database, and it worked on both web text and text copied from pdf. So I would think it's the same character that needs filtering - just need to know which one and how best to do it.

When I know, I could use StringReplace I guess, but I would suspect there were built-in functions that really worked ;)

Edited by Guy_

Share this post


Link to post
Share on other sites
BrewManNH

Post what you have coded so far so that we can see what you're doing and where there might be an error in that. Even if it doesn't work as intended, we will at least have an idea of where to start.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Guy_

It's as simple as I quoted essentially...

I select a piece of text and then essentially...

Send("^c")

$savedClip = ClipGet()

$savedClip = StringStripCR ( StringStripWS ( $savedClip, 3 ))

ClipPut( $savedClip )

WinActivate("WordPad")

Send("^v")

I've tried the stripping functions seperately too, but a CR is never stripped AFAIK

Edited by Guy_

Share this post


Link to post
Share on other sites
BrewManNH

You could do it this way.

$savedClip = StringReplace( $savedClip, @CRLF, "")

The way you have it written, it is only removing the last CRLF and not all of them. The clipboard text is considered to be one string, regardless of how many lines you have in it, and you're only removing the trailing and leading WS.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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  

×