Jump to content

_ClipBoard_GetDataEx trouble


Recommended Posts

Please let me understand how to do this be able to use formatted text from the clipboard as source material for parsing and interpreting later...

ClipGet() get me the text of course, and that has brought me lots of fine results already,

however now I will try to work with data that isn´t purely text, but from an e-mail and/or a webpage with the text in different table with different formatting.

So I would like to fetch data from the clipboard with the formatting (tables, bold, etc.), just like if I would copy something from a page or an e-mail and paste it into MS Word..

If I use ClipGet, the table structures and formatting etc. (that would be usefull for parsing) seem to be ignored...

...so I suppose _ClipBoard_GetData or _ClipBoard_GetDataEx are for this?

I believe the data format I want/need is $CF_LOCALE, and I have achieved, as a test, successfully getting the data with _ClipBoard_GetDataEx, and then setting it with _ClipBoard_SetDataEx and checking if it is in the right format when pasting in to MS Word.

Now the challenge:

How to I work with this data handle, i.e. this binary data, in a way where I can basically do things like parse it with StringRegExp etc.?

Can the binary data somehow be converted into a sort of html code or so?

Example1: If I have copied a line of text onto the clipboard, with one word in bold, how do I put that word in a variable in AutoIt?

Example2: If I have copied a simple 2x2 Table from an e-mail or webpage, how do I put that into an Array?

Edited by guestscripter
Link to comment
Share on other sites

You might get more people to read this if the text weren't so small, subscript text is very difficult to read on a web browser, and totally unnecessary.

Also, when a program, Word for example, pastes formatted text into the clipboard it uses its own private format or perhaps RTF to store that information in the clipboard. You may be able to access the text version of what is pasted there, but as to the formatted text, you'd have to try and retrieve it and see what it looks like before you can figure out how to parse it.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms649013(v=vs.85).aspx

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

Link to comment
Share on other sites

Thank you. I´ve improved the readability of my post. The clearer I get about the answer, the more clearer the question becomes, and in the beginning it was very unclear :-)

I´ve been to the page before that you recommended with the link, thanks anyway.

 

Just please help me one more bit forwards: to get to the point where I´m able to look at the retrieved data.

I understand that _ClipBoard_SetDataEx returns a handle. How do you retrieve data (binary?) from such a Clipboard handle. And then I would use BinaryToString()?

 

of course I´ve tried to research myself. And there is this one example in the helpfile:

; Read clipboard text
                    $hMemory = _ClipBoard_GetDataEx($CF_TEXT)
                    If $hMemory = 0 Then _WinAPI_ShowError("_ClipBoard_GetDataEx failed")
                    $tData = DllStructCreate("char Text[8192]", $hMemory)
                    MemoWrite(DllStructGetData($tData, "Text"))

however I suppose the part _ClipBoard_GetDataEx($CF_TEXT) needs to be changed to the correct format, and DllStructCreate("char Text[8192]"... looks like it is specific to Text, this would be my very first time working in any way with DllStructCreat..

Edited by guestscripter
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...