legend Posted May 13, 2019 Posted May 13, 2019 (edited) I'm trying to convert a ahk script to autoit, but without luck, #include <WinAPI.au3> Local $module = _WinAPI_LoadLibrary("xd2txlib.dll") ConsoleWrite($module & @LF) Local $module = DllCall("Kernel32.dll", "Ptr", "LoadLibrary", "Str", "xd2txlib.dll") ConsoleWrite($module[0] & @LF) MsgBox(0, '_xdoc2txt() Result:', _xdoc2txt(@ScriptDir & "\test.txt")) Func _xdoc2txt($sFileName) Local $sfileText = '' Local $fileLength = DllCall("xd2txlib.dll", "int", 'ExtractText', "int", $sFileName, 'BOOL', True, 'int', $sfileText) MsgBox(0, '@error', @error) MsgBox(0, '', VarGetType($fileLength)) MsgBox(0, '', $sfileText) Return $sfileText EndFunc ;==>_xdoc2txt Here's the working ahk script: myDoc := "test.txt" ExtractText( content, myDoc ) MsgBox % content ExtractText( ByRef OutputVar, Filename) { static hModule := DllCall( "LoadLibrary", "Str", "xd2txlib.dll", "Ptr") fileLength := DllCall( "xd2txlib\ExtractText", "Str", Filename, "Int", False, "Int*", fileText) OutputVar := StrGet( fileText, fileLength / 2 ) } here's the ahk script : https://www.autohotkey.com/boards/viewtopic.php?t=253 I have uploaded the dll, maybe someone can help?:) xd2txlib.dll Edited May 15, 2019 by legend
FrancescoDiMuro Posted May 14, 2019 Posted May 14, 2019 9 hours ago, legend said: DllCall("xd2txlib.dll", "int", 'ExtractText', "inst", $sFileName, 'BOOL', True, 'inst', $sfileText) What kind of type is "inst"? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
legend Posted May 15, 2019 Author Posted May 15, 2019 (edited) On 5/14/2019 at 7:25 AM, FrancescoDiMuro said: What kind of type is "inst"? should have been int* any suggestions for getting it to work? =) Edited May 15, 2019 by legend
Fenzik Posted April 24, 2020 Posted April 24, 2020 Just for them, who want to have success at the end of the thread.. Here is my working example. ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ExtractText ; Description ...: Extracts text from advanced documment formats (Doc, Docx, ODT, XLS, ...) ; Syntax ........: _ExtractText($sFilename[, $bProperties = False[, $hDll = 0]]) ; Parameters ....: $sFilename - a string value. ; $bProperties - [optional] a boolean value. Default is False. If True, documment properties will be returned instead of the text. ; $hDll - [optional] a handle value. Default is 0. Optional handle to previously opened xd2txlib.dll. By default the xd2txlib.dll (Expected in @scriptdir) will be opened and closed during the function call. ; Return value .: String, containing the text or documment properties or empty string and Error as follows: ;1 - The file does not exists. ;2 - Error during opening xd2txlib.dll. ;3 - No text returned. ; Author ........: Fenzik ; Modified ......: ; Remarks .......: Project site - http://ebstudio.info/home/xdoc2txt.html ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _ExtractText($sFilename, $bProperties = False, $hDll = 0) If Not FileExists($sFilename) Then Return SetError(1, "", "") Local $bLoaded = False If $hDll = 0 Then $hDll = DllOpen(@scriptdir&"\xd2txlib.dll") If $hDll = -1 Then Return SetError(2, "", "") $bLoaded = True Endif $aResult = DllCall($hDll, "int:cdecl", "ExtractText", "WSTR", $sFilename, "BOOL", $bProperties, "WSTR*", "") If $aResult[0] = 0 Then Return SetError(3, "", "") If $bLoaded = True Then DllClose($hDll) Return $aResult[3] EndFunc
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