xd2txlib.dll Using the Library Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

xd2txlib.dll Using the Library

07 Mar 2023, 12:36

I have used converters but without success. Dll File is in the same directory as the script.

viewtopic.php?t=23494#p110511

Code: Select all

ExtractText(content, "test.docx")
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 )
}
User avatar
boiler
Posts: 17170
Joined: 21 Dec 2014, 02:44

Re: xd2txlib.dll Using the Library

07 Mar 2023, 13:59

To be clear to others looking to help since you did not state it explicitly, are you looking for help in converting working v1 code to v2 code?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: xd2txlib.dll Using the Library  Topic is solved

07 Mar 2023, 17:02

newest version seems to support unicode already

Code: Select all

#Requires AutoHotkey v2.0.2

#DllLoad xd2txlib.dll
#DllLoad OleAut32.dll

filePath := 'E:\asdfga.doc'
pBSTR_FilePath := DllCall('oleaut32\SysAllocString', 'WStr', filePath, 'Ptr')

; typedef int (*FUNCTYPE)(BSTR lpFilePath, bool bProp,  BSTR*lpFileText);
if !nFileLength := DllCall('xd2txlib\ExtractText', 'Ptr', pBSTR_FilePath, 'Int', false, 'Ptr*', &pBSTR_FileText := 0)
    throw Error('something went wrong')

MsgBox StrGet(pBSTR_FileText)

DllCall('oleaut32\SysFreeString', 'Ptr', pBSTR_FilePath)
DllCall('oleaut32\SysFreeString', 'Ptr', pBSTR_FileText)
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: xd2txlib.dll Using the Library

07 Mar 2023, 22:24

boiler wrote:
07 Mar 2023, 13:59
To be clear to others looking to help since you did not state it explicitly, are you looking for help in converting working v1 code to v2 code?
Yes. I am sorry. I got an error trying to open a topic and forgot when I tried again. I wanted an example that I can use in the v2 version. I don't know much about using DLLs.
Thanks.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: xd2txlib.dll Using the Library

07 Mar 2023, 22:30

swagfag wrote:
07 Mar 2023, 17:02
newest version seems to support unicode already

Code: Select all

#Requires AutoHotkey v2.0.2

#DllLoad xd2txlib.dll
#DllLoad OleAut32.dll

filePath := 'E:\asdfga.doc'
pBSTR_FilePath := DllCall('oleaut32\SysAllocString', 'WStr', filePath, 'Ptr')

; typedef int (*FUNCTYPE)(BSTR lpFilePath, bool bProp,  BSTR*lpFileText);
if !nFileLength := DllCall('xd2txlib\ExtractText', 'Ptr', pBSTR_FilePath, 'Int', false, 'Ptr*', &pBSTR_FileText := 0)
    throw Error('something went wrong')

MsgBox StrGet(pBSTR_FileText)

DllCall('oleaut32\SysFreeString', 'Ptr', pBSTR_FilePath)
DllCall('oleaut32\SysFreeString', 'Ptr', pBSTR_FileText)
I'm glad the AHK community is wonderfully helpful and kind in the V2 version as well. :)
Thank you very much.

I just want to ask what I'm curious about. Will the xd2txlib library now run faster in V2 than in V1? Because it supports Unicode?

And should I do anything for better performance when I want to open too many documents? Or is it enough for me to use the example you gave again and again as it is?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: xd2txlib.dll Using the Library

08 Mar 2023, 00:25

i cant say. benchmark it and see for urself
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: xd2txlib.dll Using the Library

08 Mar 2023, 02:36

swagfag wrote:
08 Mar 2023, 00:25
i cant say. benchmark it and see for urself
Certainly. Thank you.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Descolada, Draken, kczx3, Marium0505, robinson, william_ahk and 46 guests