Leaderboard
Popular Content
Showing content with the highest reputation on 03/31/2023 in all areas
-
CHAT GPT is taking over ... so I asked it to help me code a call to itself from AutoIt. It did pretty well - but ultimately I had to turn to the docs to realize that it was calling its own deprecated endpoint that I needed to update (AI has limits I guess). Anywho, if anyone wants to play around with it here is a working example: #include <WinHttp.au3> #include <Json.au3> ; Set up WinHttp object $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHttp.Open("POST", "https://api.openai.com/v1/completions", false) $oHttp.SetRequestHeader("Content-Type", "application/json") $oHttp.SetRequestHeader("Authorization", "Bearer <YOUR API KEY HERE>"); you will need to get an API key and place it here ; Set up request data params can be seen here https://platform.openai.com/docs/api-reference/completions/create ; tokens dictate length $sData = '{"model": "text-davinci-003", "prompt": "what day is it?", "max_tokens": 10}' ; change the prompt to whatever you want ; Send request and get response $oHttp.Send($sData) ; Check if request was successful If $oHttp.Status <> 200 Then MsgBox(0, "Error", "WinHttp request failed with status code: " & $oHttp.Status) Exit EndIf $sResponse = $oHttp.ResponseText ; Parse response and display $aJson = _Json_Parse($sResponse) $sText = $aJson.choices[0].text MsgBox(0, "Response", $sText)1 point
-
PDF to TEXT conversion -- foxit reader automation
mistersquirrle reacted to Musashi for a topic
This is an interesting approach ! @rudi : You have already mentioned the command line tool pdftotext.exe. I therefore assume, that you know the other tools such as pdftopng.exe. In case not, then you can find it here : https://www.xpdfreader.com/download.html In particular the Xpdf command line tools -> Windows 32/64-bit (Win 7 and newer) : Download These command line tools work 'stand-alone' , which means that no installation is required . Excerpt from the terms of use of the "open source stand-alone executables" : If you want to use the stand-alone executables (pdftopng for example) with your application, you're free to do so. (To comply with the GPL, you'll need to distribute the Xpdf documentation along with the pdftopng executable - see the Xpdf README file for details.) ; Infos : ; -r 300 = 300 DPI (150 = 150 DPI etc) ; - q = quiet ; target : no need to set the extension .png ; For a multi-page PDF, one graphic is generated per page pdftopng.exe -r 300 -q "source.pdf" "target"1 point -
PDF to TEXT conversion -- foxit reader automation
Musashi reacted to mistersquirrle for a topic
Just a thought of something else that you can try, if you haven't already: What about converting the PDF to a simple image (png/bmp/jpg), then using a more specific OCR program to read the images? It gives you the flexibility of not looking for a PDF specific OCR program, and you can try something like or any other CLI OCR. An added benefit of converting to an image is that you can then also do some modifications to the image, to improve the potential clarity of the text if the PDF isn't computer generated (such as it was created from a scanned document).1 point -
Very often we need to measure execution speed, thus came the idea of FuncSpeedTest($sExecute) Func FuncSpeedTest($sExecute) Local $hTimer = TimerInit() Execute($sExecute) ConsoleWrite($sExecute & " processed in: " & Round(TimerDiff($hTimer) / 1000, 3) & " seconds " & @LF) EndFunc ;==>FuncSpeedTest Example1: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 FuncSpeedTest("_IfSingle()") FuncSpeedTest("_IfMulti()") ;---------------------------------------------------------------------------------------- Func _IfSingle() Local $iVariable = 1 For $i = 1 To 1000000 If $iVariable Then $iVariable = 1 Next EndFunc ;==>_IfSingle ;---------------------------------------------------------------------------------------- Func _IfMulti() Local $iVariable = 1 For $i = 1 To 1000000 If $iVariable Then $iVariable = 1 EndIf Next EndFunc ;==>_IfMulti ;---------------------------------------------------------------------------------------- Func FuncSpeedTest($sExecute) Local $hTimer = TimerInit() Execute($sExecute) ConsoleWrite($sExecute & " processed in: " & Round(TimerDiff($hTimer) / 1000, 3) & " seconds " & @LF) EndFunc ;==>FuncSpeedTest ;---------------------------------------------------------------------------------------- from: 133961-if-then-else-single-line Example2: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <WinAPISys.au3> For $i = 1 To 4 FuncSpeedTest("_test" & $i & "()") ConsoleWrite("" & @CRLF) Next ;---------------------------------------------------------------------------------------- Func _test1() For $i = 1 To 1000000 _WinAPI_GetTickCount64() Next ConsoleWrite(_WinAPI_GetTickCount64() & @CRLF) EndFunc ;==>_test1 ;---------------------------------------------------------------------------------------- Func _test2() For $i = 1 To 1000000 DllCall('kernel32.dll', 'uint64', 'GetTickCount64') Next ConsoleWrite(DllCall('kernel32.dll', 'uint64', 'GetTickCount64')[0] & @CRLF) EndFunc ;==>_test2 ;---------------------------------------------------------------------------------------- Func _test3() Local $dll = DllOpen("kernel32.dll") For $i = 1 To 1000000 DllCall($dll, 'uint64', 'GetTickCount64') Next ConsoleWrite(DllCall($dll, 'uint64', 'GetTickCount64')[0] & @CRLF) DllClose($dll) EndFunc ;==>_test3 ;---------------------------------------------------------------------------------------- Func _test4() Local $hInstance_Kernel32_dll = _WinAPI_GetModuleHandle("kernel32.dll") Local $hAddress_Kernel32_dll_GetTickCount64 = _WinAPI_GetProcAddress($hInstance_Kernel32_dll, "GetTickCount64") For $i = 1 To 1000000 DllCallAddress('uint64', $hAddress_Kernel32_dll_GetTickCount64) Next ConsoleWrite(DllCallAddress('uint64', $hAddress_Kernel32_dll_GetTickCount64)[0] & @CRLF) EndFunc ;==>_test4 ;---------------------------------------------------------------------------------------- Func FuncSpeedTest($sExecute) Local $hTimer = TimerInit() Execute($sExecute) ConsoleWrite($sExecute & " processed in: " & Round(TimerDiff($hTimer) / 1000, 3) & " seconds " & @LF) EndFunc ;==>FuncSpeedTest ;---------------------------------------------------------------------------------------- from: 209984-dllclose-is-still-a-good-idea1 point
-
Global $start TimerStart() While 1 If TimerDiff($start) >= 9000 Then $iMsgBoxAnswer = MsgBox(4, "time", "9 seconds have passed" & @CRLF & "Do you want 9 second more?") Select Case $iMsgBoxAnswer = 6 ;Yes TimerStart() Case $iMsgBoxAnswer = 7 ;No Exit EndSelect EndIf Sleep(50) WEnd Func TimerStart() $start = TimerInit() ConsoleWrite("- TimerStart" & @CRLF) EndFunc ;==>TimerStart1 point
-
DllClose() is still a good idea? - (Moved)
KaFu reacted to argumentum for a topic
.... I believe @Confuzzled gave the best answer Basically, you open it, you close it. Be the owner of your code. Note to self: learn to read without having to reply.1 point -
Rerun another assignment $MyTime = TimerIInit().1 point
-
Using DllCallAddress() is even faster, but as the team said, it's only worth to optimize when you've got a lot of calls, normally the bottlenecks are somewhere else. I analyzed how many calls are made in SMF and switched to DllCallAddress() for some calls of which literally million of calls where made in huge and complex searches. Overall gain I would say is max 5 to 10% in speed, now the hardware itself seems to be the bottleneck and slowest part in searching for files. #include <WinAPISys.au3> $iTimer = TimerInit() For $i = 1 To 1000000 _WinAPI_GetTickCount64() Next ConsoleWrite(_WinAPI_GetTickCount64() & @CRLF) ConsoleWrite(TimerDiff($iTimer) & @CRLF & @CRLF) $iTimer = TimerInit() For $i = 1 To 1000000 DllCall('kernel32.dll', 'uint64', 'GetTickCount64') Next ConsoleWrite(DllCall('kernel32.dll', 'uint64', 'GetTickCount64')[0] & @CRLF) ConsoleWrite(TimerDiff($iTimer) & @CRLF & @CRLF) $iTimer = TimerInit() $dll = DllOpen("kernel32.dll") For $i = 1 To 1000000 DllCall($dll, 'uint64', 'GetTickCount64') Next ConsoleWrite(DllCall($dll, 'uint64', 'GetTickCount64')[0] & @CRLF) DllClose($dll) ConsoleWrite(TimerDiff($iTimer) & @CRLF & @CRLF) $iTimer = TimerInit() Global $hInstance_Kernel32_dll = _WinAPI_GetModuleHandle("kernel32.dll") Global $hAddress_Kernel32_dll_GetTickCount64 = _WinAPI_GetProcAddress($hInstance_Kernel32_dll, "GetTickCount64") For $i = 1 To 1000000 DllCallAddress('uint64', $hAddress_Kernel32_dll_GetTickCount64) Next ConsoleWrite(DllCallAddress('uint64', $hAddress_Kernel32_dll_GetTickCount64)[0] & @CRLF) ConsoleWrite(TimerDiff($iTimer) & @CRLF & @CRLF)1 point
-
gcue, Look at Ceiling in the Help file: "Returns a number rounded up to the next integer" M231 point