Leaderboard
Popular Content
Showing content with the highest reputation on 07/19/2021 in all areas
-
Quickest way to add data to data (i.e. collect extracted text into a single collection)
JockoDundee and one other reacted to pseakins for a topic
<brag mode on> In 1992, under DOS 6.22, I wrote a Z80 interpreter so that I could interpret in-house software currently running on a multi-user Z80 operating system on imported hardware to run on an IBM compatible. (A lot of layers there. We imported a multi-user Z80 based system and wrote code for it. With the interpreter we could run the code on a PC.) As much as we hated M$ I was amazed at the efficiency of the OS and the way that it buffered disk writes, delaying them only until local buffers needed to be flushed and performing intensive disk IO entirely within RAM wherever possible. I found there was no need for me to perform any disk buffering in my interpreter because DOS was taking care of everything. It was marvelous. I also hooked the clock interrupt and used this for the partition switching that the emulated OS required. I was even more amazed later on when one of my colleagues reported that he had my interpreter running successfully under an early version of Windows, something which I thought impossible given that my assembly code was performing direct BIOS disk reads and writes and talking directly to the serial port ACIA hardware and timer. In the years that followed I have discovered that same basic functionality from DOS 6.22 has persisted through all the versions of Windoze which followed. I have probably mentioned the buffering in other posts. <brag mode off>2 points -
Security questions for AutoIT approval
TheDcoder reacted to JockoDundee for a topic
If only there was multi-threading1 point -
EasyCodeIt - cross-platform AutoIt implementation
TheDcoder reacted to seadoggie01 for a topic
Interestingly, I didn't realize until a few years ago that it wasn't Chame (like the first part of Chameleon). This hurt to read1 point -
Look at remarks of HotKeySet in help file, under "The following hotkeys cannot be set:" / "Other"1 point
-
Syntax error on HKEY_CLASSES_ROOT once compile - (Moved)
WilliamasKumeliukas reacted to Danp2 for a topic
Your quotation marks are off. I would suggest using single quotes for the last parameter, like this -- $RegCreate = RegWrite ("HKEY_CLASSES_ROOT\Applications\Tdp.exe\shell\edit\command", "", "REG_SZ", '"D:\Tdp.exe" "%1" -v') ;success P.S. See here for the correct method of posting code to the forum1 point -
I was busy finding a satisfiying way to do that. I ended up hidding all the complicated code in _cveFindTemplate With the new udf version below there is an example of how you can find matches of a template. For your own images, adjust parameters, usually threshold is enough, until you get a satisfying result. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include "emgucv-autoit-bindings\cve_extra.au3" _OpenCV_DLLOpen("libemgucv-windesktop-4.5.2.4673\libs\x64\cvextern.dll") Local $tDesktopScreenRect = _WinAPI_GetDesktopScreenRect() ConsoleWrite("$tDesktopScreenRect.left: " & $tDesktopScreenRect.left & @CRLF) ConsoleWrite("$tDesktopScreenRect.top: " & $tDesktopScreenRect.top & @CRLF) ConsoleWrite("$tDesktopScreenRect.right: " & $tDesktopScreenRect.right & @CRLF) ConsoleWrite("$tDesktopScreenRect.bottom: " & $tDesktopScreenRect.bottom & @CRLF) ConsoleWrite(@CRLF) Local $tBits = _cveGetDesktopScreenBits($tDesktopScreenRect) Local $matImg = _cveMatCreateWithData($tDesktopScreenRect.bottom - $tDesktopScreenRect.top, $tDesktopScreenRect.right - $tDesktopScreenRect.left, $CV_8UC4, $tBits, 0) Local $matTempl = _cveImreadAndCheck("mario_coin.png") Local $w = _cveMatGetWidth($matTempl) Local $h = _cveMatGetHeight($matTempl) ; we compute the histogram from the B G R channels ;Local $aChannels[3] = [0, 1, 2] Local $aChannels = _cveDefaultBGRChannels() ; Quantize each color to 32 levels ; The higher the value, the closer to the template the matched color is ; Local $aHistSize[3] = [32, 32, 32] Local $aHistSize = _cveDefaultBGRHistSize() ; Each color varies from 0 to 255 ; Local $aRanges[6] = [0, 256, 0, 256, 0, 256] Local $aRanges = _cveDefaultBGRRanges() ; The higher the value, the higher the match is exact Local $fThreshold = 0.8 ; Ignore the alpha channel when matching the template => $CV_COLOR_BGRA2BGR ; Only consider gray scale colors when matching the template => $CV_COLOR_BGRA2GRAY ; using cveCanny and/or gray scale can significantly reduce the matching time but also reduce the matching accuracy Local $hTimer = TimerInit() Local $aMatches = _cveFindTemplate($matImg, $matTempl, $fThreshold, $CV_COLOR_BGRA2GRAY) Local $fDiff = TimerDiff($hTimer) ConsoleWrite("Finding matches took " & $fDiff & "ms" & @CRLF) Local $iMatches = UBound($aMatches) ConsoleWrite("Number of matches: " & $iMatches & @CRLF) Local $tRedColor = _cvRGB(255, 0, 0) Local $tMatchRect = _cvRect(0, 0, $w, $h) For $i = 0 To $iMatches - 1 $tMatchRect.x = $aMatches[$i][0] $tMatchRect.y = $aMatches[$i][1] ; Draw a red rectangle around the matched position _cveRectangleMat($matImg, $tMatchRect, $tRedColor, 1, $CV_LINE_8, 0) Next _cveImshowMat("Source Image", $matImg) _cveWaitKey(0) $tMatchRect = 0 $tRedColor = 0 _cveMatRelease($matTempl) _cveMatRelease($matImg) $tBits = 0 _cveDestroyAllWindows() _Opencv_DLLClose() emgucv-autoit-bindings.zip1 point
-
Here my attempt (works for all examples) : #include <Array.au3> ;Const $DIG = [1,0,0], $IN = [10], $OUT = [2] ;Const $DIG = [1,0,0], $IN = [2], $OUT = [10] ;Const $DIG = [1,9,0,3,1,5], $IN = [2,10], $OUT = [10] ;Const $DIG = [1,9,0,3,1,5], $IN = [2,10], $OUT = [4,3,2] ;Const $DIG = [52,0,0,0,0], $IN = [100,7,24,60,60], $OUT = [10] Const $DIG = [0,2,10], $IN = [2,4,8,16], $OUT = [42] ;Const $DIG = [], $IN = [123,456], $OUT = [13] ;Const $DIG = [0, 0], $IN = [123,456], $OUT = [13] Local $Result[0] Local $res = 0, $tmp For $i = 1 To UBound($DIG) $tmp = $DIG[UBound($DIG) - $i] For $j = 1 to $i - 1 $tmp *= $IN[UBound($IN)-Mod($j-1, UBound($IN)) - 1] Next $res += $tmp Next ConsoleWrite($res & @CRLF) $i = 0 While $res > 0 ReDim $Result[$i+1] $tmp = $OUT[UBound($OUT)-Mod($i, UBound($OUT)) - 1] $Result[$i] = Mod($res, $tmp) $res = Floor($res/$tmp) $i += 1 WEnd _ArrayReverse($Result) _ArrayDisplay($Result)1 point
-
Enhanced the PowerPoint UDF to version 1.0. New functions will be added in the future! Comments are welcome!1 point
-
Using an Object as Element in a Const Array In this post, an object is used as an element in a constant array. Still, it's possible to change an object property. How is that possible? Object variables access the object itself through a reference (pointer). A simple object variable can be created with the Dictionary object. Dictionary ObjectExamples\Example0.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) Example() Func Example() Local $oDict1 = ObjCreate( "Scripting.Dictionary" ) ; Object reference counter = 1 Local $oDict2 = $oDict1 ; Object reference counter = 2 $oDict1.Item( "$vVar" ) = 123 $oDict1 = 0 ; Object reference counter = 1 ConsoleWrite( "$oDict2.Item( ""$vVar"" ) = " & $oDict2.Item( "$vVar" ) & @CRLF ) $oDict2 = 0 ; Object reference counter = 0 that deletes the object EndFunc #cs $oDict2.Item( "$vVar" ) = 123 #ce The variables $oDict1 and $oDict2 both refer to the same object. The Item property can be set with $oDict1 and read with $oDict2 and vice versa. Examples\Example1.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include "..\Includes\InspectVariable.au3" Example() Func Example() Local $oDict1 = ObjCreate( "Scripting.Dictionary" ), $oDict2 = $oDict1 ConsoleWrite( "$oDict1" & @CRLF ) ConsoleWrite( "Type = " & VarGetType( $oDict1 ) & @CRLF ) AccessVariables01( InspectVariableMtd, $oDict1 ) ConsoleWrite( @CRLF ) ConsoleWrite( "$oDict2" & @CRLF ) ConsoleWrite( "Type = " & VarGetType( $oDict2 ) & @CRLF ) AccessVariables01( InspectVariableMtd, $oDict2 ) ConsoleWrite( @CRLF ) ConsoleWrite( "Ptr( $oDict1 ) = " & Ptr( $oDict1 ) & @CRLF ) EndFunc #cs $oDict1 Type = Object ptr = 0x00000000005CB110 ($pVariant) vt = 0x0009 (VT_DISPATCH, pointer to object) data = 0x00000000005B02B0 $oDict2 Type = Object ptr = 0x00000000005CB150 ($pVariant) vt = 0x0009 (VT_DISPATCH, pointer to object) data = 0x00000000005B02B0 Ptr( $oDict1 ) = 0x00000000005B02B0 #ce The InspectVariable.au3 UDF from Accessing AutoIt Variables is used to examine $oDict1 and $oDict2. Today we know that AutoIt variables are internally stored in variant structures. For object variables, the variant type is VT_DISPATCH, and the data field contains a pointer (reference) to the object. Note that this pointer has the same value for both object variables. And that it's the same pointer as returned by Ptr( $oDict1 ). The Item property of the Dictionary object is also a variant that can store all AutoIt data types. DllStruct TypeExamples\Example2.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) Example() Func Example() Local $tagStruct = "struct;int var1;byte var2;uint var3;char var4[128];endstruct" Local $tStruct = DllStructCreate( $tagStruct ) DllStructSetData( $tStruct, "var1", -100 ) DllStructSetData( $tStruct, "var2", 255 ) DllStructSetData( $tStruct, "var3", 300 ) DllStructSetData( $tStruct, "var4", "Hello" ) Local $oDict1 = ObjCreate( "Scripting.Dictionary" ) Local $oDict2 = $oDict1 $oDict1.Item( "$tStruct" ) = $tStruct ConsoleWrite( "DllStructGetData( $oDict2.Item( ""$tStruct"" ), ""var3"" ) = " & DllStructGetData( $oDict2.Item( "$tStruct" ), "var3" ) & @CRLF ) EndFunc #cs DllStructGetData( $oDict2.Item( "$tStruct" ), "var3" ) = 300 #ce Array TypeAutoIt arrays are internally stored as safearrays of variants. Ie. the array itself is a safearray and the array elements are variant structures. Examples\Example3.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) Example() Func Example() Local $oDict1 = ObjCreate( "Scripting.Dictionary" ) Local $oDict2 = $oDict1 Local $aArray[5] = [ 0, 1, 222, 3, 4 ] $oDict1.Item( "$aArray" ) = $aArray ConsoleWrite( "$oDict2.Item( ""$aArray"" )[2] = " & $oDict2.Item( "$aArray" )[2] & @CRLF ) ; $oDict1.Item( "$aArray" )[3] = 333 ; Error: Statement cannot be just an expression Local $aMyArray = $oDict1.Item( "$aArray" ) $aMyArray[3] = 333 $oDict1.Item( "$aArray" ) = $aMyArray ConsoleWrite( "$oDict2.Item( ""$aArray"" )[3] = " & $oDict2.Item( "$aArray" )[3] & @CRLF ) EndFunc #cs $oDict2.Item( "$aArray" )[2] = 222 $oDict2.Item( "$aArray" )[3] = 333 #ce Const ArrayA consequence of an object variable having access to the object itself through a reference makes it possible to store an object variable in a constant array (or constant variable) and still be able to change an object property. Since a change of an object property doesn't change the array element (or variable) that refers to the object, the property change doesn't conflict with a constant array (or variable). Examples\Example4.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) Example() Func Example() Local $oDict = ObjCreate( "Scripting.Dictionary" ) $oDict.Item( "Int" ) = 1 $oDict.Item( "Flt" ) = 1.1 $oDict.Item( "Str" ) = "One" ;Local $aArray[1] = [ $oDict ] Local Const $aArray[1] = [ $oDict ] ; Local Const $oDict = 0 ConsoleWrite( "$aArray[0].Item( ""Int"" ) = " & $aArray[0].Item( "Int" ) & @CRLF ) ConsoleWrite( "$aArray[0].Item( ""Flt"" ) = " & $aArray[0].Item( "Flt" ) & @CRLF ) ConsoleWrite( "$aArray[0].Item( ""Str"" ) = " & $aArray[0].Item( "Str" ) & @CRLF & @CRLF ) #cs ; Direct modification of the $aArray values in this way doesn't work ; But it does work if you remove "Const" in the declaration of $aArray $aArray[0].Item( "Int" ) = 2 ; Error: $aArray previously declared as a 'Const' $aArray[0].Item( "Flt" ) = 2.2 ; Error: $aArray previously declared as a 'Const' $aArray[0].Item( "Str" ) = "Two" ; Error: $aArray previously declared as a 'Const' ConsoleWrite( "$aArray[0].Item( ""Int"" ) = " & $aArray[0].Item( "Int" ) & @CRLF ) ConsoleWrite( "$aArray[0].Item( ""Flt"" ) = " & $aArray[0].Item( "Flt" ) & @CRLF ) ConsoleWrite( "$aArray[0].Item( ""Str"" ) = " & $aArray[0].Item( "Str" ) & @CRLF & @CRLF ) #ce ;#cs ; Indirect modification of the $aArray values in this way does work Local $oMyDict = $aArray[0] $oMyDict.Item( "Int" ) = 2 $oMyDict.Item( "Flt" ) = 2.2 $oMyDict.Item( "Str" ) = "Two" $oMyDict = 0 ConsoleWrite( "$aArray[0].Item( ""Int"" ) = " & $aArray[0].Item( "Int" ) & @CRLF ) ConsoleWrite( "$aArray[0].Item( ""Flt"" ) = " & $aArray[0].Item( "Flt" ) & @CRLF ) ConsoleWrite( "$aArray[0].Item( ""Str"" ) = " & $aArray[0].Item( "Str" ) & @CRLF & @CRLF ) ;#ce EndFunc #cs $aArray[0].Item( "Int" ) = 1 $aArray[0].Item( "Flt" ) = 1.1 $aArray[0].Item( "Str" ) = One $aArray[0].Item( "Int" ) = 2 $aArray[0].Item( "Flt" ) = 2.2 $aArray[0].Item( "Str" ) = Two #ce This example is similar to the example in the link at top of post. 7z-fileThe 7z-file contains source code for UDFs and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. Misc.7z1 point
-
[Solved] Fast Real-Time File Read Write
pixelsearch reacted to Jos for a topic
I am fine with an well formulated opinion, not so much a response like that... hence my response without any nuance. There are some using many words and there are some (like me) that try to get away with messages as short as possible, but that response was uncalled for. * Now back on topic please! Jos1 point -
Execute(), as in: Global $oDictionary, $oMyError Global $aDictItems[3][2] = [["one","uno"], ["two","dos"], ["three","tres"]] ; Initialize a COM error handler $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Create dictionary object $oDictionary = ObjCreate("Scripting.Dictionary") ; Add key/item pairs For $n = 0 to UBound($aDictItems) - 1 ; Normal syntax: $oDictionary.ADD($aDictItems[$n][0], $aDictItems[$n][1]) $sMethod = "Add" Execute("$oDictionary." & $sMethod & "($aDictItems[$n][0], $aDictItems[$n][1])") Next ; Read items For $n = 0 to UBound($aDictItems) - 1 ; Normal syntax: $oDictionary.Item($aDictItems[$n][0]) $sMethod = "Item" $sItem = Execute("$oDictionary." & $sMethod & "($aDictItems[$n][0])") ConsoleWrite($aDictItems[$n][0] & " = " & $sItem & @LF) Next ; This is my custom defined error handler Func MyErrFunc() Local $err = $oMyError.number MsgBox(16, "Error", "COM Error: " & $err) SetError($err) ; to check for after this function returns EndFunc ;==>MyErrFunc Edit: Forgot COM error handler.1 point
-
EasyCodeIt - cross-platform AutoIt implementation
seadoggie01 reacted to TheSaint for a topic
Boy, has George got a lot to answer for. But then maybe he's just a comma medium ... comedian for short ... who have poetic lie sense I guess.0 points