Hi I am new to AutoHotkey. Just want to know if is it possible to convert text from MS Word text in the clipboard to HTML code to put into a string. I would like to have the same sort of text that can be generated if you paste the text from Word in to the design tab in Dreamweaver and then view the code it generates.
Is this possible and if so how is it done?
Thanks

Convert clipboard data to HTML
Started by
beetle120
, Oct 15 2010 01:12 AM
14 replies to this topic
#1
-
Posted 15 October 2010 - 01:12 AM

Probably can be done. Do you have an example of what you want?
#3
-
Posted 17 October 2010 - 09:58 PM

Probably can be done. Do you have an example of what you want?
Thanks for you response. At my work we have an in house program that uses a simple HTML editor. All of the work that we put into this program is from Word that we copy/paste and manually format ourself adding all the
- and some class tags to match the formatting in the Word document (a very time consuming task). What I am thinking, to speed up this process, is from the clipboard (from the copy) find and replace the Word formatting using AutoHotkey to the simple HTML and the other tags we use before putting the string back in the clipboard ready for the paste.
I am not sure of the method that that windows uses to copy formatting to the clipboard. I am hoping that it is possible to get access to the HTML formatted text like what Dreamweaver has when you copy a word document in, so it would be easy to use find/replace to convert to simple HTML.
#4
-
Posted 18 October 2010 - 02:21 AM

SetClipboardData and GetClipboardData functions by PhiLho
The keyword that you need: HTML Format
The keyword that you need: HTML Format
GetClipboardData( "[color=darkred]HTML Format[/color]", Data ) VarSetCapacity( Data, -1 ) MsgBox, % Data
#5
-
Posted 18 October 2010 - 02:56 AM

Thanks a lot for that, I will give it a shot when a get a chance.
#6
-
Posted 18 October 2010 - 03:41 AM

OK I am still confused. I feel like I am jumping in the deep end without first learning how to swim.
If I wanted to get copied part of a Word document's HTML into a message box what code do I need? Do I need more then one .ahk file or can they link if so how (you can tell that I am completely new at this). All I have got so far is an empty message box and a message box containing unusable gibberish.
Thanks a lot.
If I wanted to get copied part of a Word document's HTML into a message box what code do I need? Do I need more then one .ahk file or can they link if so how (you can tell that I am completely new at this). All I have got so far is an empty message box and a message box containing unusable gibberish.
Thanks a lot.
#7
-
Posted 20 October 2010 - 12:55 AM

Post whatever you have tried.. Ask-for-help topic cannot continue without actual code.
#8
-
Posted 20 October 2010 - 12:58 AM

All I have so far is the Set and Get of the ClipboardData function and the included message boxes that was in a earlier post
The first two message boxes are blank and the 3rd has gibberish when I copy a word document or just blank when copying from a text document.
[color=#909BAB][ Moderator!: Edited out ][/color]
The first two message boxes are blank and the 3rd has gibberish when I copy a word document or just blank when copying from a text document.
#9
-
Posted 20 October 2010 - 01:48 AM

3rd has gibberish
When the msgbox is active, you can do a ctrl+c to copy the msgbox contents to the clipboard.
Post the 'gibberish' here.
For example: When I copy the last two lines of your previous post, this is what I get:
--------------------------- Gui0.ahk --------------------------- Version:0.9 StartHTML:0000000170 EndHTML:0000001080 StartFragment:0000000208 EndFragment:0000001042 SourceURL:http://www.autohotkey.com/forum/viewtopic.php?t=63672 <html> <body> <!--StartFragment--> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; ">[color=blue]The first two message boxes are blank and the 3rd has gibberish when I copy a word document or just blank when copying from a text document.[/color]</span></span> <!--EndFragment--> </body> </html> --------------------------- OK ---------------------------
#10
-
Posted 20 October 2010 - 02:00 AM

What I get when I copy the same 2 lines it is:
--------------------------- Test.ahk --------------------------- 敖獲潩㩮⸰ഹ匊慴瑲呈䱍〺〰〰〰㜱സ䔊摮呈䱍〺〰〰㤰ല匊慴瑲牆条敭瑮〺〰〰〰ㄲശ䔊摮牆条敭瑮〺〰〰㔰ഴ匊畯捲啥䱒栺瑴㩰⼯睷畡潴潨歴祥挮浯是牯浵瘯敩瑷灯捩瀮灨瀿㌽㈹㈳⌱㤳㌲ㄲ格浴㹬戼摯㹹ℼⴭ瑓牡䙴慲浧湥㸭猼慰汣獡㵳䄢灰敬猭祴敬猭慰≮猠祴敬∽潢摲牥挭汯慬獰㩥猠灥牡瑡㭥挠汯牯›杲⡢ⰰ〠⤰※潦瑮昭浡汩㩹✠楔敭敎⁷潒慭❮※潦瑮猭祴敬›潮浲污※潦瑮瘭牡慩瑮›潮浲污※潦瑮眭楥桧㩴渠牯慭㭬氠瑥整灳捡湩㩧渠牯慭㭬氠湩ⵥ敨杩瑨›潮浲污※牯桰湡㩳㈠※整瑸愭楬湧›畡潴※整瑸椭摮湥㩴〠硰※整瑸琭慲獮潦浲›潮敮※桷瑩ⵥ灳捡㩥渠牯慭㭬眠摩睯㩳㈠※潷摲猭慰楣杮›瀰㭸ⴠ敷止瑩戭牯敤潨楲潺瑮污猭慰楣杮›瀰㭸ⴠ敷止瑩戭牯敤敶瑲捩污猭慰楣杮›瀰㭸ⴠ敷止瑩琭硥敤潣慲楴湯湩攭晦捥㩴渠湯㭥ⴠ敷止瑩琭硥楳敺愭橤獵㩴愠瑵㭯ⴠ敷止瑩琭硥瑳潲敫眭摩桴›瀰㭸映湯楳敺›敭楤浵※㸢猼慰汣獡㵳䄢灰敬猭祴敬猭慰≮猠祴敬∽潦瑮昭浡汩㩹嘠牥慤慮牁慩ⱬ䠠汥敶楴慣慳獮猭牥晩※潦瑮猭穩㩥ㄠ瀲㭸氠湩ⵥ敨杩瑨›㠱硰※㸢戼㹲桔楦獲⁴睴敭獳条潢數牡汢湡湡桴爳慨楧扢牥獩桷湥䤠挠灯⁹潷摲搠捯浵湥⁴牯樠獵⁴汢湡桷湥挠灯楹杮映潲整瑸搠捯浵湥⼼灳湡㰾猯慰㹮ℼⴭ湅䙤慲浧湥㸭⼼潢祤ാ㰊栯浴㹬 --------------------------- OK ---------------------------
#11
-
Posted 20 October 2010 - 02:56 AM

Which version of AutoHotkey are you using?
Edit:
Okay! You are using Unicode...
I can rewrite it if you can allow me one day.
Edit:
Okay! You are using Unicode...
I can rewrite it if you can allow me one day.
#12
-
Posted 20 October 2010 - 03:01 AM

Which version of AutoHotkey are you using?
Version v1.0.48.05.L61 I just downloaded it not long ago
Edit:
Okay! You are using Unicode...
I can rewrite it if you can allow me one day.
I would love that. Thank You so much

#13
-
Posted 20 October 2010 - 03:27 AM

ClipboardGet_HTML( byref Data ) { ; www.autohotkey.com/forum/viewtopic.php?p=392624#392624 If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt ) If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0 If DllCall( "OpenClipboard", UInt,0 ) <> 0 If hData := DllCall( "GetClipboardData", UInt,CBID, UInt ) DataL := DllCall( "GlobalSize", UInt,hData, UInt ) , pData := DllCall( "GlobalLock", UInt,hData, UInt ) , VarSetCapacity( data, dataL * ( A_IsUnicode ? 2 : 1 ) ), StrGet := "StrGet" , A_IsUnicode ? Data := %StrGet%( pData, dataL, 0 ) : DllCall( "lstrcpyn", Str,Data, UInt,pData, UInt,DataL ) , DllCall( "GlobalUnlock", UInt,hData ) DllCall( "CloseClipboard" ) Return dataL ? dataL : 0 } If ClipboardGet_HTML( Data ) MsgBox, % Data Else SoundBeep
#14
-
Posted 21 October 2010 - 01:19 AM
