Leaderboard
Popular Content
Showing content with the highest reputation on 07/16/2021 in all areas
-
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.7z3 points
-
Can you fix the HotKeySet and @HotKeyPressed
FrancescoDiMuro and one other reacted to ajag for a topic
I can not see any bug here... HotKeySet("&","CaptureAlert") works fine here on my german keyboard when pressing "SHIFT" and "6" at the same time HotKeySet("{}}","CaptureAlert") This is not a valid Key! What key do you want to be the HotKey here?2 points -
Can you fix the HotKeySet and @HotKeyPressed
JockoDundee reacted to jchd for a topic
Bunch of arrows!1 point -
@MoonscarletYou can solve this using the pageLoadStrategy setting, which is part of the Capabilities you pass to _WD_CreateSession. Searching the forum on the term "pageLoadStrategy" should yield multiple examples. P.S. As @Jos pointed out, this type of inquiry should be posted in the support thread over in the GH&S section (link in my sig) 😉1 point
-
Do you really think that our huge development team is just waiting to create a patch for you in the shortest possible time?</sarcasm> Back to real life: First you have to proof that it is a real bug Then you have to create a Trac ticket Then one of the developer has to accept the ticket as a bug Then one of the developer has to write a patch Then you have to wait for the release of the next beta version of AutoIt That's called professional software development. But I think this is nothing new for you, since you develop software yourself. So could you please start with step 1 ... BTW: We (developers, forum members ...) are just volunteers spending their rare spare time to develop and support AutoIt. So please be patient1 point
-
Advice for Getting Started with Android Development
Pumpkin_30 reacted to Earthshine for a topic
https://visualstudio.microsoft.com/xamarin/ i am telling you-- you CAN run VS and Xarmin on macos. so how bad do you want to do this? everything else isn't going to measure up to what you can do with this.1 point -
There is no function to search for an image. However there is _cveMatchTemplate that can be used for this purpose. For screen search, you can load the screen as a matrix, and from there use any opencv functions. Here is how to load a screen capture as a matrix #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WindowsConstants.au3> #include <WinAPI.au3> #include "emgucv-autoit-bindings\cve_extra.au3" 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 $iLeft = $tDesktopScreenRect.left Local $iTop = $tDesktopScreenRect.top Local $biWidth = $tDesktopScreenRect.right - $tDesktopScreenRect.left Local $biHeight = $tDesktopScreenRect.bottom - $tDesktopScreenRect.top Local $iChannels = 4 Local $hWnd = _WinAPI_GetDesktopWindow() Local $hDesktopDC = _WinAPI_GetDC($hWnd) Local $hMemoryDC = _WinAPI_CreateCompatibleDC($hDesktopDC) ;create compatible memory DC Local $tBIHDR = DllStructCreate($tagBITMAPINFO) $tBIHDR.biSize = DllStructGetSize($tBIHDR) $tBIHDR.biWidth = $biWidth $tBIHDR.biHeight = -$biHeight $tBIHDR.biPlanes = 1 $tBIHDR.biBitCount = $iChannels * 8 Local $aDIB = DllCall("gdi32.dll", "ptr", "CreateDIBSection", "hwnd", 0, "struct*", $tBIHDR, "uint", 0, "ptr*", 0, "ptr", 0, "dword", 0) _WinAPI_SelectObject($hMemoryDC, $aDIB[0]) Local $tBits = DllStructCreate('byte[' & $biWidth * $biHeight * $iChannels & ']', $aDIB[4]) _WinAPI_BitBlt($hMemoryDC, 0, 0, $biWidth, $biHeight, $hDesktopDC, $iLeft, $iTop, $SRCCOPY) _OpenCV_DLLOpen("libemgucv-windesktop-4.5.2.4673\libs\x64\cvextern.dll") Local $matImg = _cveMatCreateWithData($biHeight, $biWidth, $CV_8UC4, $tBits, 0) _cveImshowMat("Screen capture", $matImg) _cveWaitKey(0) _WinAPI_DeleteObject($aDIB[0]) $tBIHDR = 0 _WinAPI_DeleteDC($hMemoryDC) _WinAPI_ReleaseDC($hWnd, $hDesktopDC) _cveMatRelease($matImg) _cveDestroyWindow("Screen capture") _Opencv_DLLClose() Func _WinAPI_GetDesktopScreenRect() Local $iRight, $iBottom, $aRetrun Local $tRect = DllStructCreate($tagRECT) $tRect.Left = 0 $tRect.Top = 0 $tRect.Right = -1 $tRect.Bottom = -1 Local Const $tagDISPLAY_DEVICE = "dword Size;wchar Name[32];wchar String[128];dword Flags;wchar ID[128];wchar Key[128]" Local $tDisplayDevice = DllStructCreate($tagDISPLAY_DEVICE) $tDisplayDevice.Size = DllStructGetSize($tDisplayDevice) Local $tDisplaySettings = DllStructCreate($tagDEVMODE_DISPLAY) $tDisplaySettings.Size = DllStructGetSize($tDisplaySettings) Local $iDevNum = 0 While 1 ; _WinAPI_EnumDisplayDevices("", $iDevNum) $aRetrun = DllCall("user32.dll", "int", "EnumDisplayDevicesW", "ptr", 0, "dword", $iDevNum, "struct*", $tDisplayDevice, "dword", 1) If Not $aRetrun[0] Then ExitLoop $iDevNum += 1 If BitAND($tDisplayDevice.Flags, $DISPLAY_DEVICE_MIRRORING_DRIVER) Or Not BitAND($tDisplayDevice.Flags, $DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) Then ContinueLoop EndIf If BitAND($_cve_debug, 1) Then ConsoleWrite($tDisplayDevice.Name & @TAB & "Attached to desktop: " & (BitAND($tDisplayDevice.Flags, $DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) <> 0) & @CRLF) ConsoleWrite($tDisplayDevice.Name & @TAB & "Primary: " & (BitAND($tDisplayDevice.Flags, $DISPLAY_DEVICE_PRIMARY_DEVICE) <> 0) & @CRLF) ConsoleWrite($tDisplayDevice.Name & @TAB & "Mirroring driver: " & (BitAND($tDisplayDevice.Flags, $DISPLAY_DEVICE_MIRRORING_DRIVER) <> 0) & @CRLF) ConsoleWrite($tDisplayDevice.Name & @TAB & "VGA compatible: " & (BitAND($tDisplayDevice.Flags, $DISPLAY_DEVICE_VGA_COMPATIBLE) <> 0) & @CRLF) ConsoleWrite($tDisplayDevice.Name & @TAB & "Removable: " & (BitAND($tDisplayDevice.Flags, $DISPLAY_DEVICE_REMOVABLE) <> 0) & @CRLF) ConsoleWrite($tDisplayDevice.Name & @TAB & "More display modes: " & (BitAND($tDisplayDevice.Flags, $DISPLAY_DEVICE_MODESPRUNED) <> 0) & @CRLF) ConsoleWrite(@CRLF) Endif ; _WinAPI_EnumDisplaySettings($tDisplayDevice.Name, $ENUM_CURRENT_SETTINGS) Local $sDevice = $tDisplayDevice.Name Local $sTypeOfDevice = 'wstr' If Not StringStripWS($sDevice, $STR_STRIPLEADING + $STR_STRIPTRAILING) Then $sTypeOfDevice = 'ptr' $sDevice = 0 EndIf $aRetrun = DllCall("user32.dll", "bool", "EnumDisplaySettingsW", $sTypeOfDevice, $sDevice, "dword", $ENUM_CURRENT_SETTINGS, "struct*", $tDisplaySettings) If Not $aRetrun[0] Then ContinueLoop If $tRect.Left > $tDisplaySettings.X Then $tRect.Left = $tDisplaySettings.X If $tRect.Top > $tDisplaySettings.Y Then $tRect.Left = $tDisplaySettings.Y $iRight = $tDisplaySettings.X + $tDisplaySettings.PelsWidth If $tRect.Right < $iRight Then $tRect.Right = $iRight $iBottom = $tDisplaySettings.Y + $tDisplaySettings.PelsHeight If $tRect.Bottom < $iBottom Then $tRect.Bottom = $iBottom WEnd $tDisplaySettings = 0 $tDisplayDevice = 0 Return $tRect EndFunc ;==>_WinAPI_GetDesktopScreenRect1 point
-
Security questions for AutoIT approval
TheDcoder reacted to argumentum for a topic
lol, anyone that can not answer these questions by him/her self, should not be doing that job, as THAT is not the way to get those answers. There. A free lesson. ( Do click like -or HaHa- if you get to read this )1 point -
AutoIt v3.3.15.4 Beta
jaberwacky reacted to Jon for a file
1,713 downloads
AutoIt: - Changed: PCRE regular expression engine updated to 8.44. - Added: doc pages about ControlID/Handle and String/Encoding. - Added #2375: SetError(), SetExtended() doc precision. - Added #3780: WinSetTitle() on notepad.exe is reverted when the windows get focus starting Windows 19H1 !!! - Added #3222: Doc precision for statement with 2 FileInstall(). - Added: ConsoleWrite() preserves the @error and @extended. - Added: ConsoleWriteError() preserves the @error and @extended. - Added #2938: Add "GetCount" to ControlCommand() - Added #3539: FileGetTime() UTC. - Added #3808: ProgressOn()/ProgressSet() - size of the progress window - Fixed: Missing Opt("SetExitCode", 1) and AutoIt3 Exit codes in doc. - Fixed #3211: Doc precision for hwnd parameter in Pixel*() functions. - Fixed #3774: Doc precision about Null keyword comparison. - Fixed #3579: DllStructGetData() doc precision. - Fixed #3823: Language Reference - Variables typo. - Fixed #3021: bad obj calling. - Fixed #3106: StringIsFloat() doesn't accept a valid FP exponent. - Fixed #3135: StdioClose memory leak. - Fixed #3165: Call UBound Array[0] AutoIt Crash. - Fixed #3167: Com error handler not called. - Fixed #3179: Number() failure with lower case hex. - Fixed #3182: MouseMove() on multiple screens. - Fixed #3232: Issue when parsing scientific notation literals. - Fixed #3659: InetClose() always false. - Fixed #3682: GuiCtrlCreatePic() with h=0 and w=0. - Fixed #3701: Crash with array 2^24. - Fixed #3710: @OSVersion for Server 2019. - Fixed #3743: [LAST] and WinWaitClose(), WinExists(), WinGetHandle(), etc. - Fixed #3772: int64 = -9223372036854775808 not handled properly. - Fixed #3778: ToolTip() position. - Fixed #3789: FileRead() on big ANSI file (1Gb). - Fixed #3790: UCS2 compare empty string. - Fixed #3807: GUISetIcon() in taskbar. - Fixed #3809: WinGetTitle() on windows created with _WinAPI_CreateWindowEx(). - Fixed #3817: Double to Int64 conversion. AutoItX: - Fixed: run*() showflag default SW_SHOWNORMAL. Aut2Exe: - Fixed #2383: Aut2exe GUI dropped files. - Added #3684: Aut2exe title with version. Au3Check: - Fixed #3785: Crash if too many includes. Au3info: - Added #3938: DPI scaling Support. UDFs: - Changed: Updated used Excel constant enumerations in ExcelConstants.au3 to Excel 2016. - Added #3514: _GUICtrlTreeView_GetLastItem() (Thanks Crazzy). - Added #3611: _GUICtrlListView_SetBkHBITMAP() (Thanks Alofa). - Added #3695: _SQLite_Display2DResult() 2 additional parameters $sDelim_Col and $sDelim_Row. - Added #3675: WinNET.au3 $tagNETRESOURCE: Add constants. - Added #3740: _ChooseColor() support Custom colors (Thanks argumentum). - Added #3547: _FormatAutoItExitCode() and _FormatAutoItExitMethod(). - Added #3696: _ArrayFromString(). - Added #3771: ColorConstants.au3 now include all W3C extended colors. THIS IS A small SCRIPT BREAKING CHANGE - Added #3739: _Array2DCreate(). - Added #3550: _Date_Time_SystemTimeToDateTimeStr() support 2 new formats to return GMT or ISO8601 format. - Added: _WinAPI_CreateProcess() example. - Added #3804: _GUICtrlMenu_CreateMenu() example to demonstrate menuclick non blocking. - Added #3806: _GDIPlus_GraphicsDrawString() with AlphaColor font. - Added #3811: _SQLite_Startup() new parameter to allow return AutoIt Type variables by _SQLite_FetchData(). - Added: _GUICtrlListView_GetSelectedIndices() optimisation (Thanks pixelsearch). - Added: _WinAPI_GetProcessName() and _WinAPI_GetParentProcessName() doc example (Thanks argumentum). - Added #3813: _MemGlobalRealloc(). - Added #3816: _WinAPI_ReadDirectoryChanges() example with magic number. - Fixed #3819: _FileCountLines() can use file handle. - Added: SpeedUp display and sorting of ArrayDisplay() and _DebugArrayDisplay() (Thanks LarsJ). - Fixed #3647: _GDIPlus_ImageResize() ghost border. - Fixed #3650: _GDIPlus_ImageResize() off by one. - Fixed #3633: _GUICtrlRichEdit_GotoCharPos() does not detect end of text. - Fixed #3765: _FileWriteLog() using Handle Cannot insert atvthe beginning, just set @extended. - Fixed #3776: __EventLog_DecodeDesc(). - Fixed: _GUICtrlListView_SetItemChecked() regression and more GUIListview.au3 functions. - Fixed: _WinAPI_CreateEvent() return error on already define $sName. - Fixed: use "wstr" for "ptr" with Null value. - Fixed #3791: _ArrayDisplay() sort arrow. - Fixed #3805: $tagRID_DEVICE_INFO_KEYBOARD definition. - Fixed #3810: _ArrayUnique not handling "Default" for Parameter $iIntType. - Fixed: _WinAPI_DragQueryFileEx() $iflag behavior when mix drag (Thanks pixelsearch). - Fixed #3812: _DateTimeSplit() returning @error. - Fixed #3814: $PAGE_ connstants for _WinAPI_CreateFileMapping(). - Fixed #3821: _WinAPI_OemToChar() with string greater than 65536 crash. - Fixed: _Now(), _NowCalc(), ... date time coherency when call just on hour change. (Thanks argumentum). - Fixed #3824: _GUICtrlRichEdit_StreamToFile(), _GUICtrlRichEdit_StreamFromFile() default encoding doc. - Fixed #3825: beta regression for $tagEDITSTREAM in x64.1 point -
confused by WinGetTitle
636C65616E reacted to Nine for a topic
Current Alpha version has resolved that issue1 point -
What have you tried? Completely untested, but I suspect it should look something like this -- Local $sDesiredCapabilities = '{"capabilities":{"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "prefs": {"download.default_directory": "c:\\your\\desired\\directory\\"}}}}}'1 point