Leaderboard
Popular Content
Showing content with the highest reputation on 11/09/2011 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
-
HotKeySet ("{F12}", "restoreinput") Func restoreinput() BlockInput(0) EndFunc But, if the input is off what makes the computer detect that you pressed F12? lol You can always disconnect the usb ports of kb and mouse...1 point
-
closing all ie tabs except one
dickjones007 reacted to pilky1986 for a topic
Thats the latest code i have on my pc.. the finished article (not much different) is at work. Code posted above. The main things that i think you will want are in there is While 1 ; starts a loop for collecting the URL(s) of IE $oIE = _IEAttach ("", "instance", $i) If @error = $_IEStatus_NoMatch Then ExitLoop ReDim $aIE[$i + 1] $aIE[$i] = _IEPropertyGet($oIE, "locationurl") $aIE[0] = $i $i += 1 WEnd ; ends the loop In the autoit help file look for _ieAttach() function and look at example 5 (code below). This would be a good way i think of determining how many tabs you have open.. therefore you could say if the number returned is greater than 1 then close all tabs except the first one. ; ******************************************************* ; Example 5 - Create an array of object references to all current browser instances ; The first array element will contain the number of instances found ; ******************************************************* ; #include <IE.au3> Dim $aIE[1] $aIE[0] = 0 $i = 1 While 1 $oIE = _IEAttach ("", "instance", $i) If @error = $_IEStatus_NoMatch Then ExitLoop ReDim $aIE[$i + 1] $aIE[$i] = $oIE $aIE[0] = $i $i += 1 WEnd MsgBox(0, "Browsers Found", "Number of browser instances in the array: " & $aIE[0]) I guess your program is basically being used to limit the number of internet explorer tabs to 1 as there is no built in function in IE to limit the ammount of tabs open at any one time? is that correct?1 point -
closing all ie tabs except one
dickjones007 reacted to pilky1986 for a topic
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=close.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstants.au3> #Include <File.au3> #Include <Array.au3> #include <Misc.au3> #include <IE.au3> ;************************************************************************************************************************************************************************* ; Version Information ;************************************************************************************************************************************************************************* ; Version 1.2 ;************************************************************************************************************************************************************************* ; System Tray Options ;************************************************************************************************************************************************************************* TraySetIcon(1) ; Creates/Enables a tray icon for the program TraySetClick(0) ;Stops the tray icon from being clicked on TraySetToolTip("v1.2") ;When the mouse hovers over the tray icon it displays the text ;************************************************************************************************************************************************************************* ; Variables and Constants Declerations ;************************************************************************************************************************************************************************* dim $blocked dim $i dim $i2 dim $call = 0 dim $refresh_timer = 0 dim $aIE ;dim const $blocklistlocation = "Barnts01programs$programsblock list.txt" ; Writes the location of the keyword file to memory ;dim const $TabClosePromptTitle = FileOpen("Barnts01programs$programstab close prompt title.txt") ;sets the location and opens the file for the string for the tab close prompt window title dim const $blocklistlocation = ".block list.txt" ; Writes the location of the keyword file to memory dim const $TabClosePromptTitle = FileOpen(".tab close prompt title.txt") ;sets the location and opens the file for the string for the tab close prompt window title dim const $TabClosePromptTitleDataCitrix = FileReadLine($TabClosePromptTitle,1) ;gets the tab close prompt window title data (string) from the file - line 1 dim const $TabClosePromptTitleDataIE = FileReadLine($TabClosePromptTitle,2) ;gets the tab close prompt window title data (string) from the file - line 2 ;************************************************************************************************************************************************************************* ; Load the list of keywords from the block list.txt file to memory (array) ;************************************************************************************************************************************************************************* _FileReadToArray($blocklistlocation,$blocked) ;Reads the block list text file to memory (array) ;************************************************************************************************************************************************************************* ; Functions ;************************************************************************************************************************************************************************* Func _Check_Tab_Close() ; This function checks if the internet explorer multiple tab close window is present. If it is present it clicks the close all button AutoItSetOption("WinTitleMatchMode", 3) ; Used so that when WinExists below is used it searches exactly for the mentioned text only If WinExists($TabClosePromptTitleDataCitrix) or WinExists($TabClosePromptTitleDataIE) Then ; Checks to see if a window exists with the mentioned text Send("{ENTER}") ;Presses (sends) the Enter/Return key EndIf Sleep(2000) ;Pauses the program for 2 seconds i.e. keeps the message on screen for that length of time SplashOff() ; Turns off the on screen message created above $call = 0 ; Sets the $call variable back to 0 .. see _Win_Close function for variable being set to 1 EndFunc Func _Win_Close() ; Used to check the IE window URL(s) (single or multi-tab) against a list. If a match is found the IE window is closed. Dim $aIE[1] ; Creates a space in memory for an array $aIE[0] = 0 ; Sets the number of elements in the array to 0 $i = 1 While 1 ; starts a loop for collecting the URL(s) of IE $oIE = _IEAttach ("", "instance", $i) If @error = $_IEStatus_NoMatch Then ExitLoop ReDim $aIE[$i + 1] $aIE[$i] = _IEPropertyGet($oIE, "locationurl") $aIE[0] = $i $i += 1 WEnd ; ends the loop _ArrayDisplay($aIE) AutoItSetOption("WinTitleMatchMode", 2) ;Sets the searching options for WinClose to search the windows title (set to find X anywhere in string) ; Checks the array $aIE populated from the first above While statement agasint the $blocked array (block list entries) and closes IE if a match is found For $i = 1 To (UBound($aIE) - 1) For $i2 = 1 To (UBound($blocked) - 1) If StringInStr($aIE[$i],$blocked[$i2]) <> 0 Then SplashTextOn("Website Blocker","WEBSITE BLOCKED" & @CRLF & @CRLF & "Access to this site is prohibited!",400,100,-1,-1,33,"",15,900) ; creates a message on screen WinClose("[Class:IEFrame]") ;Closes any windows with any of the keywords contained within block list.txt in the windows title dim $call = 1 ; sets the $call variable to 1, this is used to see if _Check_Tab_Close function needs to be called EndIf Next Next if $call = 1 then ; Checks if $call variable is equal to 1 i.e. check if the _Check_Tab_Close function needs to be called call ("_Check_Tab_Close") ;Calls the function _Check_Tab_Close Endif EndFunc Func _Refresh_Block_List() _FileReadToArray($blocklistlocation,$blocked) ;Reads the block list text file to memory (array) $refresh_timer = 0 ;Sets the timer varaible back to 0 so that the re-counting process can start again EndFunc ;************************************************************************************************************************************************************************* ; Program Loop (Program in effect starts here) ;************************************************************************************************************************************************************************* While 1 ;creates an infinite loop If WinExists("[Class:IEFrame]") Then call ("_Win_Close") ;call the function _Win_Close Endif Sleep(1000) ;Pauses the program for 1 second - Used so it does not cause CPU to max out at 100% $refresh_timer +=1 ;Adds one to the value of the varaibale every time the while loop runs (runs every second) therefore the timer counts up in seconds If $refresh_timer = 1800 Then ; When the timer gets to 1800 seconds (30 minutes) then the function for refreshing the block list is called Call ("_Refresh_Block_List") ; Calls the function _Refresh_Block_List to refresh the block list file EndIf WEnd1 point -
delete duplicate lines from text file or array
dickjones007 reacted to Malkey for a topic
Without the sort version. #include<Array.au3> #include<File.au3> Local $aFile, $aArray _FileReadToArray(@ScriptDir & "\AnchorLinks.txt", $aFile) $aArray = _ArrayUnique($aFile, 1, 1) _ArrayDelete($aArray, 0) _ArrayDisplay($aArray)1 point -
delete duplicate lines from text file or array
dickjones007 reacted to BitByteBit for a topic
This should do the trick. You will however loose the order of your links, is that a problem? #include<array.au3> #include<file.au3> Dim $aFile _FileReadToArray(@DesktopDir & '\Codes2.txt', $aFile) _ArrayDelete($aFile, 0) _ArraySort($aFile) For $i = UBound($aFile) - 1 To 1 Step -1 If $aFile[$i] = $aFile[$i - 1] Then _ArrayDelete($aFile, $i) Next _ArrayDisplay($aFile)1 point