mrmacadamia Posted June 8, 2010 Share Posted June 8, 2010 I'm trying to create a script that could show and hide drive easily. It might be the same concept from this site but it just couldn't hide your drive automatically. http://www.wisdombay.com/hidedrive/index.php So far I created the script but couldn't figure it out how to add up each letter of the drive even I look the function of the site. It's javascript, so i don't know much about object thingy. anyway this is working code but still need a little work to do. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $Ini = @ScriptDir & "\restore.ini" Global $Sect = "Current" ;================ ;This is the drive letter with it values ;=============== ;A: 1, B: 2, C: 4, D: 8, E: 16, F: 32, G: 64, H: 128, I: 256, J: 512, K: 1024, L: 2048, M: 4096, N: 8192, O: 16384, P: 32768, Q: 65536, R: 131072, S: 262144, T: 524288, U: 1048576, V: 2097152, W: 4194304, X: 8388608, Y: 16777216, Z: 33554432, ALL: 67108863 $ChkBox = DriveGetDrive( "all" ) If NOT @error Then MsgBox(4096,"", "Found " & $ChkBox[0] & " drives") EndIf $hGui = GUICreate("", 400, 405) For $i = 1 To UBound($ChkBox) - 1 $ChkBox[$i] = GUICtrlCreateCheckbox($ChkBox[$i], 5, ($i * 20) + 5, 80, 15) Next GUISetState() Load() While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Save() Exit Case $ChkBox[1] To $ChkBox[UBound($ChkBox) - 1] Call(GUICtrlRead($Msg, 1)) EndSwitch WEnd Func Save() For $i = 1 To UBound($ChkBox) - 1 IniWrite($Ini, $Sect, GUICtrlRead($ChkBox[$i], 1), GUICtrlRead($ChkBox[$i])) Next $var = IniReadSection($Ini, $Sect) If @error Then Return Else For $j = 1 To $var[0][0] $Key = $var[$j][0] $NewValue = $var[$j][1] If $NewValue = 1 Then ;this is the place i supposed to have another function that could add up the value of each value of drives ConsoleWrite($Key & @CRLF) EndIf Next EndIf EndFunc Func Load() Local $aIRS If Not FileExists($Ini) Then Return $aIRS = IniReadSection($Ini, $Sect) If @error Then Return For $i = 1 To $aIRS[0][0] Local $Key = $aIRS[$i][0] Local $NewValue = $aIRS[$i][1] If $NewValue = 1 Then GUICtrlSetState($ChkBox[$i], 1) Call($aIRS[$i][0]) EndIf Next EndFunc ;==>Load Link to comment Share on other sites More sharing options...
rudi Posted June 8, 2010 Share Posted June 8, 2010 Hi.So, what's your question? At least I didn't get it Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 8, 2010 Share Posted June 8, 2010 If what you are trying to do is produce a bit map of selected drives: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> ;================ ;This is the drive letter with it values ;=============== ;A: Bit 0 -- Z: Bit 25, ALL: Bits 0 thru 25 Global $ChkBox, $iSelection = 0 Global $iGuiW, $iGuiH, $hGui, $idLabel Global $iMsg, $f_Checked, $sText $ChkBox = DriveGetDrive("all") If Not @error Then MsgBox(4096, "", "Found " & $ChkBox[0] & " drives") EndIf $iGuiW = 300 $iGuiH = 100 + (UBound($ChkBox) * 30) $hGui = GUICreate("", $iGuiW, $iGuiH) For $i = 1 To UBound($ChkBox) - 1 $ChkBox[$i] = GUICtrlCreateCheckbox($ChkBox[$i], 10, ($i * 20) + 10, 80, 20) Next $idLabel = GUICtrlCreateLabel("Selection = <NONE>", 10, $iGuiH - 30, $iGuiW - 20, 20, BitOr($GUI_SS_DEFAULT_LABEL, $SS_CENTER)) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $ChkBox[1] To $ChkBox[UBound($ChkBox) - 1] $f_Checked = ControlCommand($hGui, "", $iMsg, "IsChecked") $sText = ControlGetText($hGui, "", $iMsg) ConsoleWrite("ChkBx: $iMsg = " & $iMsg & "; Text = " & $sText & "; Checked = " & $f_Checked & @LF) $iMsg = Asc(StringUpper(StringLeft($sText, 1))) - 0x41 ; A=0, Z=25 If $f_Checked Then $iSelection = BitOR($iSelection, 2 ^ $iMsg) Else $iSelection = BitAND($iSelection, BitNot(2 ^ $iMsg)) EndIf If $iSelection Then ControlSetText($hGui, "", $idLabel, "Selection = " & $iSelection & " (0x" & Hex($iSelection) & ")") Else ControlSetText($hGui, "", $idLabel, "Selection = <NONE>") EndIf EndSwitch WEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
mrmacadamia Posted June 10, 2010 Author Share Posted June 10, 2010 (edited) I'm so sorry if I didn't make myself very clear. So, what i'm trying to do is: 1. Launch the script and read all the available drives. 2. All drives assigned with each checkbox. 3. Checked box allow to hide drive.(change the registry value) 3a. If multiple drives selected, e.g: a: and e: drives, it should 1 + 16 = 17. So, the registry should be in 17 value which is RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoDrives", "REG_DWORD", "17") Edited June 10, 2010 by mrmacadamia Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 10, 2010 Share Posted June 10, 2010 All I was attempting to demo was a better way to assemble the REG_DWORD value of bit mapped drive letters. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Gerald Posted October 17, 2010 Share Posted October 17, 2010 @ PsaltyDS thnks to you assemble the REG_DWORD value i will post my hide drive if i have done thanks man hmmm can you put the desperation of your code how its work thank you men Link to comment Share on other sites More sharing options...
wraithdu Posted May 16, 2011 Share Posted May 16, 2011 I could actually use a function like this, so I wrote one. Basic, does the job, doesn't deserve it's own thread, so it'll live here instead. _Main() Func _Main() Local $aDrives = StringSplit("abcdefghijklmnopqrstuvwxyz", "", 2) Local $aCtrls[26] Local $gui = GUICreate("Hide Drives", 190, 200, -1, -1, 0x80C80000) ; create checkboxes For $i = 0 To 25 $aCtrls[$i] = GUICtrlCreateCheckbox(StringUpper($aDrives[$i]), 5 + (Mod($i, 6) * 30), 5 + (30 * Int($i / 6))) Next ; set checkboxes Local $sKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" Local $val = RegRead($sKey, "NoDrives") If @error Then $val = 0 For $i = 0 To 25 If BitAND($val, 1) Then GUICtrlSetState($aCtrls[$i], 1) $val = BitShift($val, 1) Next Local $set = GUICtrlCreateButton("Set", 70, 165, 50) GUISetState() Local $msg While True $msg = GUIGetMsg() Switch $msg Case $set ; set value $val = 0 For $i = 0 To 25 If BitAND(GUICtrlRead($aCtrls[$i]), 1) Then $val += (2 ^ $i) Next RegWrite($sKey, "NoDrives", "REG_DWORD", $val) Case -3 ExitLoop EndSwitch WEnd EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now