 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Opie
Joined: 02 Nov 2009 Posts: 101
|
Posted: Tue Mar 09, 2010 8:55 am Post subject: Hide Drives from My Computer in Windows 7, Vista or XP |
|
|
Something I threw together after I bought a SD card reader for dedicated ReadyBoost use in Windows 7-- I didn't want to see all the unused drives in My Computer, so this little util allows you to show or hide drives from view
sloppy code but it works
| Code: |
#NoEnv
#SingleInstance Force
menu tray, noicon
SetWorkingDir %A_ScriptDir%
alph := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alph_back := "ZYXWVUTSRQPONMLKJIHGFEDCBA"
Regread cur_nodrives, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoDrives
all_drives := cur_nodrives ? Bin(cur_nodrives) : "00000000"
gui font, s9 w400
gui add, text, x20 y13 , Check to show drive - Uncheck to hide:
xp := 30, yp = 40
loop parse, alph
{
gui add, groupbox, % "x" xp-10 " y" yp-7 " w" 60 " h" 70
gui add, picture, % "x" xp " y" yp+5 " vpic" a_loopfield " Icon9", C:\WINDOWS\system32\SHELL32.dll
gui font, s23 w700
gui add, text, % " cred x" xp+5 " y" yp+3 " vcrossout" a_loopfield " backgroundtrans", X
gui, font, s9 w400
guicontrol hide, crossout%a_loopfield%
if ( substr(all_drives,0,1) == 1 )
{
%a_loopfield% := 0
guicontrol show, crossout%a_loopfield%
}
else %a_loopfield% := 1
stringtrimright all_drives, all_drives, 1
gui add, checkbox, % "x" xp + 5 " y" yp+40 " gchanged v" a_loopfield " checked" %a_loopfield%,% " " a_loopfield ":" ;%
xp := xp + 60
if ( xp >= 400 )
yp := yp + 65, xp = 30
}
gui add, button, % "y" yp+40 " x" 360 " w85 h25 gapply", Apply ;%
gui show, w460, Show Drive Letters
return
changed:
gui submit, nohide
guicontrol hide, crossout%a_guicontrol%
if ( %a_guicontrol% == 0 )
guicontrol show, crossout%a_guicontrol%
new =
loop parse, alph_back
{
if ( %a_loopfield% == 1 )
new .= "0"
else
new .= "1"
}
SetFormat, Integer, H
new := Dec(new)
SetFormat, Integer, D
new := substr(new,3)
return
apply:
; using reg file because I was having issues with RegWrite not actually writing values on Win7 machine ...
; ... I think it has something to do with Administrative rights
fileappend,
(
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDrives"=dword:%new%
),reg.reg
run regedit.exe /s reg.reg
sleep 250
while ( winexist("Registry Editor ahk_class #32770") )
sleep 250
process close, explorer.exe
sleep 350
run explorer.exe
filedelete reg.reg
return
GuiClose:
exitapp
Bin(x) ; thanks to infogulch
{
while x
r:=1&x r,x>>=1
return r
}
Dec(x)
{
b:=StrLen(x),r:=0
loop,parse,x
r|=A_LoopField<<--b
return r
}
|
Last edited by Opie on Tue Mar 16, 2010 9:59 pm; edited 4 times in total |
|
| Back to top |
|
 |
Gauss
Joined: 10 Sep 2009 Posts: 203
|
Posted: Thu Mar 11, 2010 4:16 pm Post subject: |
|
|
Very handy script
But it shows a whole list of letters even those that don't exist (not used), would be nice if you can make it detect that and show whats used. |
|
| Back to top |
|
 |
Opie
Joined: 02 Nov 2009 Posts: 101
|
Posted: Fri Mar 12, 2010 6:39 am Post subject: |
|
|
| Gauss wrote: | Very handy script
But it shows a whole list of letters even those that don't exist (not used), would be nice if you can make it detect that and show whats used. |
I added it to the script -- thanks for the idea  |
|
| Back to top |
|
 |
Gauss
Joined: 10 Sep 2009 Posts: 203
|
Posted: Fri Mar 12, 2010 9:34 am Post subject: |
|
|
One last bug I think, the apply button is on top of the last drive letter  |
|
| Back to top |
|
 |
Opie
Joined: 02 Nov 2009 Posts: 101
|
Posted: Sun Mar 14, 2010 7:57 am Post subject: |
|
|
fixed?
i changed back to all drives as well |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Mar 14, 2010 9:08 am Post subject: |
|
|
| Thanks nice! just a small thing ,if you abandon the registry change it will still kill explorer. |
|
| Back to top |
|
 |
Gauss
Joined: 10 Sep 2009 Posts: 203
|
Posted: Sun Mar 14, 2010 9:22 am Post subject: |
|
|
I think you made it show all letters again, I edited a little part of your second post to fix button position, works, just one thing, how can you do this without windows crying messages?
| Code: |
#NoEnv
#SingleInstance Force
menu tray, noicon
SetWorkingDir %A_ScriptDir%
DriveGet alph, List
a_num := strlen(alph)
while ( a_num )
{
alph_back .= substr(alph,a_num,1)
a_num--
}
Regread cur_nodrives, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoDrives
all_drives := cur_nodrives ? Bin(cur_nodrives) : "00000000"
gui font, s9 w400
gui add, text, x20 y13 , Check to show drive - Uncheck to hide:
xp := 30, yp = 40
loop parse, alph
{
gui add, groupbox, % "x" xp-10 " y" yp-7 " w" 60 " h" 70
gui add, picture, % "x" xp " y" yp+5 " vpic" a_loopfield " Icon9", C:\WINDOWS\system32\SHELL32.dll
gui font, s23 w700
gui add, text, % " cred x" xp+5 " y" yp+3 " vcrossout" a_loopfield " backgroundtrans", X
gui, font, s9 w400
guicontrol hide, crossout%a_loopfield%
if ( substr(all_drives,0,1) == 1 )
{
%a_loopfield% := 0
guicontrol show, crossout%a_loopfield%
}
else %a_loopfield% := 1
gui add, checkbox, % "x" xp + 5 " y" yp+40 " gchanged v" a_loopfield " checked" %a_loopfield%,% " " a_loopfield ":" ;%
xp := xp + 60
if ( xp >= 400 )
yp := yp + 65, xp = 30
stringtrimright all_drives, all_drives, 1
}
gui add, button, % "y" yp+80 " x" 370 " w85 h25 gapply", Apply ;%
gui show, w460, Show Drive Letters
return
changed:
gui submit, nohide
guicontrol hide, crossout%a_guicontrol%
if ( %a_guicontrol% == 0 )
guicontrol show, crossout%a_guicontrol%
new =
loop parse, alph_back
{
if ( %a_loopfield% == 1 )
new .= "0"
else
new .= "1"
}
SetFormat, Integer, H
new := Dec(new)
SetFormat, Integer, D
new := substr(new,3)
return
apply:
; using reg file because I was having issues with RegWrite not actually writing values on Win7 machine ...
; ... I think it has something to do with Administrative rights
fileappend,
(
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDrives"=dword:%new%
),reg.reg
run reg.reg
sleep 250
while ( winexist("Registry Editor ahk_class #32770") )
sleep 250
process close, explorer.exe ; kill explorer to show immediate changes - xp/vista/win7 should restart it
sleep 350
filedelete reg.reg
return
GuiClose:
exitapp
Bin(x) ; thanks to infogulch
{
while x
r:=1&x r,x>>=1
return r
}
Dec(x)
{
b:=StrLen(x),r:=0
loop,parse,x
r|=A_LoopField<<--b
return r
}
|
|
|
| Back to top |
|
 |
emmanuel d
Joined: 29 Jan 2009 Posts: 436 Location: Belgium
|
Posted: Mon Mar 15, 2010 9:10 pm Post subject: |
|
|
No regedit msg:
| Code: | #NoEnv
#SingleInstance Force
menu tray, noicon
SetWorkingDir %A_ScriptDir%
DriveGet alph, List
a_num := strlen(alph)
while ( a_num )
{
alph_back .= substr(alph,a_num,1)
a_num--
}
Regread cur_nodrives, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoDrives
all_drives := cur_nodrives ? Bin(cur_nodrives) : "00000000"
gui font, s9 w400
gui add, text, x20 y13 , Check to show drive - Uncheck to hide:
xp := 30, yp = 40
loop parse, alph
{
gui add, groupbox, % "x" xp-10 " y" yp-7 " w" 60 " h" 70
gui add, picture, % "x" xp " y" yp+5 " vpic" a_loopfield " Icon9", C:\WINDOWS\system32\SHELL32.dll
gui font, s23 w700
gui add, text, % " cred x" xp+5 " y" yp+3 " vcrossout" a_loopfield " backgroundtrans", X
gui, font, s9 w400
guicontrol hide, crossout%a_loopfield%
if ( substr(all_drives,0,1) == 1 )
{
%a_loopfield% := 0
guicontrol show, crossout%a_loopfield%
}
else %a_loopfield% := 1
gui add, checkbox, % "x" xp + 5 " y" yp+40 " gchanged v" a_loopfield " checked" %a_loopfield%,% " " a_loopfield ":" ;%
xp := xp + 60
if ( xp >= 400 )
yp := yp + 65, xp = 30
stringtrimright all_drives, all_drives, 1
}
gui add, button, % "y" yp+80 " x" 370 " w85 h25 gapply", Apply ;%
gui show, w460, Show Drive Letters
return
changed:
gui submit, nohide
guicontrol hide, crossout%a_guicontrol%
if ( %a_guicontrol% == 0 )
guicontrol show, crossout%a_guicontrol%
new =
loop parse, alph_back
{
if ( %a_loopfield% == 1 )
new .= "0"
else
new .= "1"
}
SetFormat, Integer, H
new := Dec(new)
SetFormat, Integer, D
new := substr(new,3)
return
apply:
; using reg file because I was having issues with RegWrite not actually writing values on Win7 machine ...
; ... I think it has something to do with Administrative rights
fileappend,
(
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDrives"=dword:%new%
),reg.reg
run,regedit.exe /s reg.reg ; Run regedit with silent swich
sleep 250
while ( winexist("Registry Editor ahk_class #32770") )
sleep 250
process close, explorer.exe ; kill explorer to show immediate changes - xp/vista/win7 should restart it
sleep 350
filedelete reg.reg
return
GuiClose:
exitapp
Bin(x) ; thanks to infogulch
{
while x
r:=1&x r,x>>=1
return r
}
Dec(x)
{
b:=StrLen(x),r:=0
loop,parse,x
r|=A_LoopField<<--b
return r
} |
_________________ Stopwatch
emdkplayer
http://www.autohotkey.com/forum/viewtopic.php?p=306819
the code i post falls under the:
WTFYW license
, wich meens its free to use |
|
| Back to top |
|
 |
emmanuel d
Joined: 29 Jan 2009 Posts: 436 Location: Belgium
|
Posted: Mon Mar 15, 2010 10:18 pm Post subject: |
|
|
For those that do want to try a regwrite(in xp works fine): | Code: | #NoEnv
#SingleInstance Force
menu tray, noicon
SetWorkingDir %A_ScriptDir%
DriveGet alph, List
a_num := strlen(alph)
while ( a_num )
{
alph_back .= substr(alph,a_num,1)
a_num--
}
Regread cur_nodrives, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoDrives
all_drives := cur_nodrives ? Bin(cur_nodrives) : "00000000"
gui font, s9 w400
gui add, text, x20 y13 , Check to show drive - Uncheck to hide:
xp := 30, yp = 40
loop parse, alph
{
gui add, groupbox, % "x" xp-10 " y" yp-7 " w" 60 " h" 70
gui add, picture, % "x" xp " y" yp+5 " vpic" a_loopfield " Icon9", C:\WINDOWS\system32\SHELL32.dll
gui font, s23 w700
gui add, text, % " cred x" xp+5 " y" yp+3 " vcrossout" a_loopfield " backgroundtrans", X
gui, font, s9 w400
guicontrol hide, crossout%a_loopfield%
if ( substr(all_drives,0,1) == 1 )
{
%a_loopfield% := 0
guicontrol show, crossout%a_loopfield%
}
else %a_loopfield% := 1
gui add, checkbox, % "x" xp + 5 " y" yp+40 " gchanged v" a_loopfield " checked" %a_loopfield%,% " " a_loopfield ":" ;%
xp := xp + 60
if ( xp >= 400 )
yp := yp + 65, xp = 30
stringtrimright all_drives, all_drives, 1
}
gui add, button, % "y" yp+80 " x" 370 " w85 h25 gapply", Apply ;%
gui show, w460, Show Drive Letters
return
changed:
gui submit, nohide
guicontrol hide, crossout%a_guicontrol%
if ( %a_guicontrol% == 0 )
guicontrol show, crossout%a_guicontrol%
new =
loop parse, alph_back
{
if ( %a_loopfield% == 1 )
new .= "0"
else
new .= "1"
}
SetFormat, Integer, H
new := Dec(new)
SetFormat, Integer, D
new := substr(new,3)
return
apply:
; using reg file because I was having issues with RegWrite not actually writing values on Win7 machine ...
; ... I think it has something to do with Administrative rights
RegWrite,REG_DWORD,HKCU,Software\Microsoft\Windows\CurrentVersion\Policies\Explorer,NoDrives,%new%
process close, explorer.exe ; kill explorer to show immediate changes - xp/vista/win7 should restart it
return
GuiClose:
exitapp
Bin(x) ; thanks to infogulch
{
while x
r:=1&x r,x>>=1
return r
}
Dec(x)
{
b:=StrLen(x),r:=0
loop,parse,x
r|=A_LoopField<<--b
return r
} | restarting explorer has no effect in xp for hiding the drive you might need to log off _________________ Stopwatch
emdkplayer
http://www.autohotkey.com/forum/viewtopic.php?p=306819
the code i post falls under the:
WTFYW license
, wich meens its free to use |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Mar 16, 2010 2:32 am Post subject: |
|
|
| emmanuel d wrote: | No regedit msg:
| Code: | #NoEnv
#SingleInstance Force
menu tray, noicon
SetWorkingDir %A_ScriptDir%
DriveGet alph, List
a_num := strlen(alph)
while ( a_num )
{
alph_back .= substr(alph,a_num,1)
a_num--
}
Regread cur_nodrives, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoDrives
all_drives := cur_nodrives ? Bin(cur_nodrives) : "00000000"
gui font, s9 w400
gui add, text, x20 y13 , Check to show drive - Uncheck to hide:
xp := 30, yp = 40
loop parse, alph
{
gui add, groupbox, % "x" xp-10 " y" yp-7 " w" 60 " h" 70
gui add, picture, % "x" xp " y" yp+5 " vpic" a_loopfield " Icon9", C:\WINDOWS\system32\SHELL32.dll
gui font, s23 w700
gui add, text, % " cred x" xp+5 " y" yp+3 " vcrossout" a_loopfield " backgroundtrans", X
gui, font, s9 w400
guicontrol hide, crossout%a_loopfield%
if ( substr(all_drives,0,1) == 1 )
{
%a_loopfield% := 0
guicontrol show, crossout%a_loopfield%
}
else %a_loopfield% := 1
gui add, checkbox, % "x" xp + 5 " y" yp+40 " gchanged v" a_loopfield " checked" %a_loopfield%,% " " a_loopfield ":" ;%
xp := xp + 60
if ( xp >= 400 )
yp := yp + 65, xp = 30
stringtrimright all_drives, all_drives, 1
}
gui add, button, % "y" yp+80 " x" 370 " w85 h25 gapply", Apply ;%
gui show, w460, Show Drive Letters
return
changed:
gui submit, nohide
guicontrol hide, crossout%a_guicontrol%
if ( %a_guicontrol% == 0 )
guicontrol show, crossout%a_guicontrol%
new =
loop parse, alph_back
{
if ( %a_loopfield% == 1 )
new .= "0"
else
new .= "1"
}
SetFormat, Integer, H
new := Dec(new)
SetFormat, Integer, D
new := substr(new,3)
return
apply:
; using reg file because I was having issues with RegWrite not actually writing values on Win7 machine ...
; ... I think it has something to do with Administrative rights
fileappend,
(
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDrives"=dword:%new%
),reg.reg
run,regedit.exe /s reg.reg ; Run regedit with silent swich
sleep 250
while ( winexist("Registry Editor ahk_class #32770") )
sleep 250
process close, explorer.exe ; kill explorer to show immediate changes - xp/vista/win7 should restart it
sleep 350
filedelete reg.reg
return
GuiClose:
exitapp
Bin(x) ; thanks to infogulch
{
while x
r:=1&x r,x>>=1
return r
}
Dec(x)
{
b:=StrLen(x),r:=0
loop,parse,x
r|=A_LoopField<<--b
return r
} |
|
thanks for that
btw...
if you use the code with the drives detected, the drives wont be properly hidden. When rewriting the binary reg data (10001001001) it needs to be the whole alphabet -- thats why i reverted it back to "ABCDEFGHIJ.."
That could be the reason why you dont see the changes immediately... |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|