Jump to content

Reading table from clipboard


ggg
 Share

Recommended Posts

If we select the 2x2 table near the bottom of

http://www.autoitscript.com/code/

and press ctrl-c to copy it to the clipboard and

run the AutoIt program:

$x = ClipGet()

MsgBox(0,"",$x)

then adjacent cells in a row are all run together.

However, if we paste that same clipboard

into Excel then the table cells appear in

similarly arranged cells in the Excel

spreadsheet. Excel knew how to

distinguish the individual cells.

How do I do that in AutoIt? That is

how does one read in the clipboard in

this example so that one can still

distinguish which text goes in which

cell like Excel can do?

Is it possible in AutoIt?

(Note that I am not looking for a solution

based on parsing the original HTML

file. I know how to do that using

the InternetExplorer.Application COM

object but that's not what I am asking. What I

don't know is how to distinguish the cells

in the clipboard. The info must be there

since Excel can do it. But it does not

seem to appear in AutoIt.)

Note that if I paste it into Excel and then

copy it back from Excel and run the

above AutoIt program then I can

distinguish it since Excel puts tabs

between cells in a row but I want to

do this entirely programmatically

and not involve Excel at all. I guess

I would settle for a free utility that

inserts tabs into the clipboard provided

its automatic although a solution

entirely in AutoIt Scripting Language

would be even better.

Link to comment
Share on other sites

I don't believe it's as simple as that. There is more to the clipboard than meets the eye: download an open source application called CLCL.exe (http://www.nakka.com) .. Besides keeping a history of your clipboard, it displays all the details about what's currently in it.

Copy your HTML table, and see what CLCL reveals .. I think you'll be surprised, if not fascinated :P

Given that what you paste into Excel preserves the font characteristics of the HTML, I'd say that Excel doesn't just interpret the "Text" portion of the clipboard, but perhaps something like the clipboard's Rich Text Format object.

There have been incentives in the past to get the AU3 ClipGet() function to provide more than just the text that might be on the clipboard. If CLCL can do it (source readily available), then it should be possible to harvest such delights as images, file-lists, and even RTF for you, too.

Maybe this is an opportunity to revisit the question. Devs?

HTH

;)

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