Jump to content

Recommended Posts

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?:)


Edited by legend
Link to post
Share on other sites
  • 11 months later...

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
$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]


Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...