phoenix73 Posted November 22, 2005 Share Posted November 22, 2005 Hi! I'm a newbie in AutoIt Forum :">. I have the following question: I needed a RTF dll that allows me to insert a BMP image into an RTF file and I found the free "KCRtfCreator.dll" (http://www.kalpatarucomputers.com/kcrtfcreator.htm), but I am not able to load its procedures in AutoIt, while in VB6 it runs successfully. Please, tell me where I'm wrong. IMHO the problems are that this dll perhaps cannot run with AutoIt and I can't pass the boolean type of the parameters in the dllcall.Example code in VB6:Private Sub Form_Load()Dim objKCRTFWriter As New KCRTFWriterWith objKCRTFWriter .FontName = "Trebuchet MS" .Bold = True .FontSize = .FontSize * 1.1 .TextAlignment = CenterAlign .StartParaSelection .InsertText "This is a test.", True .EndParaSelection .InsertBMPFromFile "D:\MyWork\export.bmp", True .SaveInFile "D:\MyWork\test.rtf"End WithEndEnd SubExample code in AutoIt v3 (beta):$dll = DllOpen("KCRtfCreator.dll")If $dll = -1 Then MsgBox(0, "Error", "Unable to open dll.") ExitEndI$BTMfile = "D:\MyWork\export.bmp"$result1 = DllCall($dll, "none", "KCRTFWriter.StartParaSelection", "none","")check(@error, 1)$result2 = DllCall($dll, "none", "KCRTFWriter.InsertText", "str", "This is a test.", "none", True)check(@error, 2)$result3 = DllCall($dll, "none", "KCRTFWriter.EndParaSelection", "none","")check(@error, 3)$result4 = DllCall($dll, "none", "KCRTFWriter.InsertBMPFromFile", "str", $BTMfile, "none", True)check(@error, 4)$result5 = DllCall($dll, "none", "KCRTFWriter.SaveInFile", "str", "D:\MyWork\test.rtf")check(@error, 5)DllClose($dll)Func check($err, $n_proc)Select Case $err = 0 $msg = "Procedure " & $n_proc & " runs successfully." MsgBox(0, "Success", $msg) Case $err = 1 $msg = "Unable to call procedure " & $n_proc MsgBox(0, "Error", $msg) Exit Case $err = 2 $msg = "Unknown return type from procedure " & $n_proc MsgBox(0, "Error", $msg) ExitEndSelectEndFuncBest regards.Pho Link to comment Share on other sites More sharing options...
ptrex Posted November 22, 2005 Share Posted November 22, 2005 @phoenix73 This is more or less how you should do it. You don' t need to use DLL OPEN. expandcollapse popup; ; RTF Example ; PTREX 09/11/05 ; #include <GUIConstants.au3> #NoTrayIcon ;Vars Dim $oMyError Dim $File = "C:\Temp\test.rtf" ;Declare objects $oRTF = ObjCreate("objKCRTFWriter"); Default to Office XP If IsObj($oRTF) Then with $oRTF .FontName = "Trebuchet MS" .Bold = True .FontSize = 10 .TextAlignment = "CenterAlign" .StartParaSelection .InsertText = "This is a test." .EndParaSelection ;.InsertBMPFromFile "D:\MyWork\export.bmp", True .SaveInFile = $File EndWith Else MsgBox(0,"Reply","Not an Object",4) EndIf ;Main Gui GuiCreate("RTF Object", 802, 590,(@DesktopWidth-802)/2, (@DesktopHeight-590)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUI_ActiveX = GUICtrlCreateObj ($oRTF, 10, 10 , 780 , 550) GUICtrlSetStyle ( $GUI_ActiveX, $WS_VISIBLE ) GUICtrlSetResizing ($GUI_ActiveX,$GUI_DOCKAUTO) ; Auto Resize Object GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Exit ;This is Sven P's custom error handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc I have not tested ot yet. Because I have not downloaded the DLL. Maybe if you can link the DLL to this Thread we can all start testing. Enjoy !! Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
phoenix73 Posted November 22, 2005 Author Share Posted November 22, 2005 @ptrex Thanks for your reply! It was useful to discover that in AutoIt 3 beta exist new interesting functions. Although, I'm not be able to run the script yet. $oRTF = ObjCreate("KCRTFWriter") gives me only the result on msgbox "Not An Object". Why? I'm sure that KCRTFWriter is an object. The user manual of the DLL tells this... Maybe if you can link the DLL to this Thread we can all start testing.Look at my 1st post Furtherware, being the DLL of third parts, I can't post it here, but only write its link etc. Thanks a lot for your advices. Regards Pho Link to comment Share on other sites More sharing options...
phoenix73 Posted November 23, 2005 Author Share Posted November 23, 2005 @ptrex I solved the problem (thanks to your advices) in this way: $hPlug = PluginOpen("KCRtfCreator.dll") ;Declare objects $oRTF = ObjCreate("KCRtfCreator.KCRTFWriter.1") If IsObj($oRTF) Then with $oRTF .FontName = "Trebuchet MS" .Bold = True .FontSize = .FontSize * 1.1 .TextAlignment = 3 .StartParaSelection .InsertText ("This is a test.", True) .EndParaSelection .InsertBMPFromFile ($BMPfile, True) .SaveInFile ($File) EndWith Else MsgBox(0,"Reply","Not an Object",4) EndIf PluginClose($hPlug) "KCRtfCreator" makes possible to make RTF report into our applications, inserting BMP images, tables, etc. It is free to use and then it can bypass the well-done "RTF plugin" by Lazycat. Have fun!! Pho Link to comment Share on other sites More sharing options...
phoenix73 Posted November 23, 2005 Author Share Posted November 23, 2005 Oops , I have forgotten to say that the method "TextAlignment" is an enum property. Its values can be: 1 --> LeftAlignment 2 --> RightAlignment 3 --> CenterAlignment 4 --> Justified Bye Pho Link to comment Share on other sites More sharing options...
ptrex Posted November 23, 2005 Share Posted November 23, 2005 (edited) @phoenix73 Glad to be of assistance. But you can do somothing in return. Please upload the DLL in this Thread (Attache it in the post) So that other people don' t have to go to the site and register themselves and download and .... When the DLL in atached in a ZIP format, you probably well get more respons. Thanks Edited November 23, 2005 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
phoenix73 Posted November 23, 2005 Author Share Posted November 23, 2005 @ptrexSorry , the DLL in object is not my property and so I can't attach to the post. According to me, it's a very small price for us "to go to the site and register themselves and download and ...." use the DLL for free. Or is not? ByePho Link to comment Share on other sites More sharing options...
ptrex Posted November 23, 2005 Share Posted November 23, 2005 @phoenix73 If it's free to use, it is free to distribute it, isn't it ? If not I am not interested. If you want people to use you application, you will have to accomodate them. If not there will be very few people interested, I guess. Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
phoenix73 Posted November 23, 2005 Author Share Posted November 23, 2005 @phoenix73If it's free to use, it is free to distribute it, isn't it ? If not I am not interested.If you want people to use you application, you will have to accomodate them. If not there will be very few people interested, I guess. @ptrexHere's my example script... :"> Finally you have convinced me... Have funPho Link to comment Share on other sites More sharing options...
phoenix73 Posted November 23, 2005 Author Share Posted November 23, 2005 @ptrex Here's my example script... :"> Finally you have convinced me... Have fun Photest_DLL.zip Link to comment Share on other sites More sharing options...
ptrex Posted November 23, 2005 Share Posted November 23, 2005 Thanks for the contribution. I ran the script and it runs like a charm !!A small cosmetic correction.I changed the path to a more universal approach.Dim $RTFFile = @ScriptDir&"\test.rtf"Dim $BMPFile = @ScriptDir&"\autoit9.bmp"Keep on bringing good tools for AutoIT !! Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
pinkfoyd Posted January 18, 2006 Share Posted January 18, 2006 (edited) no need to register to download juste fill form with some caracter and the donwload start ps : where is this file ? #include "_ShellExecute.au3" D:\Downloads\test DLL\KCRtfCreator Example.au3(38,23) : ERROR: _ShellExecute(): undefined function. Edited January 18, 2006 by pinkfoyd Link to comment Share on other sites More sharing options...
phoenix73 Posted January 21, 2006 Author Share Posted January 21, 2006 ps : where is this file ?#include "_ShellExecute.au3"D:\Downloads\test DLL\KCRtfCreator Example.au3(38,23) : ERROR: _ShellExecute(): undefined function.You have to use the beta version of AutoIt. ByePho Link to comment Share on other sites More sharing options...
Sokko Posted January 21, 2006 Share Posted January 21, 2006 Thanks for providing this nice DLL, Phoenix! It looks to be much better than the method I was using before, but unfortunately I keep getting the "Not an Object" error (the ObjCreate is failing). Any idea why this would happen? Link to comment Share on other sites More sharing options...
phoenix73 Posted January 23, 2006 Author Share Posted January 23, 2006 Thanks for providing this nice DLL, Phoenix! It looks to be much better than the method I was using before, but unfortunately I keep getting the "Not an Object" error (the ObjCreate is failing). Any idea why this would happen?Don't mention it! It is a pleasure to give something of useful to all the AutoIt users.My idea is that perhaps the dll is not registered on your pc. If not, you have to copy the dll in windows/system32 directory and then register it with regsv32.RegardsPho Link to comment Share on other sites More sharing options...
Sokko Posted January 23, 2006 Share Posted January 23, 2006 (edited) Okay, now that works a lot better than the method described here, which always fails to create the object no matter how many times I register the required files.Now I've gotten it to successfully save the RTF file with text and images, but I can't figure out how to create or configure a GUI control. I am going on Ptrex's example in post #2 (code below), which doesn't throw any obvious errors but doesn't seem to create the control either. Has anyone gotten it working?EDIT: On closer inspection, it appears that this DLL is meant to be solely focused on outputting RTF files, rather than creating RTF GUI controls. Looks like I'll have to puzzle out the above-mentioned method after all (and if anyone could reply to my post there with a possible explanation, that would be great). Edited January 23, 2006 by Sokko 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