saywell Posted July 23, 2010 Share Posted July 23, 2010 (edited) 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 July 23, 2010 by saywell Link to comment Share on other sites More sharing options...
Ascend4nt Posted July 23, 2010 Share Posted July 23, 2010 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. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
saywell Posted July 23, 2010 Author Share Posted July 23, 2010 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 ..: 18Clipboard format 1 Number:49161 String: DataObjectClipboard format 2 Number:49166 String: Object DescriptorClipboard format 3 Number:49332 String: Rich Text FormatClipboard format 4 Number:49434 String: HTML FormatClipboard format 5 Number:1 String: TextClipboard format 6 Number:13 String: Unicode TextClipboard format 7 Number:14 String: Enhanced MetafileClipboard format 8 Number:3 String: Metafile PictureClipboard format 9 Number:49163 String: Embed SourceClipboard format 10 Number:49156 String: NativeClipboard format 11 Number:49155 String: OwnerLinkClipboard format 12 Number:49165 String: Link SourceClipboard format 13 Number:49167 String: Link Source DescriptorClipboard format 14 Number:49154 String: ObjectLinkClipboard format 15 Number:49710 String: HyperlinkClipboard format 16 Number:49171 String: Ole Private DataClipboard format 17 Number:16 String: LocaleClipboard format 18 Number:7 String: OEM TextIf I copied it into notepad, then re-copied to the clipboard, I get:Clipboard formats ..: 4Clipboard format 1 Number:13 String: Unicode TextClipboard format 2 Number:16 String: LocaleClipboard format 3 Number:1 String: TextClipboard format 4 Number:7 String: OEM TextNot 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 More sharing options...
Ascend4nt Posted July 23, 2010 Share Posted July 23, 2010 $sText=ClipGet() should work fine for you since you have both Text and Unicode Text formats in the Clipboard. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
doudou Posted July 23, 2010 Share Posted July 23, 2010 How about $sText = _ClipBoard_GetData($CF_TEXT) or $sText = _ClipBoard_GetData($CF_UNICODETEXT) ? UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE Link to comment Share on other sites More sharing options...
saywell Posted July 24, 2010 Author Share Posted July 24, 2010 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 More sharing options...
AndyG Posted July 25, 2010 Share Posted July 25, 2010 if you load the MS-Word text into Scite and type CTRL*SHIFT+8 and CTRL+SHIFT+9 you will see the spaces and the EOL Link to comment Share on other sites More sharing options...
saywell Posted July 25, 2010 Author Share Posted July 25, 2010 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 More sharing options...
saywell Posted July 26, 2010 Author Share Posted July 26, 2010 Update: ClipGet works for Word 2007 but NOT in Word 97! _ClipBoard_GetData ($CF_UNICODETEXT) works in '97 though. William Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now