Jump to content

Mixed Clipboard data


Recommended Posts

Can anyone point me in the right direction please?

I'm copying the content of a Word Doc into the clipboard to use the text in an html document later [via a string].

There is an image in the word doc that gets copied [using ^a, ^c ] but the text is there on the clipboard [eg it works if i paste into notepad] - I'm not needing to save the picture.

I've tried various functions to get the text component from the clipboard into a string, but none has worked - not sure if I'm using the wrong tool, or using the right tool wrongly!

I've tried

ClipGet ( )

_ClipBoard_GetPriorityFormat

_ClipBoard_GetData and

_ClipBoard_GetDataEx

all to no avail!

In desperation I may have to resort to opening notepad, ^v, close, and fileread ! But that would be a horrible way to do it!

Thanks,

William

Edited by saywell
Link to comment
Share on other sites

Try enumerating the clipboard formats available to see whats there after you do a copy.

Check the modified version of the Help file example for _Clipboard_EnumFormats here.

Link to comment
Share on other sites

Try enumerating the clipboard formats available to see whats there after you do a copy.

Check the modified version of the Help file example for _Clipboard_EnumFormats here.

Thanks. I used that example to get the following:

From word doc copy:

I got the following:

Clipboard formats ..: 18

Clipboard format 1 Number:49161 String: DataObject

Clipboard format 2 Number:49166 String: Object Descriptor

Clipboard format 3 Number:49332 String: Rich Text Format

Clipboard format 4 Number:49434 String: HTML Format

Clipboard format 5 Number:1 String: Text

Clipboard format 6 Number:13 String: Unicode Text

Clipboard format 7 Number:14 String: Enhanced Metafile

Clipboard format 8 Number:3 String: Metafile Picture

Clipboard format 9 Number:49163 String: Embed Source

Clipboard format 10 Number:49156 String: Native

Clipboard format 11 Number:49155 String: OwnerLink

Clipboard format 12 Number:49165 String: Link Source

Clipboard format 13 Number:49167 String: Link Source Descriptor

Clipboard format 14 Number:49154 String: ObjectLink

Clipboard format 15 Number:49710 String: Hyperlink

Clipboard format 16 Number:49171 String: Ole Private Data

Clipboard format 17 Number:16 String: Locale

Clipboard format 18 Number:7 String: OEM Text

If I copied it into notepad, then re-copied to the clipboard, I get:

Clipboard formats ..: 4

Clipboard format 1 Number:13 String: Unicode Text

Clipboard format 2 Number:16 String: Locale

Clipboard format 3 Number:1 String: Text

Clipboard format 4 Number:7 String: OEM Text

Not sure how to proceed from here, as there are obviously still mixed data types even when notepad has stripped a lot of the word stuff out!

William

Link to comment
Share on other sites

$sText=ClipGet()
should work fine for you since you have both Text and Unicode Text formats in the Clipboard.

Link to comment
Share on other sites

How about

$sText = _ClipBoard_GetData($CF_TEXT)

or

$sText = _ClipBoard_GetData($CF_UNICODETEXT)

?

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE 

Link to comment
Share on other sites

OK, I'm making progress! Thanks.

I can use clipget - the reason I thought it didn't work was because I was trying to show the string in a MsgBox, and id showed balnk [presumably due to the mixed content].

Writing it to a text file works fine.

My next problem is that although the line breaks are passed to the text file, I need to replace them with <BR> as I'm trying to create an html page.

StringReplace @CR or @CRLF with <BR> has no effect

I presume Word line feeds are a special character. I know it's included in the string because notepad starts new lines appropriately.

But, how do I search for it in AutoIt?

I guess what I'm asking is: what is the new line character in micro$soft word?

Thanks,

William

PS would I be better posting this as a new question?

Link to comment
Share on other sites

Thanks, all.

I couldn't get onto this site yesterday evening/earlier today [uK time], but had a browse round the net ans the help files.

I found in the RegEx section an option to identify 'all vertical tab characters'. I have successfully used this in a regex search & replace them with <br> for the html.

Also found that Word uses ASCII characters thus:

^9 or ^t Tab

^11 or ^l New line

^12 Page or section break (Replaces a section break with a page break)

^13 or ^p Carriage return/paragraph mark

^14 or ^n Column break

But I couldn't work out how to add an ASCII 11 to a string for an ordinary string replace . No matter, though, as the regex method works fine.

Regards,

William

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