Leaderboard
Popular Content
Showing content with the highest reputation on 08/23/2019 in all areas
-
Hello guys. Here is a small function to create a hash hmac similar to hash_hmac PHP function. Supported are: SHA512,SHA256,SHA1,SHA384,MD5 and RIPEMD160. Local $sSecret = "SecretKey" Local $sMessage = "AutoIt Rocks!!!" ConsoleWrite("HMAC-SHA256: " & @TAB & @TAB & _HashHMAC("SHA512", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA256: " & @TAB & @TAB & _HashHMAC("SHA256", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA1: " & @TAB & @TAB & _HashHMAC("SHA1", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA384: " & @TAB & @TAB & _HashHMAC("SHA384", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-MD5: " & @TAB & @TAB & _HashHMAC("MD5", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-RIPEMD160: " & @TAB & _HashHMAC("RIPEMD160", $sMessage, $sSecret) & @CRLF) Func _HashHMAC($sAlgorithm, $bData, $bKey, $bRaw_Output = False) Local $oHashHMACErrorHandler = ObjEvent("AutoIt.Error", "_HashHMACErrorHandler") Local $oHMAC = ObjCreate("System.Security.Cryptography.HMAC" & $sAlgorithm) If @error Then SetError(1, 0, "") $oHMAC.key = Binary($bKey) Local $bHash = $oHMAC.ComputeHash_2(Binary($bData)) Return SetError(0, 0, $bRaw_Output ? $bHash : StringLower(StringMid($bHash, 3))) EndFunc ;==>_HashHMAC Func _HashHMACErrorHandler($oError) ;Dummy Error Handler EndFunc ;==>_HashHMACErrorHandler It requires .NET Framework 2.0 or higher. Saludos1 point
-
If statement in for loop causing error.
SkysLastChance reacted to Gianni for a topic
try to change the ContinueLoop statement with an EndIf1 point -
1 point
-
Can you access the web site manually with IE ? Does it have outside references ? Is the initial url changing during the load ? Any supplemental information would certainly help...1 point
-
Try removing the protected mode of the intranet (IE Menu Options/tab Security). See if that works...1 point
-
Your "security officer" urgently needs one or more of: brain surgery, basic education, brain software update, getting fired. (S)he shoots hundreds of ammunitions to anything in sight that shows the slightest move, gets sure the thing is dead, then gets close and shouts "You souldn't have moved!" at the dead body. I wouldn't have liked to be a fellow soldier of your "genocide officer". As the lengthy thread already mentionned shows, the culprit is the one who choose an under-par AV (another "security officer" perhaps?), not the employee using AutoIt for the benefit of the company.1 point
-
'Connected Standby' Support
VenusProject2 reacted to Bilgus for a topic
the equivalent in autoit would be: ;AHK SendMessage, 0x112, 0xF170, 2,, Program Manager ;AHK SendMessage, Msg , wParam, lParam, Control, WinTitle, WinText, ExcludeTitle, ExcludeText, Timeout #include <SendMessage.au3> Local $hWnd = WinGetHandle("[CLASS:Progman]") ;or Local $hWnd = WinGetHandle("[TITLE:Program Manager]") _SendMessage ($hWnd, 0x112, 0xF170, 2) ;or maybe?? _SendMessage ("[TITLE:Program Manager]", 0x112, 0xF170, 2)1 point -
Find Administrator and Guest username
Colduction reacted to Subz for a topic
Another way: #include <Security.au3> Global $g_aComputerSID = _Security__LookupAccountName(@ComputerName) If @error Then Exit ConsoleWrite(_GetAccountName($g_aComputerSID[0] & "-500") & @CRLF) ;~ Administator Account SID ConsoleWrite(_GetAccountName($g_aComputerSID[0] & "-501") & @CRLF) ;~ Guest Account SID Func _GetAccountName($_sAccountSID) Local $aAccountSID = _Security__LookupAccountSid($_sAccountSID, @ComputerName) Local $sAccoutName = @error = 0 And IsArray($aAccountSID) ? $aAccountSID[0] : "" Return $sAccoutName EndFunc1 point -
Thanks all for alternative solutions. My final working solution: #AutoIt3Wrapper_UseX64=n #NoTrayIcon #include <GUIConstants.au3> #include <GuiStatusBar.au3> $Form1 = GUICreate("StatusBar Checkbox", 400, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX)) $cbx1 = GUICtrlCreateCheckbox("Sum 1", 10, 100, 120, 20) GUICtrlSetResizing($cbx1, $GUI_DOCKLEFT+$GUI_DOCKTOP+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $cbx2 = GUICtrlCreateCheckbox("Sum 2", 3, 3, 58, 15) $hcbx2 = GUICtrlGetHandle($cbx2) GUICtrlSetResizing($cbx2, $GUI_DOCKALL) $cbx2_dummy = GUICtrlCreateDummy() $StatusBar1 = _GUICtrlStatusBar_Create($Form1) Dim $sb1_PartsWidth[3] = [62, 200, -1] _GUICtrlStatusBar_SetParts($StatusBar1, $sb1_PartsWidth) _GuiCtrlStatusBar_Resize($StatusBar1) _SetParent($cbx2, $StatusBar1) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_SIZE, "WM_SIZE") ; Register StatusBar window proc Global $hDll, $pDll, $hProc $hDll = DllCallbackRegister('_SBWinProc', 'ptr', 'hwnd;uint;wparam;lparam') $pDll = DllCallbackGetPtr($hDll) $hProc = _WinAPI_SetWindowLong($StatusBar1, $GWL_WNDPROC, $pDll) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $cbx1 MsgBox(64, 'cbx1', 'Checked: ' & IsChecked($cbx1)) Case $cbx2_dummy MsgBox(64, 'cbx2', 'Checked: ' & IsChecked($cbx2)) EndSwitch WEnd _WinAPI_SetWindowLong($StatusBar1, $GWL_WNDPROC, $hProc) DllCallbackFree($hDll) Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) _GuiCtrlStatusBar_Resize($StatusBar1) Return $GUI_RUNDEFMSG EndFunc Func _SetParent($ctrl_child, $ctrl_parent) ;~ $ctrl_parent = GUICtrlGetHandle($ctrl_parent) $ctrl_child = GUICtrlGetHandle($ctrl_child) DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $ctrl_child, "hwnd", $ctrl_parent) EndFunc Func IsChecked($control) Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED EndFunc Func _SBWinProc($hWnd, $iMsg, $wParam, $lParam) If $hWnd = $StatusBar1 And $iMsg = $WM_COMMAND And $wParam = $cbx2 Then GUICtrlSendToDummy($cbx2_dummy) Return _WinAPI_CallWindowProc($hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc1 point
-
Files patch manager v1.1 (patch generator)
Stormgrade reacted to Neutro for a topic
Hey guys, I needed a tool to generate a patch from the folder of a software after an update so i could apply this patch to other computers without having to re-download the update on them as well. I've looked a bit on the net and was surprised not beeing able to find one. So i've made my own that i called "file patch manager": I think the explaination in the screenshot above is pretty much straightfoward so i don't need to add a lot more to that This is developped in pure autoit v3.3.14.5, no UDF required. Download Source code: files patch manager v1.1.au3 Compiled exe: files patch manager v1.1.exe I've noticed that the compiled exe can sometimes be detected as a trojan by windows defender :facepalm: But this is a false positive as it's a compiled exe from the untouched source code i'm providing here as well. If you have any doubt feel free to compile it yourself instead of directly using the exe, but i assure you the exe is completely safe. If i had bad intentions i wouldn't share the source code as well More informations on why the false positive happens can be found here: The code is not perfect and could certainly be enhanced but i've tested it and all the steps should work properly in all situations except maybe when using it on a folder that contains files with special attributes (explained below). What could be enhanced: - if the updated version of the folder of the software contains empty folders that did not previously exist in the outdated folder, this tool doesn't carry them over (it could be added easily thought, i made a comment about that in the source code) - i didn't test the tool with a folder that had files with special attributes (hidden, system, ect...) so some tweaking might be needed to use it on such a folder - i didn't had the time to secure the tool properly from user-input mistakes or to add proper error handling to all the functions used to check they return values for errors, but you can easily check if the patch works correctly by trying to apply it to an outdated folder then compare it's byte size to the one of the updated folder. If they match then it's OK. - the GUI design which is pretty basic but doing a fancy thing wasn't my goal here. - when designing the engine to compare the outdated and updated folders i did one that compares the files then the folders. It compares them in 2 steps while it could have been possible to compare both in 1 step by analysing if the compared element was a file or a folder using the FileGetAttrib function. This means that for a software that has a huge number of files and folders (over 10000) the 2 step process will take twice the time it would take with a 1 step process. But since i've never had to work in that case until now, i won't change the compare engine right now. If one of you reach this case and processing time is an essential factor you know what you have to do Shouldn't be too complicated to make the change anyway if needed. If you have any problems using it feel free to ask, i'll do my best to help when i'm available. If possible include the outdated and updated folders you use as the source of your patch so i can run it and check errors by myself as well. If you used this tool for your own needs and made some improvements consider sharing your version as well Enjoy Changelog 22 august 2019 - v1.0: - initial release 23 august 2019 - v1.1: - fix crash if patch generated has no file to delete inside the outdated folder. - added a progress bar to show which file the tool is currently working on, it's size and how many files are remaining so the tool doesn't look frozen when it's working with large files.1 point -
You may want to have a look at a post I created about a week ago, it may also help, I actually tried using XML udf but because my xml like yours didn't have any id attributes I ended up using DOM object directly and getting information directly from msdn and other sites on the code. You'll notice I ended up using createNode method but actually prefer the createElement method I posted for you, so will probably change my code to reflect this.1 point
-
Hopefully the following will help, I gather you can add in the checks against the array, you probably want to comment out the _Add_DataNode() function as it will keep adding a Data node section to the end of your sheet, it was basically just an example. #include <XML.au3> ;~ Create a blank template file ;~ ArrayData - Template.xml Local $fXMLTemplate = @ScriptDir & "\Template.xml" If FileExists($fXMLTemplate) = 0 Then Local $hXMLTemplate = FileOpen($fXMLTemplate, 10) $sXMLTemplate = '<?xml version="1.0" encoding="utf-8"?>' & @CRLF $sXMLTemplate &= '<ArrayOfData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' & @CRLF $sXMLTemplate &= '</ArrayOfData>' & @CRLF FileWrite($hXMLTemplate, $sXMLTemplate) FileClose($hXMLTemplate) EndIf Local $fXMLFileName = @ScriptDir & "\FileName.xml" If FileExists($fXMLFileName) = 0 Then FileCopy($fXMLTemplate, $fXMLFileName, 9) Local $oRoot_Node, $oData_Node, $oData_SubNode Local $oErrorHandler = ObjEvent("AutoIt.Error", "_XmlErrFunc") Local $oXMLDoc = ObjCreate("MSXML2.DOMDocument") $oXMLDoc.validateOnParse = True $oXMLDoc.load($fXMLFileName) Local $oDataNodes_Enum = $oXMLDoc.selectNodes("ArrayOfData/Data") ;~ Just as an example ;~ Add a new Data node _Add_DataNode() ;~ Check existing nodes If IsObj($oDataNodes_Enum) Then For $oData_Enum In $oDataNodes_Enum For $i = 0 To ($oData_Enum.childNodes.length - 1) If $oData_Enum.childNodes.item($i).tagName = "dataType" And $oData_Enum.childNodes.item($i).Text = "T2" Then ContinueLoop If $oData_Enum.childNodes.item($i).tagName = "dataDetails" Then For $j = 0 To ($oData_Enum.childNodes.item($i).childNodes.length - 1) ConsoleWrite($oData_Enum.childNodes.item($i).childNodes.item($j).Text & @CRLF) Next EndIf Next Next ;~ Document is modified only after saving the document $sXMLDoc = _XML_TIDY($oXMLDoc) $sXMLDoc.save($fXMLFileName) Else ;~ Add Data Node _Add_DataNode() ;~ Document is modified only after saving the document ;~ _XML_TIDY($oXMLDoc) $oXMLDoc.save($oXMLDoc) EndIf Func _Add_DataNode() $oRoot_Node = $oXMLDoc.documentElement $oData_Node = _XML_AddElement($oRoot_Node, "Data") _XML_AddElement($oData_Node, "Enabled", "true") _XML_AddElement($oData_Node, "dataType", "T1") $oData_SubNode = _XML_AddElement($oData_Node, "dataDetails") _XML_AddAttrib($oData_SubNode, "xsi:Type", "Type1") _XML_AddElement($oData_SubNode, "field1", "name1") _XML_AddElement($oData_SubNode, "field2", "email1") _XML_AddElement($oData_SubNode, "field3", "choice1") _XML_AddElement($oData_SubNode, "field4", "choice2") _XML_AddElement($oData_SubNode, "field5", "choice3") _XML_AddElement($oData_SubNode, "field6", "choice4") _XML_AddElement($oData_SubNode, "field7", "choice5") _XML_AddElement($oData_SubNode, "field8", "choice6") _XML_AddElement($oData_Node, "optionSetting", "true") ;~ Save XML with indentations ;~ $sXMLDoc = _XML_TIDY($oXMLDoc) ;~ Local $hFileOpen = FileOpen($fXMLFileName, 2) ;~ FileWrite($fXMLFileName, $sXMLDoc) ;~ FileClose($hFileOpen) ;~ Save XML without indentations $oXMLDoc.save($fXMLFileName) EndFunc Func _XML_AddElement($_oNode, $_sTagName = "", $_sText = "") Local $oNode = $oXMLDoc.createElement($_sTagName) If $_sText <> "" Then $oNode.Text = $_sText $_oNode.appendChild($oNode) Return $oNode EndFunc Func _XML_AddAttrib($_oAttrib, $_sAttribName = "", $_sNodeValue = "") Local $oAttrib = $oXMLDoc.createAttribute($_sAttribName) If $_sNodeValue <> "" Then $oAttrib.nodeValue = $_sNodeValue $_oAttrib.setAttributeNode($oAttrib) Return $oAttrib EndFunc1 point
-
Open a file's properties window
alienclone reacted to Ascend4nt for a topic
If ShellExecute doesn't work for you, there are two alternatives: One using COM objects: $sPath = @SystemDir&"\user32.dll" $oshellApp = ObjCreate("shell.application") $oshellApp.namespace(0).parsename($sPath).invokeverb("Properties") Sleep(2000) ; The Properties page will display and disappear if your program exits (it somehow attaches to this process) One using SHObjectProperties: Global Const $SHOP_PRINTERNAME=1 ; $sObjName = printer friendly name Global Const $SHOP_FILEPATH=2 ; $sObjName = full pathname to file Global Const $SHOP_VOLUMEGUID=4 ; $sObjName = Drive Path ("C:\") or Volume GUID ("\\?\Volume\{2eca078d-5cbc-43d3-aff8-7e8511f60d0e}\)") Func _FilePropertiesDialog($sObjName,$sPropPage="",$iObjType=0x02,$hWnd=0) Local $sPropPageType="ptr" If IsString($sPropPage) And $sPropPage<>"" Then $sPropPageType="wstr" Else $sPropPage=0 EndIf Local $aRet=DllCall("shell32.dll","bool","SHObjectProperties","hwnd",$hWnd,"dword",$iObjType,"wstr",$sObjName,$sPropPageType,$sPropPage) If @error Then Return SetError(2,@error,False) If Not $aRet[0] Then Return SetError(3,0,False) Return True EndFunc _FilePropertiesDialog("C:\","",4) ; Drive/Volume Properties - this special case does not return until closed by the User _FilePropertiesDialog("Microsoft XPS Document Writer","",1) ; Printers ConsoleWrite("@error="&@error&", @extended="&@extended&@CRLF) Sleep(2000) ; The Properties page will display and disappear if your program exits (it somehow attaches to this process) _FilePropertiesDialog(@ComSpec,"Version",2) ; File ConsoleWrite("@error="&@error&", @extended="&@extended&@CRLF) Sleep(2000) ; The Properties page will display and disappear if your program exits (it somehow attaches to this process) Note how both options will close once the program is closed - this is why you should do what you need to do with the dialog boxes, and then close them. The odd case is drives, from which it doesn't return until closed by the user. A nice thing about the second option is that you can select which Property tab displays (I gave 'Version' as an example, but you can leave it as "" to display the default tab). Anyway, hope it helps1 point