Leaderboard
Popular Content
Showing content with the highest reputation on 07/28/2022 in all areas
-
Just released version 1.6.0.12 points
-
@MightyWeirdPlease confirm that the bug has been fixed. Is fixed. See next post. New version in first post Version: 2022.07.27 - Support scripts with space in username.2 points
-
Encryption / Decryption / Hashing / Signing Purpose Cryptography API: Next Generation (CNG) is Microsoft's long-term replacement for their CryptoAPI. Microsoft's CNG is designed to be extensible at many levels and cryptography agnostic in behavior. Although the Crypt.au3 UDF lib that is installed with AutoIt3 still works well, the advapi32.dll functions that it uses have been deprecated. In addition the Crypt.au3 UDF lib, as it is currently written, has a very limited ability to decrypt AES data that was not encrypted using Crypt.au3 functions. That is because Crypt.au3 functions do not allow you to specify an actual key or initialization vector (IV). It only lets you specify data to be used to derive a key and uses a static IV. This UDF was created to offer a replacement for the deprecated functions used by Crypt.au3. According to Microsoft, deprecated functions may be removed in future release. It was also created to allow more flexibility and functionality in encryption/decryption/hashing/signing and to expand the ability for users to implement cryptography in their scripts. Description This UDF implements some of Microsoft's Cryptography API: Next Generation (CNG) Win32 API functions. It implements functions to encrypt/decrypt text and files, generate hashes, derive keys using Password-Based Key Derivation Function 2 (PBKDF2), create and verify signatures, and has several cryptography-related helper functions. The UDF can implement any encryption/decryption algorithms and hashing algorithms that are supported by the installed cryptography providers on the PC in which it is running. Most, if not all, of the "magic number" values that you would commonly use to specify that desired algorithms, key bit lengths, and other magic number type values, are already defined as constants or enums in the UDF file. To flatten the learning curve, there is an example file that shows examples of all of the major functionality. This example file is not created to be an exhaustive set of how to implement each feature and parameter. It is designed to give you a template or guide to help you hit the ground running in terms of using the functions. I have tried to fully document the headers of all of the functions as well as the code within the functions themselves. As of v1.4.0, there is also a Help file that includes all of the functions, with examples. Current UDF Functions Algorithm-Specific Symmetric Encryption/Decryption Functions _CryptoNG_AES_CBC_EncryptData _CryptoNG_AES_CBC_DecryptData _CryptoNG_AES_CBC_EncryptFile _CryptoNG_AES_CBC_DecryptFile _CryptoNG_AES_ECB_EncryptData _CryptoNG_AES_ECB_DecryptData _CryptoNG_AES_GCM_EncryptData _CryptoNG_AES_GCM_DecryptData _CryptoNG_3DES_CBC_EncryptData _CryptoNG_3DES_CBC_DecryptData _CryptoNG_3DES_CBC_EncryptFile _CryptoNG_3DES_CBC_DecryptFile Generic Symmetric Encryption/Decryption Functions _CryptoNG_EncryptData _CryptoNG_DecryptData _CryptoNG_EncryptFile _CryptoNG_DecryptFile Hashing Functions _CryptoNG_HashData _CryptoNG_HashFile _CryptoNG_PBKDF2 Asymmetric (Public/Private Key) Cryptography Functions _CryptoNG_ECDSA_CreateKeyPair _CryptoNG_ECDSA_SignHash _CryptoNG_ECDSA_VerifySignature _CryptoNG_RSA_CreateKeyPair _CryptoNG_RSA_EncryptData _CryptoNG_RSA_DecryptData _CryptoNG_RSA_SignHash _CryptoNG_RSA_VerifySignature Misc / Helper Functions _CryptoNG_CryptBinaryToString _CryptoNG_CryptStringToBinary _CryptoNG_GenerateRandom _CryptoNG_EnumAlgorithms _CryptoNG_EnumRegisteredProviders _CryptoNG_EnumKeyStorageProviders _CryptoNG_LastErrorMessage _CryptoNG_Version Related Links Cryptography API: Next Generation - Main Page Cryptography API: Next Generation - Reference Cryptography API: Next Generation - Primitives Cryptography API: Next Generation - Cryptographic Algorithm Providers Get CryptoNG from the AutoIt Downloads Area1 point
-
No sarcasm intended... Really. In all seriousness, it isn't a function that I use regularly so I had forgotten about that restriction. It looks like there had been some recent movement on this over in the Chromium camp, so maybe it will be resolved before too much longer.1 point
-
1 point
-
Au3toCmd -- Avoid false virus positives. (Version: 2022.09.01)
Exit reacted to MightyWeird for a topic
Hi Exit, Yes the latest update (Version: 2022.07.27) fixes this problem. My script runs fine now. Thank you for your work / quick fix!1 point -
DllStructEx - Extended DllStruct for AutoIt3
argumentum reacted to genius257 for a topic
Version 1.1.0 released! Most important change is a fix to the byte padding, that previously made DllStructEx useless with unions and nested structs with external calls! 🎊1 point -
Try This: #include <File.au3> $s = FileRead("mp3.txt") $aReadUrl = StringRegExp($s, "(?:http).+(?=\w\/)+[!-~]+\.\w{3}", 3) If IsArray($aReadUrl) Then ;~ MsgBox(0, StringRegExpReplace($aReadUrl[0], ".*\/", ""), $aReadUrl[0]) InetGet($aReadUrl[0], StringRegExpReplace($aReadUrl[0], ".*\/", ""), "", 2) ;~ _ArrayDisplay($aReadUrl, "File Url List") EndIf1 point
-
RunAs not fully elevated (UAC issue)
wongshing1439 reacted to AdamUL for a topic
Here is a workaround for dealing with RunAs and RunAsWait and the UAC Admin Token. This uses re-execution to elevate the script and allow the Admin part of the script to run. After the admin part runs, it reverts back to the not admin part. Example script is below. #include <MsgBoxConstants.au3> Global $sAdminUser = "USERNAME" Global $sAdminPassword = "PASSWORD" Global $sDomain = @ComputerName Global $iLogOnFlag = 0 Global $sParameters = "" ;Run as the Admin account. If @UserName <> $sAdminUser And Not IsAdmin() Then $sParameters = "" If Not @Compiled Then $sParameters = ' "' & @ScriptFullPath & '"' EndIf ;Use RunAsWait to run as AdminUser, to continue the script as the user that started it, and to wait for the Admin part to Finish. RunAsWait($sAdminUser, $sDomain, $sAdminPassword, $iLogOnFlag, @AutoItExe & $sParameters) If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR!", "Unable to run under administrator account.") EndIf ;Request the Admin Token for the Admin account in Windows Vista and Higher. If @UserName = $sAdminUser And Not IsAdmin() And Not StringRegExp(@OSVersion, "_(XP|200(0|3))") Then $sParameters = "" If Not @Compiled Then $sParameters = '"' & @ScriptFullPath & '"' EndIf ;Use ShellExecuteWait to run as AdminUser with Admin Token, to wait for the Admin part of the script to finish, and then to exit. ShellExecuteWait(@AutoItExe, $sParameters, "", "runas") If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR!", "Unable to elevate to Admin due to UAC.") Exit EndIf MsgBox($MB_ICONINFORMATION, @UserName, "Is " & (IsAdmin() ? "" : "Not " ) & "Admin") ;Example Global $sDrive = EnvGet("systemdrive") ;Admin part of script. If IsAdmin() Then MsgBox ($MB_OK, "Admin Run Test", "Run Admin part of script and then exit to run as user who started the script.") ;Example Run($sDrive & "\vendor\vendor.exe") ;Wait for Vendor Version Control to close Do Sleep(100) Until Not WinExists("Vendor Version Control") ;Wait for VendorAppLauncher to exist ProcessWait("VendorAppLauncher.exe") ;Close the Vendor Launcher as Admin ProcessClose("VendorAppLauncher.exe") ;Exit to finish Admin part of script. Exit EndIf ;Put rest of the non Admin part of script here. ;Re-open Vendor Launcher as user Run($sDrive & "\Vendor\VendorAppLauncher.exe", $sDrive & "\Vendor") Adam1 point -
If the AutoIt Window Info tool isn't able to detect a control the standard way to proceed is to try with the UI Automation framework, which has been the Microsoft automation platform for the last 10 years. You should start by checking if the UI Automation framework is able to detect your control. The easiest way to do that is to use Inspect.exe which is a Microsoft tool. You can find Inspect.exe in the bin-folder of the Windows 10 SDK (can also be installed on windows 7/8). The Windows 10 SDK takes up about 2.5 GB of diskspace. If you only need Inspect.exe you can copy the 32 and 64 bit versions of the program and then uninstall the SDK again (installing the SDK is the only legal way to get a copy of Inspect.exe). You can also find a copy of Inspect.exe here (the RAR-file can be extracted with 7-Zip). Double click Inspect.exe to start it and hover the mouse pointer over the control. You'll probably see a lot of information. In a Combo box in upper left corner of Inspect.exe you can switch between UI Automation mode (default) and MSAA mode (Microsoft Active Accessibility). MSAA mode can be useful if your program is very old (more than 10 years old). If Inspect.exe can identify your control you can use the AutoIt implementation of the UI Automation framework to automate the control. Here is an example with the TreeView in Windows/File Explorer left pane window. The Intel folder on the C-drive is selected: Inspect.exe can identify the TreeView item and extract a lot of information. The Action menu is opened and the Expand action is highlighted: When the Expand menu item is clicked the TreeView is expanded: With Inspect.exe you can test if the TreeView can be automated with UI Automation code. And you can perform the test without writing a single line of code. In the next two pictures the Intel folder is collapsed again. With Inspect.exe you can relatively easily get an impression of whether you're able to automate the window or control. And you can figure it out before you start writing code. The code box shows how to automate the manual procedure above with UI Automation code. Windows/File Explorer must be open and the C-drive must be expanded as shown in the last picture. The code expands and collapses the Windows folder: #include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Flag to handle Windows XP Local $fXP = ( @OSVersion = "WIN_XP" ) ; Get window handle for Windows/File Explorer on XP, Vista, 7, 8, 10 Local $hWindow = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hWindow Then Return ConsoleWrite( "$hWindow ERR" & @CRLF ) ConsoleWrite( "$hWindow OK" & @CRLF ) ; Activate the window WinActivate( $hWindow ) ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get UI Automation element from window handle Local $pWindow, $oWindow $oUIAutomation.ElementFromHandle( $hWindow, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow ) Then Return ConsoleWrite( "$oWindow ERR" & @CRLF ) ConsoleWrite( "$oWindow OK" & @CRLF ) ; Condition to find the Windows folder in the TreeView ; We use two conditions to find the Windows folder ; A condition to find the folder as a TreeView item ; A condition to find the folder by name (Windows) ; TreeView item Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TreeItemControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) ; Folder name Local $pCondition2 ; Note that $UIA_NamePropertyId ia a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, ( $fXP ? "WINDOWS" : "Windows" ), $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition Local $pCondition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) ; Find folder Local $pFolder, $oFolder $oWindow.FindFirst( $TreeScope_Descendants, $pCondition, $pFolder ) $oFolder = ObjCreateInterface( $pFolder, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oFolder ) Then Return ConsoleWrite( "$oFolder ERR" & @CRLF ) ConsoleWrite( "$oFolder OK" & @CRLF ) If Not $fXP Then ; For visual verification ; XP: SetFocus expands the folder $oFolder.SetFocus() ; Not necessary ConsoleWrite( "SetFocus OK" & @CRLF ) EndIf ; ExpandCollapse pattern object ; Pattern objects are used for ACTIONS Local $pExpandCollapse, $oExpandCollapse $oFolder.GetCurrentPattern( $UIA_ExpandCollapsePatternId, $pExpandCollapse ) $oExpandCollapse = ObjCreateInterface( $pExpandCollapse, $sIID_IUIAutomationExpandCollapsePattern, $dtagIUIAutomationExpandCollapsePattern ) If Not IsObj( $oExpandCollapse ) Then Return ConsoleWrite( "$oExpandCollapse ERR" & @CRLF ) ConsoleWrite( "$oExpandCollapse OK" & @CRLF ) ; Wait 5 seconds Sleep( 5000 ) ; Expand folder $oExpandCollapse.Expand() ConsoleWrite( @CRLF & "Expand OK" & @CRLF ) ; Wait 5 seconds Sleep( 5000 ) ; Collapse folder $oExpandCollapse.Collapse() ConsoleWrite( @CRLF & "Collapse OK" & @CRLF ) EndFunc Output in SciTE console: $hWindow OK $oUIAutomation OK $oWindow OK $pCondition1 OK $pCondition2 OK $pCondition OK $oFolder OK SetFocus OK $oExpandCollapse OK Expand OK Collapse OK The code is tested on Windows 10, 7 and XP. The zip file contains the example code and CUIAutomation2.au3. Run the code in SciTE. Explorer.7z An alternative to Inspect.exe is the simplespy.au3 script which is included in UIA_V0_63.zip in bottom of first post in the UI Automation thread. Another alternative to both Inspect.exe and simplespy.au3 is UIASpy - UI Automation Spy Tool. Examples of UIASpy use are found in Using UI Automation Code in AutoIt. With the code in post 71 of the UI Automation thread you can print information in SciTE console about the controls in a window. The information is printed in a hierarchical structure like a treeview.1 point
-
Image List
NoNameCode reacted to Yashied for a topic
#Include <GDIPlus.au3> #Include <GUIImageList.au3> #Include <GUIListView.au3> _GDIPlus_Startup() $hForm = GUICreate('MyGUI', 400, 400, 302, 218) $hListView = GUICtrlCreateListView('', 10, 10, 380, 380) _GUICtrlListView_AddColumn($hListView, 'Items', 200) $hImageList = _GUIImageList_Create(150, 160, 5, 1) _GUICtrlListView_SetImageList($hListView, $hImageList, 1) _GUIImageList_AddImage($hImageList, -1, @ScriptDir & '\test.jpg') _GUICtrlListView_AddItem($hListView, 'Test', 0) GUISetState() Do Until GUIGetMsg() = -3 Func _GUIImageList_AddImage($hWnd, $iIndex, $sFile) Local $Size = _GUIImageList_GetIconSize($hWnd) If (Not $Size[0]) Or (Not $Size[1]) Then Return -1 EndIf Local $W, $H, $hGraphic, $hPic, $hImage, $hIcon _GDIPlus_Startup() $hPic = _GDIPlus_ImageLoadFromFile($sFile) $W = _GDIPlus_ImageGetWidth($hPic) $H = _GDIPlus_ImageGetHeight($hPic) If ($W < 0) Or ($H < 0) Then _GDIPlus_Shutdown() Return -1 EndIf If $W < $H Then $W = $Size[0] * $W / $H $H = $Size[1] Else $H = $Size[1] * $H / $W $W = $Size[0] EndIf $hImage = DllCall($ghGDIPDll, 'int', 'GdipGetImageThumbnail', 'ptr', $hPic, 'int', $Size[0], 'int', $Size[1], 'ptr*', 0, 'ptr', 0, 'ptr', 0) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage[4]) _GDIPlus_GraphicsClear($hGraphic, 0) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hPic, ($Size[0] - $W) / 2, ($Size[1] - $H) / 2, $W, $H) $hIcon = DllCall($ghGDIPDll, 'int', 'GdipCreateHICONFromBitmap', 'ptr', $hImage[4], 'ptr*', 0) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage[4]) _GDIPlus_ImageDispose($hPic) _GDIPlus_Shutdown() If Not $hIcon[2] Then Return -1 EndIf $iIndex = _GUIImageList_ReplaceIcon($hWnd, $iIndex, $hIcon[2]) _WinAPI_DestroyIcon($hIcon[2]) Return $iIndex EndFunc ;==>_GUIImageList_AddImag1 point