Jump to content
Sign in to follow this  
Suppir

How to "rip off" RTF-data from text?

Recommended Posts

Suppir

Hello!

I have got text with hyperlinks in my program. If I'll copy this text in MS Word - hyperlinks will stay at the right place. But if I'll copy text in notepad - hyperlinks will dissappear. That is because notepad does not support RTF tags.

The adress of each hyperlink consists of 8-digit number, and I want to rip-off these numbers from my text to array. How to do it with AutoIt? Does it support raw data and RTF tags? Thanks.

Edited by Suppir

Share this post


Link to post
Share on other sites
James

The adress of each hyperlink consists of 8-digit number, and I want to rip-off these numbers from my text to array. How to do it with AutoIt? Does it support raw data and RTF tags?

I guess you could analyse the data in the clipboard and using a regular expression to look for these hyperlinks. If this is how you want to do it, then you'll need the ClipGet and StringRegExp.

Share this post


Link to post
Share on other sites
Suppir

I guess you could analyse the data in the clipboard and using a regular expression to look for these hyperlinks. If this is how you want to do it, then you'll need the ClipGet and StringRegExp.

I've already try it. But text after ClipGet() function is "flat" like in notepad. So, all metadata(font, style, hyperlinks, tables) is clipped out.

Edited by Suppir

Share this post


Link to post
Share on other sites
James

I've already try it. But text after ClipGet() function is "flat" like in notepad. So, all metadata(font, style, hyperlinks, tables) is clipped out.

Why are you going about it that way? Copy the data out from the clipboard as you copy from the RTF?

Share this post


Link to post
Share on other sites
Suppir

Why are you going about it that way? Copy the data out from the clipboard as you copy from the RTF?

I did not understand properly your saying. I'm selecting some text with hyperlinks by mouse, then copying selected in clipboard (CRTL+c). Then I'm searching by regular expressions in clipboard, but there is no RTF tags, only "flat text" of selection. I think that is because ClipGet() returns text with no RTF tags.

Edited by Suppir

Share this post


Link to post
Share on other sites
James

I did not understand properly your saying. I'm selecting some text with hyperlinks by mouse, then copying selected in clipboard (CRTL+c). Then I'm searching by regular expressions in clipboard, but there is no RTF tags, only "flat text" of selection. I think that is because ClipGet() returns text with no RTF tags.

Oh sorry, I see. How about _ClipBoard_GetData() does any of that help?

Share this post


Link to post
Share on other sites
Suppir

Oh sorry, I see. How about _ClipBoard_GetData() does any of that help?

Thanks, I will try it

Share this post


Link to post
Share on other sites
Malkey

This may give you a direction.

If it nearly works, you may be able to adjust the regular expression pattern to extract exactly what you require.

Instead of the StringRegExp() function, _StringBetween () in #Include <String.au3> might be easier to use.

#include <Array.au3>

;Create "WithHyperlinks.rtf" with Word, insert hyperlinks, saved as rtf file.
Local $sStr = FileRead("WithHyperlinks.rtf")
Local $aHyperLks = StringRegExp($sStr, "(?s)HYPERLINK (.*?)\*\\datafield", 3)

_ArrayDisplay($aHyperLks)

Share this post


Link to post
Share on other sites
Suppir

This may give you a direction.

If it nearly works, you may be able to adjust the regular expression pattern to extract exactly what you require.

Instead of the StringRegExp() function, _StringBetween () in #Include <String.au3> might be easier to use.

#include <Array.au3>

;Create "WithHyperlinks.rtf" with Word, insert hyperlinks, saved as rtf file.
Local $sStr = FileRead("WithHyperlinks.rtf")
Local $aHyperLks = StringRegExp($sStr, "(?s)HYPERLINK (.*?)\*\\datafield", 3)

_ArrayDisplay($aHyperLks)

I've done it. But rtf contains only hyperlinks to himself (local). And glogal hyperlinks (to others documents) had dissapeared.

I'm copying text from my program to Word. Then I see, that only local hyperlinks are displayed and to be saved in rtf.

I want to rip-off hyperlinks without using Word, just from the selection in my program. When I do a selection, I'm sure that all the data contains in buffer. But later, when I paste it to another program, my hyperlinks dissappear :D

Edited by Suppir

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  

×