
NewCommer
Members-
Posts
17 -
Joined
-
Last visited
Profile Information
-
WWW
https://autoit-udf.forumvi.com/f1-forum
-
Interests
Learn programming AutoIt
Recent Profile Visitors
309 profile views
NewCommer's Achievements
-
Thanks for great app ! Question: If the AutoIt code contains #Include .a3x, the program will report an error and cannot output the exe. You can fix it.
-
dandz reacted to a post in a topic: Websockets and AutoIt
-
mLipok reacted to a post in a topic: Websockets and AutoIt
-
My websocket UDF: Only AutoIt code (combine Js from IE core): 😃 #RequireAdmin MsgBox(0x1000, 'Begin', 'Example1') example1() MsgBox(0x1000, 'Begin', 'Example2') example2() MsgBox(0x1000, 'Begin', 'Example3') example3() Func example1() Local $oWS = Websocket_Connect('wss://api.bitfinex.com/ws') Local $recv = Websocket_Send($oWS) For $index = 0 To $recv.length - 1 ConsoleWrite(' - Index ' & $index & ': ' & $recv.index($index) & @CRLF & @CRLF) Next Websocket_Close($oWS, 1000, '', 20000) EndFunc Func example2() Local $oWS = Websocket_Connect('wss://api.bitfinex.com/ws') Local $recv = Websocket_Send($oWS) $oJson = $recv.index(0, True) ;<= True = turn on Json parse MsgBox(0x1000, '$oJson.serverId', $oJson.serverId) Websocket_Close($oWS, 1000, '', 20000) EndFunc Func example3() Local $oWS = Websocket_Connect('wss://api.bitfinex.com/ws') Local $recv = Websocket_Send($oWS, '{"event":"subscribe","channel":"ticker","pair":"BTCUSD"}') Local $Timer = TimerInit() Do Sleep(1000) For $index = 0 To $recv.length - 1 ConsoleWrite(' - Index ' & $index & ': ' & $recv.index($index) & @CRLF & @CRLF) Next ConsoleWrite('-------------------------------------------------' & @CRLF) Until TimerDiff($Timer) > 30000 Websocket_Close($oWS, 1000, '', 20000) EndFunc Func Websocket_Connect($Ws_URL, $protocol = '', $binaryType = False, $timeout = 20000) _IE_Emulation(True) If @error Then Exit MsgBox(0x40000, 'Fatal Error', 'You must install Internet Explorer 11') Local Static $oEvent = ObjEvent('AutoIt.Error', '') Local $oWS = ObjCreate("HTMLFILE") $Ws_URL = '"' & $Ws_URL & '"' If $protocol Then $Ws_URL &= ', [' & StringRegExpReplace(StringRegExpReplace($protocol, '(?i)Sec-WebSocket-Protocol:\s+', '', 1), '(\w+)', '"${1}"') & ']' If $binaryType = Default Then $binaryType = False With $oWS.parentwindow .execScript( _ 'Array.prototype.item = function(i,parseJson) {if(typeof parseJson==''undefined''){return this[i]}else{return JSON.parse(this[i])}};' & _ ;Ma thuật giúp autoit thương tác JS Array 'Array.prototype.index = Array.prototype.item;' & _ 'var recv_data=[], event_close = [], event_error ;' & _ 'let socket = new WebSocket(' & $Ws_URL & ');' & _ 'socket.binaryType = "' & ($binaryType ? 'arraybuffer' : 'blob') & '";' & _ 'socket.onopen = function(event) {};' & _ 'socket.onmessage = function(event) {recv_data.push(event.data)};' & _ 'socket.onclose = function(event) {event_close = event};' & _ 'socket.onerror = function(error) {event_error= error.message};') If @error Then Return SetError(1, ConsoleWrite(@CRLF & '! [Websocket_Connect] Your IE don''t support websocket. Please update to IE11' & @CRLF & @CRLF), 0) Local $ti = TimerInit() Do Sleep(25) If TimerDiff($ti) > $timeout Then Return SetError(2, ConsoleWrite(@CRLF & '! [Websocket_Connect] Connect timeout' & @CRLF & @CRLF)) Until .eval('socket.readyState') = 1 EndWith ConsoleWrite(@CRLF & '> [Websocket_Connect] Connection established' & @CRLF & @CRLF) Return $oWS EndFunc Func Websocket_Send(ByRef $oWS, $Data = '', $timeout = 60000) If $Data Then $oWS.parentwindow.eval('socket').send($Data) Local $recv_data = $oWS.parentwindow.eval('recv_data') Local $ti = TimerInit() Do Sleep(25) If TimerDiff($ti) > $timeout Then Return SetError(1, ConsoleWrite('! [Websocket_Send] Receive timeout' & @CRLF & @CRLF)) Until $recv_data.length > 0 Return $recv_data EndFunc Func Websocket_ResetRecvData(ByRef $oWS) $oWS.parentwindow.eval('recv_data.splice(0, recv_data.length);') EndFunc Func Websocket_Close(ByRef $oWS, $Code = 1000, $Reason = '', $wait_ms = 0) With $oWS.parentwindow.eval('socket') .close() If .readyState >= 2 Then ConsoleWrite('> [Websocket_Close] The connection is in the process of closing...') If IsKeyword($wait_ms) Then $wait_ms = 0 If $wait_ms > 0 Then If $wait_ms < 10000 Then $wait_ms = 10000 Local $ti = TimerInit() Do Sleep(25) If TimerDiff($ti) > $wait_ms Then ExitLoop Until .readyState = 3 If .readyState = 3 Then Local $event_close = $oWS.parentwindow.eval('event_close') ConsoleWrite('The connection is closed with Code=' & $event_close.code & ($event_close.reason ? ' and Reason=' & $event_close.reason : '')) EndIf EndIf $oWS = Null ConsoleWrite(@CRLF & @CRLF) EndWith EndFunc Func _IE_Emulation($vTurnOn = True) ;By Huân Hoàng ;https://blogs.msdn.microsoft.com/patricka/2015/01/12/controlling-webbrowser-control-compatibility/ Local Static $isOn = False If $vTurnOn = True And $isOn = True Then Return Local Static $_Reg_BROWSER_EMULATION = '\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION' Local Static $_Reg_HKCU_BROWSER_EMULATION = 'HKCU\SOFTWARE' & $_Reg_BROWSER_EMULATION Local Static $_Reg_HKLM_BROWSER_EMULATION = 'HKLM\SOFTWARE' & $_Reg_BROWSER_EMULATION Local Static $_Reg_HKLMx64_BROWSER_EMULATION = 'HKLM\SOFTWARE\WOW6432Node' & $_Reg_BROWSER_EMULATION Local $_IE_Mode, $_AutoItExe = StringRegExp(@AutoItExe, '(?i)\\([^\\]+.exe)$', 1)[0] Local $_IE_Version = StringRegExp(FileGetVersion(@ProgramFilesDir & "\Internet Explorer\iexplore.exe"), '^\d+', 1) If @error Then $isOn = False Return SetError(1, ConsoleWrite('! [_IE_Emulation]: Cannot get IE Version' & @CRLF & @CRLF), False) EndIf $_IE_Version = Number($_IE_Version[0]) Switch $_IE_Version Case 10, 11 $_IE_Mode = $_IE_Version * 1000 + 1 Case Else Return SetError(2, ConsoleWrite('! [_IE_Emulation]: You must install Internet Explorer 10 and Internet Explorer 11' & @CRLF & @CRLF), False) EndSwitch If $vTurnOn Then If RegRead($_Reg_HKCU_BROWSER_EMULATION, $_AutoItExe) <> $_IE_Mode Then RegWrite($_Reg_HKCU_BROWSER_EMULATION, $_AutoItExe, 'REG_DWORD', $_IE_Mode) If RegRead($_Reg_HKLM_BROWSER_EMULATION, $_AutoItExe) <> $_IE_Mode Then RegWrite($_Reg_HKLM_BROWSER_EMULATION, $_AutoItExe, 'REG_DWORD', $_IE_Mode) If @AutoItX64 And RegRead($_Reg_HKLMx64_BROWSER_EMULATION, $_AutoItExe) <> $_IE_Mode Then RegWrite($_Reg_HKLMx64_BROWSER_EMULATION, $_AutoItExe, 'REG_DWORD', $_IE_Mode) $isOn = True Else RegDelete($_Reg_HKCU_BROWSER_EMULATION, $_AutoItExe) RegDelete($_Reg_HKLM_BROWSER_EMULATION, $_AutoItExe) If @AutoItX64 Then RegDelete($_Reg_HKLMx64_BROWSER_EMULATION, $_AutoItExe) $isOn = False EndIf Return True EndFunc
-
Hello everyone, Today I would like to introduce ImageRE.au3 UDF, this is a UDF about ImageSearch that I just finished writing. Sincere thanks to @Danyfirex for helping me in completing this UDF. This UDF is written based on the Image Recognition Library (ImageRecognition.dll), homepage: https://www.3delite.hu/Object Pascal Developer Resources/ImageRecognitionLibrary.html Image Recognition Library (IRL) is a component for use in Win32 and Win64 (2K/XP/Vista/7/8/10) software with a purpose to provide image recognition functionality, that is compare two pictures if they are the same or similar or find a smaller picture in a bigger picture with difference tolerance. License: IRL in shareware and commercial software? You can use this component in your free programs with a freeware license. If like it and use it for shareware or commercial software (or make money with it in any way) you have to buy a shareware or commercial license. Commercial license also allows the usage of the component inside a commercial company. Features: - Loading a picture from local disk - Loading a picture from HBitmap (by _ScreenCapture_Capture, _ScreenCapture_CaptureHwnd, IR_WinCapture...) - Loading a picture from memory - Exact, relative ARGB and AHSL with alpha channel support - ColorTolerance, PixelTolerance support - Pre-process images with 6 different resamplers - Multi-threaded processing - Multiple match support - OpenCL accelerated search - Rotate search support - Stretch search support - A fully multi-threaded loading queue functionality for batch loading of pictures - A fully multi-threaded search queue functionality for batch processing with support of parallel CPU-OpenCL processing a the same time - Full unicode support - Platforms: Win32 and Win64 About ImageRE UDF: Includes 8 main functions that I have summarized from IRL, ensuring all the features that IRL brings. Some example images: Download ImageRE.au3 UDF + Examples + IRL (Size 7Mb): https://1drv.ms/u/s!AhiIbjk1VKtOfEwStW1Sp0WGR3Q I'm not very good at English. So the UDF notes and examples are mostly translated using Google Translate. So there will be explanations that are very confusing or obscure. I hope you understand. 😔
-
Hello friends, I'm writing a code about DllCall a websocket.dll, its documentation looks like this: And I write to AutoIt like this: Local $pParams = 0 Local $hWsOnWillConnect = DllCallbackRegister(OnWillConnectCallback, 'ptr', 'ptr;ptr;str') Local $hWsOnConnected = DllCallbackRegister(OnConnectedCallback, 'bool', 'ptr;ptr') Local $hWsOnReceive = DllCallbackRegister(OnReceiveCallback, 'ptr', 'ptr;ptr;int;ptr;int;bool') Local $hWsOnSend = DllCallbackRegister(OnSendCallback, 'ptr', 'ptr;ptr;int;ptr;int;bool') Local $hWsOnError = DllCallbackRegister(OnErrorCallback, 'ptr', 'ptr;ptr') Local $tCallbackFuncs = DllStructCreate('ptr onWillConnect; ptr onConnected; ptr onReceive; ptr onSend; ptr onError') $tCallbackFuncs.onWillConnect = DllCallbackGetPtr($hWsOnWillConnect) $tCallbackFuncs.onConnected = DllCallbackGetPtr($hWsOnConnected) $tCallbackFuncs.onReceive = DllCallbackGetPtr($hWsOnReceive) $tCallbackFuncs.onSend = DllCallbackGetPtr($hWsOnSend) $tCallbackFuncs.onError = DllCallbackGetPtr($hWsOnError) Local $ret = DllCall('ws.dll', 'ptr', 'WebsocketOpen', 'ptr', DllStructGetPtr($tCallbackFuncs), 'ptr', $pParams) Func OnWillConnectCallback($pParams, $WsChannel, $sURL) #forceref $pParams, $WsChannel, $sURL ConsoleWrite(1 & @CRLF) EndFunc Func OnConnectedCallback($pParams, $WsChannel) #forceref $pParams, $WsChannel ConsoleWrite(2 & @CRLF) EndFunc Func OnReceiveCallback($pParams, $WsChannel, $opCode, $pBuffer, $LenghtBuffer, $IsContinue) #forceref $pParams, $WsChannel, $opCode, $pBuffer, $LenghtBuffer, $IsContinue ConsoleWrite(3 & @CRLF) EndFunc Func OnSendCallback($pParams, $WsChannel, $opCode, $pBuffer, $LenghtBuffer, $IsContinue) #forceref $pParams, $WsChannel, $opCode, $pBuffer, $LenghtBuffer, $IsContinue ConsoleWrite(4 & @CRLF) EndFunc Func OnErrorCallback($pParams, $WsChannel) #forceref $pParams, $WsChannel ConsoleWrite(5 & @CRLF) EndFunc Can I ask if what I wrote above is correct or not? Because I ran script and it only printed to console number 1 (means only ran the OnWillConnectCallback function) Thank you for reading my question. (Sorry my english is not very good)
-
NewCommer reacted to a post in a topic: A problem about DllStruct
-
NewCommer reacted to a post in a topic: A problem about DllStruct
-
Thank @TheXman Instead of declaring Local, I used Enum to declare as your advice and fixed the problem.
-
NewCommer reacted to a post in a topic: A problem about DllStruct
-
Another test:
-
Hello everyone, I don't know how to describe this problem, it's generally like the picture below: $n = 1 $t = DllStructCreate('int Test[2]') $t.Test(1) = 123 MsgBox(0, 0, _ $t.Test(1) & @CRLF & _ $t.Test($n) & @CRLF & _ $t.Test(Number($n))) Why "$t.Test($n)" value is 0 Thank you.
-
Sam2022 reacted to a post in a topic: Get URL Final Download File Name
-
NewCommer reacted to a post in a topic: Chromium Embedded Framework for AutoIt3
-
NewCommer reacted to a post in a topic: I have problem using DllCall to call ImageRecognition.dll
-
Exit reacted to a post in a topic: [solved] _FTP_Connect() has a delay of around 20 seconds. Why? --> it was TCP/IP V6
-
Get URL Final Download File Name
NewCommer replied to Sam2022's topic in AutoIt General Help and Support
You can use @trancexx excellent UDF WinHttp.au3 to receive and send http requests. Main Steps: Disable Redirects -- Send request -- Query Location Header #include "WinHttp.au3" Local $URL = "https://www.internetdownloadmanager.com/getlatestversion.html" Local $aURL = _WinHttpCrackUrl($URL) Local $hOpen = _WinHttpOpen() Local $hConnect = _WinHttpConnect($hOpen, $aURL[2]) Local $hRequest = _WinHttpOpenRequest($hConnect, 'HEAD', $aURL[6], Default, Default, Default) _WinHttpSetOption($hRequest, $WINHTTP_OPTION_DISABLE_FEATURE, $WINHTTP_DISABLE_REDIRECTS) _WinHttpSendRequest($hRequest) _WinHttpReceiveResponse($hRequest) Local $sLocation = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_LOCATION) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) MsgBox(0, "Location", $sLocation) -
Exit reacted to a post in a topic: [solved] _FTP_Connect() has a delay of around 20 seconds. Why? --> it was TCP/IP V6
-
Hello, The answer is probably because of ipv6. [stackoverflow] "I found out that turning off IPV6 protocol in network adapter settings on windows resolved the issue. So it really could be server side compatibility with IPV6. After 20 sec fallback to IPV4 and any next request running good. Just try turning off the IPV6."
-
NewCommer reacted to a post in a topic: I have problem using DllCall to call ImageRecognition.dll
-
Hello everyone, I found a very nice library: Image Recognition Library (https://www.3delite.hu/Object%20Pascal%20Developer%20Resources/download.html#irl) Features: And I am writing code to call this library. The simplest example of how to use this library consists of 3 steps: 1/ ImageRecognition_CreateObject 2/ ImageRecognition_Compare 3/ ImageRecognition_FreeObject Step 1 and step 3 I have done, but in step 2, when running the program, the program encounters an error and crashes. I have tried many ways but still can't fix it. Now I ask everyone to help me fix this error. Here is the code I did: #AutoIt3Wrapper_UseX64 = no #include <Array.au3> #include <WinAPISys.au3> #include <WinAPIDiag.au3> Global $__gh_DLL_IRL = -1 Enum _ $IR_OK, _ $IR_ERROR_UNKNOWN, _ $IR_ERROR_NOT_ENOUGH_MEMORY, _ $IR_ERROR_LOADING, _ $IR_ERROR_OBJECT, _ $IR_ERROR_DIMENSIONS, _ $IR_ERROR_NOT_AVAILABLE, _ $IR_ERROR_OCL_NOT_AVAILABLE, _ $IR_ERROR_OCL_NOT_INITIALIZED, _ $IR_ERROR_OCL_NO_SEARCH_IN_SET, _ $IR_ERROR_OCL_NO_SEARCH_FOR_SET, _ $IR_ERROR_NO_SEARCH_QUEUE_SET, _ $IR_ERROR_OCL_SET_SEARCH_IN, _ $IR_ERROR_OCL_SET_SEARCH_FOR, _ $IR_ERROR_NO_LOAD_QUEUE_SET #Status types Enum $IR_STATUS_PROGRESS #Compare type modes Enum _ $IR_COMPARE_TYPE_EXACT, _ ;Perform an exact search with an allowed pixel difference count. This requires that the search for bitmap is pixel identical with the search in bitmap, although you can set a "DifferenceTolerance" value to allow a concrete pixel count to differ. Exact mode is the fastest of the available modes. $IR_COMPARE_TYPE_RELATIVE_ARGB, _ ;Perform a search with an allowed pixel difference in Alpha-Red-Green-Blue color space. This mode is usefull when searching a similar picture in another picture. Setting a "DifferenceTolerance" value will allow a concrete pixel count to differ completly. This mode is slower than exact mode but faster than AHSL mode. $IR_COMPARE_TYPE_RELATIVE_AHSL, _ ;Perform a search with an allowed pixel difference in Alpha-Hue-Saturation-Lightness color space. AHSL component values range from 0 to 1. This mode is usefull when searching a similar picture in another picture but AHSL mode is required. Setting a "DifferenceTolerance" value will allow a concrete pixel count to differ completly. $IR_COMPARE_TYPE_RELATIVE_ARGB_ALPHA, _ ;Same as ARGB but the search for bitmap's pixels transparency value (alpha chanel) is considered when searching. Usefull when searching for a non-rectangular image, for example to find a logo put on a picture with transparency. Recommended that the search for bitmap is a PNG image with transparency. Slower then ARGB mode. $IR_COMPARE_TYPE_RELATIVE_AHSL_ALPHA ;Same as AHSL but the search for bitmap's pixels transparency value (alpha chanel) is considered when searching. Usefull when searching for a non-rectangular image, for example to find a logo put on a picture with transparency but AHSL mode is required. Recommended that the search for bitmap is a PNG image with transparency. This is the slowest of the available modes. #Queue modes Enum _ $IR_SEARCH_MODE_CPU, _ $IR_SEARCH_MODE_OPENCL, _ $IR_SEARCH_MODE_ANY #Queue threads Enum _ $IR_THREAD_PRIORITY_IDLE, _ $IR_THREAD_PRIORITY_LOWEST, _ $IR_THREAD_PRIORITY_LOWER, _ $IR_THREAD_PRIORITY_NORMAL, _ $IR_THREAD_PRIORITY_HIGHER, _ $IR_THREAD_PRIORITY_HIGHEST, _ $IR_THREAD_PRIORITY_TIMECRITICAL #Pre-process types Enum _ $IR_PROCESS_TYPE_NONE, _ $IR_PROCESS_TYPE_RESAMPLE #Pre-process resample modes Enum _ $IR_RESAMPLER_BOX, _ ; 0 // Box, pulse, Fourier window, 1st order (constant) b-spline $IR_RESAMPLER_BICUBIC, _ ; 1 // Mitchell & Netravali's two-param cubic filter $IR_RESAMPLER_BILINEAR, _ ;2 // Bilinear filter $IR_RESAMPLER_BSPLINE, _ ; 3 // 4th order (cubic) b-spline $IR_RESAMPLER_CATMULLROM, _ ; 4 // Catmull-Rom spline, Overhauser spline $IR_RESAMPLER_LANCZOS3 ; 5 // Lanczos3 filter #type LongBool Global Const $sIRDimensions = _ 'long Width;' & _ 'long Height' Global Const $sGUID = _ 'byte GUID[16]' Global Const $sIRObject = _ 'long Status;' & _ 'ptr lpszFileName;' & _ 'ptr pImageObject;' & _ 'struct ID;' & $sGUID & ';endstruct;' & _ 'struct OriginalDimensions;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'struct ProcessedDimensions;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'ptr User' Global Const $sIRCreateObjectParameters = _ 'long ProcessType;' & _ 'struct Dimensions;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'long Resampler' Global Const $sIRProcessParameters = _ 'long CompareType;' & _ 'byte ARGBATolerance;' & _ 'byte ARGBRTolerance;' & _ 'byte ARGBGTolerance;' & _ 'byte ARGBBTolerance;' & _ 'double AHSLATolerance;' & _ 'double AHSLHTolerance;' & _ 'double AHSLSTolerance;' & _ 'double AHSLLTolerance;' & _ 'long DifferenceTolerance;' & _ 'long StretchCompare;' & _ ;//* Stretch compare is experimental and very slow! 'struct MinimalStretchSize;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'struct MaximalStretchSize;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'long StretchResampler;' & _ 'long MultipleMatches;' & _ 'long MultiThreadedProcessing;' & _ 'long MultiThreadCount;' & _ ;//* 0 means all available CPU cores 'ptr StatusCallback;' & _ ; TIRStatusCallback *StatusCallback; 'long RotateSearch;' & _ 'float RotateSearchStartDegrees;' & _ 'float RotateSearchEndDegrees;' & _ 'float RotateSearchStepDegrees;' & _ 'long SearchSorroundingPixels' Global Const $sIRPoint = _ 'dword X;' & _ 'dword Y' Global Const $sIRResultMatches = _ 'struct Position;' & $sIRPoint & ';endstruct;' & _ ;TPoint 'struct Dimensions;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'float Angle;' & _ 'long Difference;' & _ 'float MatchPercentage' Global Const $sIRResult = _ 'long Success;' & _ 'long MatchCount;' & _ 'ptr pMatches' ;OpenCL accelerated search right now is supported with IR_COMPARE_TYPE_EXACT and IR_COMPARE_TYPE_RELATIVE_ARGB_ALPHA. ;Rotate search is supported with only IR_COMPARE_TYPE_RELATIVE_ARGB_ALPHA. #Region 3 Steps ImageRecognition_StartUp() Local $TIRObject_SearchIn = ImageRecognition_CreateObject(@ScriptDir & '\SearchIn.bmp') ;_WinAPI_DisplayStruct($TIRObject_SearchIn, $sIRObject) Local $TIRObject_SearchFor = ImageRecognition_CreateObject(@ScriptDir & '\SearchFor.bmp') ;_WinAPI_DisplayStruct($TIRObject_SearchFor, $sIRObject) #Region ImageRecognition_Compare #typedef void (CALLBACK TIRStatusCallback)(double Progress, int StatusType, void *User); Local $sIRStatusCallback = 'double;long;ptr*' Local $hIRStatusCallback = DllCallbackRegister('IRStatusCallback', 'none', $sIRStatusCallback) Volatile Func IRStatusCallback($Progress, $StatusType, $User) EndFunc Local $TIRProcessParameters = DllStructCreate($sIRProcessParameters) $TIRProcessParameters.CompareType = $IR_COMPARE_TYPE_EXACT $TIRProcessParameters.MultipleMatches = True $TolerancePercent = 1 ; 0 - 99 $TIRProcessParameters.DifferenceTolerance = Int($TIRObject_SearchFor.Width * $TIRObject_SearchFor.Height * ($TolerancePercent / 100)) $TIRProcessParameters.MultiThreadedProcessing = 0 ;$TIRProcessParameters.StatusCallback = DllCallbackGetPtr($hIRStatusCallback) ;_WinAPI_DisplayStruct($TIRProcessParameters, $sIRProcessParameters) Local $TIRResultMatches = DllStructCreate($sIRResultMatches) ;_WinAPI_DisplayStruct($TIRResultMatches, $sIRResultMatches) Local $TIRResult = DllStructCreate($sIRResult) $TIRResult.pMatches = DllStructGetPtr($TIRResultMatches) ;_WinAPI_DisplayStruct($TIRResult, $sIRResult) #typedef int(IRLIBCALL *t_ImageRecognition_Compare)(TIRObject IRObjectSearchIn, TIRObject IRObjectSearchFor, TIRProcessParameters Parameters, TIRResult *CompareResult, void *User); Local $User = 0 $ret = DllCall($__gh_DLL_IRL, 'long', 'ImageRecognition_Compare', 'struct', $TIRObject_SearchIn, 'struct', $TIRObject_SearchFor, 'struct', $TIRProcessParameters, 'struct*', $TIRResult, 'ptr', $User) _ArrayDisplay($ret) #EndRegion ImageRecognition_FreeObject($TIRObject_SearchFor) ImageRecognition_FreeObject($TIRObject_SearchIn) #EndRegion Func ImageRecognition_StartUp($sDllPath = 'ImageRecognition.dll') If Not FileExists($sDllPath) Then Exit MsgBox(16, 'Fatal Error', 'Not found ' & $sDllPath) $__gh_DLL_IRL = DllOpen($sDllPath) If @error Or $__gh_DLL_IRL = -1 Then Exit MsgBox(16, 'Fatal Error', 'Could not open ' & $sDllPath) OnAutoItExitRegister(ImageRecognition_Shutdown) EndFunc Func ImageRecognition_Shutdown() DllClose($__gh_DLL_IRL) EndFunc Func ImageRecognition_CreateObject($FilePath_or_Binary_or_hBitmap, $ProcessType = Default, $Resampler = Default, $Dimensions_Width = Default, $Dimensions_Height = Default) #Set Parameters Local $TIRCreateObjectParameters = DllStructCreate($sIRCreateObjectParameters) ;Pre-process the images: It can be usefull to resize the images when loading for faster processing and also usefull if you want to compare two images that differ in dimensions. When acquireing the picture object specify the "ProcessType" parameter of the "TIRCreateObjectParameters" structure to "IR_PROCESS_TYPE_RESAMPLE". And specify a resampler ("Resampler" variable). Resampling the images is performed by FreeImage.dll. If $ProcessType = Default Then $ProcessType = $IR_PROCESS_TYPE_NONE If $Resampler = Default Then $Resampler = $IR_RESAMPLER_BOX $TIRCreateObjectParameters.ProcessType = $ProcessType $TIRCreateObjectParameters.Resampler = $Resampler $TIRCreateObjectParameters.Width = $Dimensions_Width $TIRCreateObjectParameters.Height = $Dimensions_Height ;_WinAPI_DisplayStruct($TIRCreateObjectParameters, $sIRCreateObjectParameters) #Tạo Struct nhận Object Local $TIRObject = DllStructCreate($sIRObject) ;Local $tUser = DllStructCreate('byte[100]') ;$TIRObject.User = DllStructGetPtr($tUser) #Tạo Object If IsBinary($FilePath_or_Binary_or_hBitmap) Then Local $lImage = BinaryLen($FilePath_or_Binary_or_hBitmap) Local $tImage = DllStructCreate('byte[' & $lImage & ']') DllStructSetData($tImage, 1, $FilePath_or_Binary_or_hBitmap) ;typedef int(IRLIBCALL *t_ImageRecognition_CreateObjectFromMemory)(void *Address, QWORD DataSize, TIRObject *IRObject, TIRCreateObjectParameters Parameters); Local $ret = DllCall($__gh_DLL_IRL, 'long', 'ImageRecognition_CreateObjectFromMemory', 'ptr', DllStructGetPtr($tImage), 'uint64', $lImage, 'struct*', $TIRObject, 'struct', $TIRCreateObjectParameters) ElseIf IsPtr($FilePath_or_Binary_or_hBitmap) Then ;typedef int(IRLIBCALL *t_ImageRecognition_CreateObjectFromBitmapHandle)(HBITMAP BitmapHandle, TIRObject *IRObject, TIRCreateObjectParameters Parameters); Local $ret = DllCall($__gh_DLL_IRL, 'long', 'ImageRecognition_CreateObjectFromBitmapHandle', 'handle', $FilePath_or_Binary_or_hBitmap, 'struct*', $TIRObject, 'struct', $TIRCreateObjectParameters) Else ;typedef int(IRLIBCALL *t_ImageRecognition_CreateObject)(LPWSTR FileName, TIRObject *IRObject, TIRCreateObjectParameters Parameters); Local $ret = DllCall($__gh_DLL_IRL, 'long', 'ImageRecognition_CreateObject', 'wstr', $FilePath_or_Binary_or_hBitmap, 'struct*', $TIRObject, 'struct', $TIRCreateObjectParameters) EndIf Local $err = @error #Clear Params _WinAPI_ZeroMemory($TIRCreateObjectParameters, DllStructGetSize($TIRCreateObjectParameters)) #Trả kết quả If $err Or $ret[0] <> $IR_OK Then Return SetError(1) If Not @Compiled Then ConsoleWrite(_WinAPI_GetString($TIRObject.lpszFileName) & ' / ImageObj=' & $TIRObject.pImageObject & ' / W=' & $TIRObject.Width & ' / H=' & $TIRObject.Height & @CRLF) EndIf Return $TIRObject EndFunc Func ImageRecognition_FreeObject(ByRef $TIRObject) If Not IsDllStruct($TIRObject) Then Return SetError(1) ;typedef int(IRLIBCALL *t_ImageRecognition_FreeObject)(TIRObject *IRObject); Local $ret = DllCall($__gh_DLL_IRL, 'long', 'ImageRecognition_FreeObject', 'struct*', $TIRObject) Local $err = @error _WinAPI_ZeroMemory($TIRObject, DllStructGetSize($TIRObject)) If Not @Compiled Then ConsoleWrite('Free: ' & _WinAPI_GetString($TIRObject.lpszFileName) & ' / ImageObj=' & $TIRObject.pImageObject & ' / W=' & $TIRObject.Width & ' / H=' & $TIRObject.Height & @CRLF) EndIf If $err Or $ret[0] <> $IR_OK Then Return SetError(2) EndFunc I would like to thank everyone.😘 - Exe tutorials with source code of the Image Recognition Library: https://www.3delite.hu/Object%20Pascal%20Developer%20Resources/download.html#irl - The attachment (my work) includes: my au3 script, dll, image Test.zip