728x90

[참조]
https://ss64.com/nt/syntax-nodrives

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
NoDrives

#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
   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
}

 

NoDrives.ahk
0.00MB

 

728x90

'AutoHotKey' 카테고리의 다른 글

UrlDownloadToFile 폰트 적용 - 다운로드용  (0) 2023.09.30
[GUI] Checked groupbox  (0) 2023.09.17
[GUI] PING 테스트  (0) 2023.09.03
[GUI] IP on network interfaces  (0) 2023.09.01
[GUI] IP on network interfaces  (0) 2023.08.31

+ Recent posts