Leaderboard
Popular Content
Showing content with the highest reputation on 03/04/2015 in all areas
-
Hi. I've been working on this for a while. I think now it's good enough to post it here. Functions to do most everything with the DACL and ownership on all types of objects: Files or folders, Registry keys, services, Kernel and WMI objects, etc. Here's a good example to test: #include 'Permissions.au3' _InitiatePermissionResources() FileWrite(@ScriptDir&'test.txt','Test') Local $TI = TimerInit() Local $ret = _DenyAllAccess(@ScriptDir&'test.txt',$SE_FILE_OBJECT,@UserName) Local $TD = TimerDiff($TI) MsgBox(0,'','Deny all access to test.txt and take ownership:'&@CRLF&@CRLF& _ '_DenyAllAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _GrantReadAccess(@ScriptDir&'test.txt',$SE_FILE_OBJECT,'Administrators') $TD = TimerDiff($TI) MsgBox(0,'','Grant everyone read access, all access to admins and system, and set the owner: Admins group'&@CRLF&@CRLF& _ '_GrantReadAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _GrantAllAccess(@ScriptDir&'test.txt') $TD = TimerDiff($TI) MsgBox(0,'','Grant everyone access'&@CRLF&@CRLF& _ '_GrantAllAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _CopyFullDacl(@ScriptDir&'test.txt',$SE_FILE_OBJECT,@ScriptDir) $TD = TimerDiff($TI) MsgBox(0,'','Restore all inherited permissions'&@CRLF&@CRLF& _ '_CopyFullDacl return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Local $aPerm[2][3] = [['Restricted',1,$GENERIC_ALL],['Users',1,$GENERIC_ALL]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Add two granted access aces: Restricted and Users'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Dim $aPerm[2][3] = [['Restricted',1,$GENERIC_READ],['Users',1,$GENERIC_READ]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Give only read access to the Restricted and Users groups'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Dim $aPerm[2][3] = [['Restricted',0,$GENERIC_ALL],['Users',0,$GENERIC_ALL]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Deny access to the Restricted and Users groups'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Local $Hndl = _Permissions_OpenProcess(@AutoItPID) Local $SDBefore = _GetObjectStringSecurityDescriptor($Hndl,$SE_KERNEL_OBJECT) Local $CODRet = _ClearObjectDacl($Hndl,$SE_KERNEL_OBJECT) Local $DARet = _DenyAllAccess($Hndl,$SE_KERNEL_OBJECT) Local $SDAfter = _GetObjectStringSecurityDescriptor($Hndl,$SE_KERNEL_OBJECT) $TD = Round(TimerDiff($TI),2) MsgBox(0,'', 'Deny everyone access to the current process:'&@CRLF&@CRLF& _ '@AutoItPID original security descriptor: '&@CRLF&$SDBefore&@CRLF&@CRLF& _ '_ClearObjectDacl return value: '&$CODRet&@CRLF&@CRLF& _ '_DenyAllAccess_ return value: '&$DARet&@CRLF&@CRLF& _ 'New @AutoItPID security descriptor: '&@CRLF& _ $SDAfter&@CRLF&@CRLF& 'Time taken: '&$TD&' miliseconds.') _Permissions_CloseHandle($Hndl) FileDelete(@ScriptDir&'test.txt') _ClosePermissionResources()I'm planning to add functions to deal with the Sacl in the future, even though I don't think it's very important. Edit: Let me know if you need an example for the registry. Updated: Fixed a bug in the _ClearObjectDacl function. I thought that adding a null DACL would work fine, but it causes problems later when adding a new DACL. Those who have downloaded, please update. Shoot! Now it wasn't clearing the DACL at all. Updated again. I think it's fixed now. Updated 9/11/2011 - Added the security descriptor functions and removed unnecessary constants. Updated 10/11/2011 - There were some functions missing in the index, and some parameters in the comments. Also removed the "MustDeclareVars" option. (About 50 total downloads before) Update 12/12/2011 - Added more functions: New Update 12/12/2011 - Missing declaration keywords in 3 constants. Sorry Update 16/12/2011 - Added support for all object types, including window and process handles. Added more functions, modified most of them, and removed one. Here's the new function list: Updated 22/2/2012.. This time I'm including SecurityConstants.au3 and FileConstants.au3 to prevent constants conflicts. Added a few more functions and fixed a few bugs. Also added the ability to include the inherited aces in the _EditObjectPermissions function. Now the permissions array can have four elements (optional). It will still work with three elements arrays though. The fourth element is intended to have the inheritance flag for the corresponding ace. Here's the new list of functions: 400 previous downloads Permissions.au31 point
-
ActiveWindowTracking Toy v1.0.0.2
coffeeturtle reacted to jaberwacky for a topic
Hello, I don't like clicking every window just to make it the active window. I also often times want a window to be active but not stand on top of other windows. So, I threw together this script which I hope changes the proper windows settings without having to edit the registry. Seems to work for me on my Windows 7 x64 machine. Your mileage may vary. I honor no warranties. A more thorough explanation. Linux systems have a feature which will automatically focus the window that is currently under the mouse cursor. This setting can be enabled in Windows but used to require futzing around in the registry. This tool will enable the setting and also exposes two other important settings. ZOrder will determine whether or not the window which takes focus will come to the fore. Timeout will set how many milliseconds the mouse must hover over a window before it will take focus. ActiveWindowTrack Toy.zip dl: 110 Sincerely yours, Jaberwacky P.S., Latest AutoIt beta required for the source. An exe is included however. ------------------------------------------------------------------ Project now available on GitHub. ------------------------------------------------------------------ Latest update: Better code. No! I need to work with it some more. I messed something up. Latest Update: NOW better code. Latest Update: Improved GUI. Latest Update: The weirdest thing has happened. I was editing the file but when I would zip it, then it seemed like it wasn't creating a new zip file! Anyways, it should be right now. Latest Update: Better project structure. Latest Update: Fixed an important issue where the user could not revert back to previous settings. Again. Latest Update: Fixed again. Latest Update: Version 1.0! Made the GUI bigger in case it was too small for anybody with a disability. If that's ever a problem then let me know. Admin rights aren't actually required so those are gone. No need to restart your computer. Let me know of any problems! Latest update: ZOrder wasn't working. Does now. Latest Update: ZOrder wasn't working. Again. Silly error arising from the ancient copy/paste clan style of coding. ------------------------------------------------------------------ Recommended settings: Leave ZOrder unchecked and set Timeout to 100. Thanks to orbs and JohnOne!1 point -
Remote Function (AutoIt <=> PHP)
mesale0077 reacted to Luigi for a topic
This little example, you can build a function in AutoIt, the function have options and this options is send to PHP script. The PHP script proccess all options, and returns to AutoIt. Its simple and still development, but is useful. You can use xampp/wamp. Br, Luigi AutoIt script: #include-once #include <JSMN.au3> ; https://github.com/ez2sugul/stopwatch_client/blob/master/JSMN.au3 #include <object_dump.au3> arpc_url("http://localhost", "arpc/arpc.php") Local $sum = arpc_sum(20, 30) ConsoleWrite("$sum[" & $sum & "]" & @LF) Local $greetings = arpc_greetings() ConsoleWrite("$greetings[" & $greetings & "]" & @LF) Func arpc_sum($iNumber1, $iNumber2) Local $oo = ObjCreate($SD) $oo.Add("method", "sum") $oo.Add("number1", $iNumber1) $oo.Add("number2", $iNumber2) Local $oRet = arpc($oo) If @error Then Else Local $json = Jsmn_Decode($oRet) If Not $json.Exists("method") Then Return SetError(1, 0, "#unknow $json") Switch $json.Item("method") Case "@done" Return $json.Item("result") Case "@error" Return "@error." & $json.Item("result") EndSwitch EndIf EndFunc ;==>arpc_sum Func arpc_greetings() Local $oo = ObjCreate($SD) $oo.Add("method", "greetings") $oo.Add("client_name", @ComputerName) Local $return = arpc($oo) If @error Then Else EndIf EndFunc ;==>arpc_sum Func arpc_url($sHost = "", $sPage = "") If Not IsDeclared("oARPC") Then Global $oARPC = ObjCreate($SD) If IsDictionary($oARPC) Then $oARPC = ObjCreate($SD) __arpc_set("host", $sHost) __arpc_set("page", $sPage) __arpc_set("url", $sHost & "/" & $sPage) __arpc_set("version", "0.0.0.1") EndFunc ;==>arpc_url Func __arpc_set($key, $value) If $oARPC.Exists($key) Then $oARPC.Item($key) = $value Else $oARPC.Add($key, $value) EndIf EndFunc ;==>__arpc_set Func arpc($oo = "") Local $iStatusCode, $sReceived Static $sCookie = Cookie() ;~ If $DEBUG Then ConsoleWrite(@TAB & "> " & $sAddress & @LF) Local $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1") If @error Then Return SetError(1, 0, 0) $oHttp.Open("POST", $oARPC.Item("url"), False) $oHttp.setRequestHeader("User-Agent", "ARPC-AutoIt") $oHttp.setRequestHeader("arpc_version", $oARPC.Item("version")) $oHttp.setRequestHeader("Connection", "Keep-Alive") If $sCookie Then $oHttp.setRequestHeader("Cookie", $sCookie) $oHttp.setRequestHeader("Referer", $oARPC.Item("url")) Local $json = Jsmn_Encode_Compact($oo) ConsoleWrite("--> " & $json & @LF) $oHttp.Send(StringToBinary($json, 4)) $oHttp.WaitForResponse() Local $oAllHeaders = $oHttp.GetAllResponseHeaders() $sReceived = $oHttp.ResponseText $iStatusCode = $oHttp.Status If Not $sCookie Then $sCookie = $oHttp.GetResponseHeader("Set-Cookie") $oHttp = 0 If $iStatusCode == 200 Then Cookie($sCookie) ;ConsoleWrite("$oAllHeaders--------------------" & @LF & $oAllHeaders & "$oAllHeaders--------------------" & @LF) ConsoleWrite("<-- " & $sReceived & @LF) Return $sReceived Else ConsoleWrite("<-- @error" & @LF) Return SetError(1, 0, 0) EndIf EndFunc ;==>arpc Func Cookie($sInput = False) ;~ http://brugbart.com/setting-http-request-headers-autoit Static $sCookie If $sInput Then $sCookie = $sInput Return $sCookie EndFunc ;==>Cookie PHP Server <?php class arpc{ private $sRaw; private $sJson; private $oReturn; private $version; private $aHeaders; function __construct(){ $this->arpc_version = "0.0.0.1"; $this->oReturn = new stdClass(); $this->oFunctions = new stdClass(); $this->oFunctions->sum = array("number1", "number2"); $this->oFunctions->greetings = array("client_name"); $this->aHeaders = getallheaders(); if(!isset($this->aHeaders["arpc_version"])){ $this->oReturn->method = "@error"; $this->oReturn->result = "@version"; die(); } if(!isset($this->aHeaders["User-Agent"]) || ($this->aHeaders["User-Agent"] != "ARPC-AutoIt" ) ){ $this->oReturn->method = "@error"; $this->oReturn->result = "@user"; die(); } if(isset($HTTP_RAW_POST_DATA)){ $sRaw = $HTTP_RAW_POST_DATA; }else{ $sRaw = file_get_contents("php://input"); } if(!$sRaw){ $this->oReturn->method = "@error"; $this->oReturn->result = "@sRaw"; die(); } if(($this->sJson = json_decode($sRaw)) != True){ $this->oReturn->method = "@error"; $this->oReturn->result = "@json"; die(); } if(property_exists($this->oFunctions, $this->sJson->method) && method_exists("arpc", $this->sJson->method) ){ $method = $this->sJson->method; unset($this->sJson->method); $arr = $array = get_object_vars($this->sJson); $try = self::check_methods($this->oFunctions->$method, $arr); if($try){ $this->oReturn->method = "@done"; $this->oReturn->result = call_user_func_array("self::{$method}", $arr); }else{ $this->oReturn->method = "@error"; $this->oReturn->result = "@properties"; die(); } }else{ $this->oReturn->method = "@error"; $this->oReturn->result = "@unknow method"; die(); } } function check_methods($aa, $bb){ $arr = array(); foreach($bb as $key => $value){ $arr[] = $key; } $aDiff = array_diff($aa, $arr); if(count($aDiff)){ return False; }else{ return True; } } function __destruct(){ self::output(); } private function output(){ header("Content-Type: application/json; charset=utf-8"); header("version", $this->version); echo json_encode($this->oReturn); die(); } private function sum($number1, $number2){ return (int) $number1 + (int) $number2; } private function greetings($client_name){ return "Welcome {$client_name}!"; } } $arpc = new arpc(); object_dump.au3 #include-once #include <String.au3> Func dump($oo, $key = "", $iIdent = 0) ;~ Local $sString = dump_str($oo, $key, $iIdent) ConsoleWrite(dump_str($oo, $key, $iIdent) & @LF) ;~ Local $iTab = 4 ;~ Local $sKeys ;~ If IsDictionary($oo) Then ;~ $sKeys = $oo.Keys ;~ For $each In $sKeys ;~ If IsDictionary($oo.Item($each)) Or IsArray($oo.Item($each)) Then ;~ ConsoleWrite(($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & $each & "{" & @LF) ;~ dump($oo.Item($each), ($key == "" ? "" : $key & ".") & $each, $iTab + $iIdent) ;~ ConsoleWrite(($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & "}" & @LF) ;~ Else ;~ ConsoleWrite(($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & ($key == "" ? "" : $key & ".") & $each & " = " & $oo.Item($each) & @LF) ;~ EndIf ;~ Next ;~ Else ;~ If IsArray($oo) Then ;~ Switch UBound($oo, 0) ;~ Case 1 ;~ For $ii = 0 To UBound($oo, 1) - 1 ;~ If IsDictionary($oo[$ii]) Or IsArray($oo[$ii]) Then ;~ dump($oo[$ii], $key & "[" & $ii & "]", $iTab + $iIdent) ;~ Else ;~ ConsoleWrite(($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & ($key == "" ? "" : $key & "[") & $ii & "] = " & $oo[$ii] & @LF) ;~ EndIf ;~ Next ;~ Case 2 ;~ For $ii = 0 To UBound($oo, 1) - 1 ;~ For $jj = 0 To UBound($oo, 2) - 1 ;~ If IsDictionary($oo[$ii][$jj]) Or IsArray($oo[$ii][$jj]) Then ;~ dump($oo[$ii][$jj], $key & "[" & $ii & "][" & $jj & "]", $iTab + $iIdent) ;~ Else ;~ ConsoleWrite(($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & ($key == "" ? "" : $key & "[") & $ii & "][" & $jj & "] = " & $oo[$ii][$jj] & @LF) ;~ EndIf ;~ Next ;~ Next ;~ EndSwitch ;~ Else ;~ EndIf ;~ EndIf EndFunc ;==>dump Func dump_str($oo, $key = "", $iIdent = 0) Local $iTab = 4 Local $sKeys Local $sString = "" If IsDictionary($oo) Then $sKeys = $oo.Keys For $each In $sKeys If IsDictionary($oo.Item($each)) Or IsArray($oo.Item($each)) Then $sString &= (($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & $each & "{" & @LF) $sString &= dump_str($oo.Item($each), ($key == "" ? "" : $key & ".") & $each, $iTab + $iIdent) $sString &= (($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & "}" & @LF) Else $sString &= (($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & ($key == "" ? "" : $key & ".") & $each & " = " & $oo.Item($each) & @LF) EndIf Next Else If IsArray($oo) Then Switch UBound($oo, 0) Case 1 For $ii = 0 To UBound($oo, 1) - 1 If IsDictionary($oo[$ii]) Or IsArray($oo[$ii]) Then $sString &= dump_str($oo[$ii], $key & "[" & $ii & "]", $iTab + $iIdent) Else $sString &= (($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & ($key == "" ? "" : $key & "[") & $ii & "] = " & $oo[$ii] & @LF) EndIf Next Case 2 For $ii = 0 To UBound($oo, 1) - 1 For $jj = 0 To UBound($oo, 2) - 1 If IsDictionary($oo[$ii][$jj]) Or IsArray($oo[$ii][$jj]) Then $sString &= dump_str($oo[$ii][$jj], $key & "[" & $ii & "][" & $jj & "]", $iTab + $iIdent) Else $sString &= (($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & ($key == "" ? "" : $key & "[") & $ii & "][" & $jj & "] = " & $oo[$ii][$jj] & @LF) EndIf Next Next EndSwitch Else EndIf EndIf Return $sString EndFunc ;==>dump_str Func IsDictionary($oo = Null) If Not IsObj($oo) Or Not (ObjName($oo, 2) == "Scripting.Dictionary") Then Return 0 ;~ If Not (ObjName($oo, 2) == "Scripting.Dictionary") Then Return 0 Return 1 EndFunc ;==>IsDictionary1 point -
whenever i call this on my GUI: GUISetState(@SW_HIDE) the GUI does indeed become hidden, but it does so with a visual effect used for the Minimize command - i.e. decreasing size while fading. the effect is very swift, but still i'd like to cancel this effect and make the GUI immediately hidden. any hints?1 point
-
Do you have an example application for the code, because as it stands I've no idea what you can do with it. Do you routinely run out of Int64 data values?1 point
-
Duration of video files
dynamitemedia reacted to iamtheky for a topic
my original ffmpeg answer still works for me (tested just now on mp3, avi, and flv) even if it didnt for the OP 4 years ago. Here it is straight from the console rather than using a pipe #include <AutoItConstants.au3> Global $sFile = FileOpenDialog("Pick Media" , @ScriptDir & "\" , "ALL (*.*)") If @Error Then exit $sCommands = "ffmpeg -i " & '"' & $sFile & '"' $iPID = Run("cmd /c " & $sCommands, @ScriptDir , @SW_SHOW , $stderr_child + $stdout_child) $sOutput = "" While 1 $sOutput &= StderrRead($iPID) If @error Then ; Exit the loop if the process closes or StderrRead returns an error. ExitLoop EndIf WEnd msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)[0])1 point -
Ctrl + r is not implemented so far and will not work. And iuiautomation without internet and google is a hard way of using iuiautomation. The uiawrappers just simplify a little from the whole microsoft iuiautomation object model.1 point
-
ArrayFindAll on 2D Array Help
VenusProject2 reacted to BrewManNH for a topic
The array columns are zero based, and unfortunately for your script, if the column searched in is past the end of the array, it corrects your search to be the last column. So when you were searching the 3 column of the array in the 6/3 array, it was actually asking to search the 4th column, since there is no 4th column, it was auto-corrected to search the 3rd. When there actually is a 4th column, the auto-correction doesn't happen, and it searches in the 4th column (column order 0,1,2,3,4). Change the 3 in _arrayfindall to 2, and it works correctly.1 point -
I can't say I've ever noticed this issue. Perhaps it is a Windows setting on your PC? I seem to recall you can have that occur. I don't have that enabled on mine.1 point
-
ActiveWindowTracking Toy v1.0.0.2
jaberwacky reacted to TheSaint for a topic
Sounds like someone else I know ...... ME! Though not on this occasion. Now get to bed you crazy person ... you'll start hallucinating shortly.1 point -
ConsoleWrite not working on compiled executable
Leendert-Jan reacted to SadBunny for a topic
From the helpfile of ConsoleWrite: This does not write to a DOS console unless the script is compiled as a console application. Onwards to the helpfile text on "Compiling Scripts with Aut2Exe", which tells us that we can run the Aut2Exe compiler with the /console switch to make is a console application. If you are running from SciTE, you can just press ctrl+F7, which will bring up the Compile dialog, and check the "Create CUI instead of GUI EXE" checkbox before you press the "Compile Script" button. Works on my ConsoleWrite'ing hello world testscript1 point -
Ask about the buttons and interface
hoangtungpcinfo reacted to BrewManNH for a topic
If you want the GUI to be skinned, you need to include the DLL and the skin file with the compiled exe. The easiest way to do that is to use the FileInstall function to add them to the compiled script.1 point -
Find in File
coffeeturtle reacted to llewxam for a topic
Thanks for posting your sample files, though I am not on the computer yet so haven't downloaded them for testing. I was finding phrases in PDF files but again, thanks for posting the files you used! BTW, I did not test on msg and am glad you did, will be valuable to add that. I chose going with the 7-Zip files inline instead of FileInstall just because that now feels clunky to me - I would have to include them in an archive in the post here anyway, the executable would be about the same size, and that would be yet another folder with 2 7-Zip files in it! Going inline seems much better to me, but by all means change it on your end if you wish. Drag/drop to input is already there with last nights changes, few more things before I post it. As for your XML request, I have always loathed XML so don't understand why tags would need to go - why would the phrase you are searching for not be within one tag? If I just don't understand then please help me to, I'll definately help support XML by removing tags if the need is legit but every special case added will cause a small slowdown. Thanks Ian1 point -
Changing languages (Visual C)
mLipok reacted to jaberwacky for a topic
I used google to translate bracket to latin which is ancon. So Anconophobia?1 point -
@JohnOne - Good attempt, but it could be improved greatly (quite simply), by adding in elements that work with a drive serial number for instance or processor detail, username, etc. That way, the encrypted registry info couldn't just be swapped around from PC to PC.1 point