Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/28/2022 in all areas

  1. just a hint on one possible way. You can use the functions present in an external file by running that script using /AutoIt3ExecuteScript and getting the return results by reading the StdOut stream. How?... you have to make calls to those functions like this: instead of using a normal call in the form of _func_1([$ params ...]) as for functions contained in the same script you have to use this other format instead: Run (@AutoItExe & "/AutoIt3ExecuteScript " & 'Filename.au3 Param1 Param2 ...', '', '', 8) From the external script, to be able to send results to the main script just use ConsoleWrite ($ Var) instead of Return $ Var As usual, a simple example script is worth more than too many words save the following two scripts in the same directory and run the MainScript.au3 p.s The main script can be compiled as well as the external script. Obviously if you compile the external script in an .exe or .a3x you must also change the command to call the external script accordingly. Check it out here: https://www.autoitscript.com/autoit3/docs/intro/running.htm I hope this helps MainScript.au3: #include <array.au3> ; Local $STDERR_MERGED = 8 Local $vReturn Local $sFilename = '.\ExternalFunc.au3' ; call func_1 $vReturn = CallExternal($sFilename, 1) MsgBox(0, 'Return', "Received: " & $vReturn) ; call func_2 $vReturn = CallExternal($sFilename, 2) _ArrayDisplay(StringSplit($vReturn, "|", $STR_NOCOUNT)) Func CallExternal($sFilename, $iParams) Local $vStdOut Local $hPID = Run(@AutoItExe & " /AutoIt3ExecuteScript " & $sFilename & ' ' & $iParams, '', '', $STDERR_MERGED) While ProcessExists($hPID) Sleep(250) $vStdOut &= StdoutRead($hPID) WEnd Return $vStdOut EndFunc ;==>CallExternal ExternalFunc.au3: ; #include <array.au3> Local $iParams = $CmdLine[0] If Not $iParams Then ConsoleWriteError("missing parameters error.") Exit EndIf Local $iParam1 = $CmdLine[1] Local $aWeekDays[] = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] Switch $iParam1 Case 1 _func_1() Case 2 _func_2() Case Else ConsoleWriteError("function number undefined error.") EndSwitch ; returns a random number Func _func_1() ; use ConsoleWrite instead of Return ConsoleWrite(Random(0, 100, 1)) EndFunc ;==>_func_1 ; returns a (pseudo) array Func _func_2() Local $sString ; ConsoleWrite(_ArrayToString($aWeekDays)) For $i = 0 To UBound($aWeekDays) - 1 $sString &= $aWeekDays[$i] & "|" Next ; use ConsoleWrite instead of Return ConsoleWrite(StringTrimRight($sString, 1)) EndFunc ;==>_func_2
    2 points
  2. Hello guys. I recently saw some posts that Windows 10 provides OCR API. So I decided to create a UDF. What's UWPOCR? UWPOCR UDF is a simple library to use Universal Windows Platform Optical character recognition API. Features. Get Text From Image File. Get Text From GDI+ Bitmap. Easy to use. Usage: #include "..\UWPOCR.au3" _Example() Func _Example() Local $sOCRTextResult = _UWPOCR_GetText(FileOpenDialog("Select Image", @ScriptDir & "\", "Images (*.jpg;*.bmp;*.png;*.tif;*.gif)")) MsgBox(0,"",$sOCRTextResult) EndFunc Get Words Rect(Example): More examples here. Check UWPOCR UDF on GitHub. Saludos
    1 point
  3. flaui and this uiawrappers all make use of the microsoft technology UIA automation and boils down to uiautomationcore.dll which is the unmanaged com version dll. Not sure where flaui defines uia2/uia3 but here is where MS has documented the foundation. https://docs.microsoft.com/en-us/windows/win32/winauto/entry-uiautocore-overview a usefull library where i based the uiawrappers udf on. This wrapper is around what flaui calls uia2 but as said I don't know that description from MS itself. UIA3 you refer to is the .net managed dll version but both give also access to iaccessible.iaccessible2 interface.
    1 point
  4. Maybe you can mimic algorithms used to detect sequences in DNA data. Google for that. For instance: https://pastel.archives-ouvertes.fr/tel-01762479/document
    1 point
  5. I was wandering about the FileGetTime. It now has UTC support but FileSetTime not ?!. So I tested and it does but there is no telling in the help file. So on type, "$FT_UTC (4) = UTC time instead of Local time" need to be added. Edit: No such thing. Was in a hurry this morning. Brain fart !.
    1 point
  6. Since you are working with JSON, you could also use UDF's designed specifically for that purpose, like the ones in JSON.au3, which can handle JSON escaping & unescaping for you: #include <Constants.au3> #include <Debug.au3> #include <MyIncludes\json\json.au3> ;<== Modify path as needed example() Func example() Const $JSON = '{"message":"Invalid license","errors":{"key":"\u0627\u06cc\u0646 ' & _ '\u0644\u0627\u06cc\u0633\u0646\u0633 \u062f\u0631 \u0633\u06cc\u0633' & _ '\u062a\u0645 \u0645\u0648\u062c\u0648\u062f \u0646\u06cc\u0633\u062a"}}' Local $oJson = Null ;Set up debug messages to go to notepad _DebugSetup("JSON Parsing Example", False, 5) ;Decode JSON into dictionary object $oJson = Json_Decode($JSON) If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "Json_Decode failed - @error = " & @error) ;Display examples of escaped and unescaped JSON unicode output _DebugOut("Raw JSON") _DebugOut(Json_Encode($oJson) & @CRLF) _DebugOut("Raw JSON with unescaped unicode") _DebugOut(Json_Encode($oJson, $JSON_UNESCAPED_UNICODE) & @CRLF) _DebugOut("Pretty-printed JSON") _DebugOut(Json_Encode($oJson, $JSON_PRETTY_PRINT) & @CRLF) _DebugOut("Pretty-printed JSON with unescaped unicode") _DebugOut(Json_Encode($oJson, $JSON_PRETTY_PRINT + $JSON_UNESCAPED_UNICODE) & @CRLF) _DebugOut("Parsed JSON values") _DebugOut(".message = " & Json_Get($oJson, ".message")) _DebugOut(".errors = " & Json_Encode(Json_Get($oJson, ".errors"), $JSON_UNESCAPED_UNICODE)) _DebugOut(".errors.key = " & Json_Get($oJson, ".errors.key")) EndFunc Output: Raw JSON {"message":"Invalid license","errors":{"key":"\u0627\u06cc\u0646 \u0644\u0627\u06cc\u0633\u0646\u0633 \u062f\u0631 \u0633\u06cc\u0633\u062a\u0645 \u0645\u0648\u062c\u0648\u062f \u0646\u06cc\u0633\u062a"}} Raw JSON with unescaped unicode {"message":"Invalid license","errors":{"key":"این لایسنس در سیستم موجود نیست"}} Pretty-printed JSON { "message": "Invalid license", "errors": { "key": "\u0627\u06cc\u0646 \u0644\u0627\u06cc\u0633\u0646\u0633 \u062f\u0631 \u0633\u06cc\u0633\u062a\u0645 \u0645\u0648\u062c\u0648\u062f \u0646\u06cc\u0633\u062a" } } Pretty-printed JSON with unescaped unicode { "message": "Invalid license", "errors": { "key": "این لایسنس در سیستم موجود نیست" } } Parsed JSON values .message = Invalid license .errors = {"key":"این لایسنس در سیستم موجود نیست"} .errors.key = این لایسنس در سیستم موجود نیست
    1 point
  7. There are various standards for such encoding. Here's a good sample based on https://r12a.github.io/app-conversion/index.html Local $s = 'این لایسنس در سیستم موجود نیست' ; AutoIt UCS2 string with characters > 0xFF (or not) Local $t ; conversion to encoded form Local $u ; $t converted back to AutoIt UCS2 string ; AutoIt UCS2 string to JSON/JS/Java/C C-style Unicode Local $t = Execute("'" & StringRegExpReplace($s, "([\x{0100}-\x{FFFF}])", "\\u' & Hex(AscW('$1'), 4) & '") & "'") MsgBox(0, "", $t) cw($t) ; JSON/JS/Java/C C-style Unicode to AutoIt UCS2 string Local $u = Execute("'" & StringRegExpReplace($t, "\\u([[:xdigit:]]{1,4})", "' & ChrW(0x$1) & '") & "'") MsgBox(0, "", $u) cw($u) cw('Round-trip conversion to JSON/JS/Java/C C-style string is ' & ($s == $u ? 'correct' : 'incorrect!')) cw() ; AutoIt UCS2 string to JSON/JS/Java/C ES6 or Rust/Ruby Unicode Local $t = Execute("'" & StringRegExpReplace($s, "([\x{0100}-\x{FFFF}])", "\\u\{' & Hex(AscW('$1'), 4) & '}") & "'") MsgBox(0, "", $t) cw($t) ; JSON/JS/Java/C ES6 or Rust/Ruby Unicode to AutoIt UCS2 string Local $u = Execute("'" & StringRegExpReplace($t, "\\u\{([[:xdigit:]]{1,4})\}", "' & ChrW(0x$1) & '") & "'") MsgBox(0, "", $u) cw($u) cw('Round-trip conversion to JSON/JS/Java/C ES6 or Rust/Ruby string is ' & ($s == $u ? 'correct' : 'incorrect!')) cw() ; AutoIt UCS2 to Hex NCRs Local $t = Execute("'" & StringRegExpReplace($s, "([\x{0100}-\x{FFFF}])", "&#x' & Hex(AscW('$1'), 4) & '") & "'") MsgBox(0, "", $t) cw($t) ; Hex NCRs to AutoIt UCS2 Local $u = Execute("'" & StringRegExpReplace($t, "&#x([[:xdigit:]]{1,4})", "' & ChrW(0x$1) & '") & "'") MsgBox(0, "", $u) cw($u) cw('Round-trip conversion to Hex NCRs string is ' & ($s == $u ? 'correct' : 'incorrect!')) cw() ; AutoIt UCS2 to Decimal NCRs Local $t = Execute("'" & StringRegExpReplace($s, "([\x{0100}-\x{FFFF}])", "&#x' & AscW('$1') & '") & "'") MsgBox(0, "", $t) cw($t) ; Decimal NCRs to AutoIt UCS2 Local $u = Execute("'" & StringRegExpReplace($t, "&#x(\d{1,5})", "' & ChrW($1) & '") & "'") MsgBox(0, "", $u) cw($u) cw('Round-trip conversion to Decimal NCRs string is ' & ($s == $u ? 'correct' : 'incorrect!')) cw() ; AutoIt UCS2 string to CSS Unicode Local $t = Execute("'" & StringRegExpReplace($s, "([\x{0100}-\x{FFFF}])", "\\' & Hex(AscW('$1'), 4) & ' ") & "'") MsgBox(0, "", $t) cw($t) ; CSS Unicode to AutoIt UCS2 string Local $u = Execute("'" & StringRegExpReplace($t, "\\([[:xdigit:]]{1,4}) ", "' & ChrW(0x$1) & '") & "'") MsgBox(0, "", $u) cw($u) cw('Round-trip conversion to CSS string is ' & ($s == $u ? 'correct' : 'incorrect!')) cw() ; AutoIt UCS2 string to Perl/UTR#18 Unicode Local $t = Execute("'" & StringRegExpReplace($s, "([\x{0100}-\x{FFFF}])", "\\x\{' & Hex(AscW('$1'), 4) & '\}") & "'") MsgBox(0, "", $t) cw($t) ; Perl/UTR#18 Unicode to AutoIt UCS2 string Local $u = Execute("'" & StringRegExpReplace($t, "\\x\{([[:xdigit:]]{1,4})\}", "' & ChrW(0x$1) & '") & "'") MsgBox(0, "", $u) cw($u) cw('Round-trip conversion to Perl/UTR#18 string is ' & ($s == $u ? 'correct' : 'incorrect!')) cw() ; Unicode-aware ConsoleWrite Func cw($v) ConsoleWrite(BinaryToString(StringToBinary($v & @LF, 4), 1)) EndFunc
    1 point
  8. Yes, _Pathsplit does what you need: "Splits a path into the drive, directory, file name and file extension parts" For the exact syntax please see the help file.
    1 point
×
×
  • Create New...