Advertisement
Najeebsk

DRIVE-ICON-CHANGE.au3

Nov 8th, 2022
2,547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 5.58 KB | None | 0 0
  1. #include <ButtonConstants.au3>
  2. #include <ComboConstants.au3>
  3. #include <Constants.au3>
  4. #include <EditConstants.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <Misc.au3>
  7. #include <StaticConstants.au3>
  8. #include <WindowsConstants.au3>
  9. #include <TabConstants.au3>
  10.  
  11.  
  12. If _Singleton("Najeeb Drive Icon Changer", 1) = 0 Then
  13.     MsgBox(16, "Warning", "Najeeb Drive Icon Changer is already running.", 5)
  14.     Exit
  15. EndIf
  16.  
  17. #Region Main GUI
  18. DirCreate(@AppDataDir & "\Data\Najeeb Drive Icon Changer\Icons")
  19. FileInstall("MainIcon.ico", @AppDataDir & "\Data\Najeeb Drive Icon Changer\Icons\MainIcon.ico", 1)
  20. DirCreate(@AppDataDir & "\Data\Najeeb Drive Icon Changer\Images")
  21. $AppTitle = "Najeeb Drive Icon Changer"
  22. $YS_DIcon_Changer = GUICreate($AppTitle, 349, 285, -1, -1, $WS_SYSMENU)
  23. ;About button
  24. $btnAbout = GUICtrlCreateButton("!", 320, 0, 20, 20)
  25. GUICtrlSetCursor(-1, 0)
  26. GUICtrlSetTip(-1, "About...", "", $TIP_NOICON, $TIP_BALLOON)
  27.  
  28. ; Group
  29. $Group1 = GUICtrlCreateGroup("", 8, 16, 329, 177)
  30. ;Label Chose Icon
  31. $LblIconChose = GUICtrlCreateLabel("Chose Icon", 24, 26, 58, 17)
  32. ;Input Icon Location
  33. $NputIconLocation = GUICtrlCreateInput("", 24, 46, 241, 21)
  34. ;Browse Icon Button
  35. $btnIconBrowse = GUICtrlCreateButton("...", 272, 44, 57, 25)
  36. GUICtrlSetFont(-1, 12, 800, 0, "Arial")
  37. GUICtrlSetCursor(-1, 0)
  38. GUICtrlSetTip(-1, "Browse Icon...", "", $TIP_NOICON, $TIP_BALLOON)
  39. ;Label Chose Drives
  40. $LblChoseDrive = GUICtrlCreateLabel("Chose Drive", 25, 79, 62, 17)
  41. ;Drives Latters ComboBox
  42. Local $CboDLatter = GUICtrlCreateCombo("", 24, 104, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
  43. GUICtrlCreateGroup("", -99, -99, 1, 1)
  44. GUICtrlSetData($CboDLatter, "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "D")
  45.  
  46. ;IconImage
  47. $IconPic = GUICtrlCreateIcon(@AppDataDir & "\Data\Najeeb Drive Icon Changer\Icons\MainIcon.ico", 0, 230, 90, 90, 90)
  48.  
  49. ; Restore  Default Button
  50. $btnRestore = GUICtrlCreateButton("Restore Default", 16, 208, 105, 41)
  51. GUICtrlSetCursor(-1, 0)
  52. GUICtrlSetTip(-1, "Restore Default Icon...", "", $TIP_NOICON, $TIP_BALLOON)
  53.  
  54. ; Change Drive Icon Button
  55. $btnChange = GUICtrlCreateButton("Change Drive Icon", 230, 208, 105, 41)
  56. GUICtrlSetCursor(-1, 0)
  57. GUICtrlSetTip(-1, "Change Icon...", "", $TIP_NOICON, $TIP_BALLOON)
  58.  
  59. GUISetState(@SW_SHOW)
  60. #EndRegion
  61.  
  62. While 1
  63.     $nMsg = GUIGetMsg()
  64.     Switch $nMsg
  65.         Case $GUI_EVENT_CLOSE
  66.             Exit
  67.         Case $btnIconBrowse
  68.             $icoopen = FileOpenDialog("Choose an icon file", @DesktopDir, "Icon (*.ico)", 1)
  69.             GUICtrlSetData($NputIconLocation, $icoopen)
  70.             GUICtrlCreateIcon($icoopen, 0,230, 90, 90, 90)
  71.             GUICtrlCreateIcon(@AppDataDir & "\Data\Najeeb Drive Icon Changer\Icons\MainIcon.ico", 0, 230, 90, 90, 90)
  72.         Case $btnChange
  73.             $IconPath = GUICtrlRead($NputIconLocation)
  74.             If $IconPath = "" Then
  75.                 MsgBox(16, "Icon is not found ..", "Please choose a icon ..")
  76.             Else
  77.                 $DriveLatter = GUICtrlRead($CboDLatter,0)
  78.                 FileDelete(@AppDataDir & "\Data\Najeeb Drive Icon Changer\Icons\" & $DriveLatter & ".ico")
  79.                 RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\"& $DriveLatter)
  80.                 Sleep(200)
  81.                 $BackupIcon = @AppDataDir & "\Data\Najeeb Drive Icon Changer\Icons\" & $DriveLatter & ".ico"
  82.                 RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\"& $DriveLatter & "\DefaultIcon", "", "REG_SZ", $IconPath)
  83.                 MsgBox(64, "Complete", "Drive Icon is successfully changed. Thank for using my program.", 10)
  84.             EndIf
  85.         Case $btnRestore
  86.             $DriveLatter = GUICtrlRead($CboDLatter,0)
  87.             RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\"& $DriveLatter)
  88.             MsgBox(64, "Complete", "Drive Icon is now default Icon. Thank for using my program.", 10)
  89.         Case $btnAbout
  90.             _AboutGUI()
  91.     EndSwitch
  92. WEnd
  93.  
  94.  
  95. Func _AboutGUI()
  96.     GUISetState(@SW_DISABLE)
  97.     Local $Aboutdlg = GUICreate("About", 302, 195, -1, -1, $WS_SYSMENU, $WS_EX_TOPMOST)
  98.     GUISetBkColor(0xFFFFFF)
  99.     FileInstall("AboutIcon.ico", @AppDataDir & "\Data\Najeeb Drive Icon Changer\Icons\AbutIcon.ico")
  100.     FileInstall("N.jpg", @AppDataDir & "\DataNajeeb Drive Icon Changer\Images\N.jpg")
  101.     GUISetIcon(@AppDataDir & "\Data\Najeeb Drive Icon Changer\Icons\AbutIcon.ico")
  102.     $PicYawStar = GUICtrlCreatePic(@AppDataDir & "\Data\Najeeb Drive Icon Changer\Images\N.jpg", 8, 3, 55, 55)
  103.     $Label2 = GUICtrlCreateLabel("Najeeb Drive Icon Changer", 70, 8, 255, 23)
  104.     GUICtrlSetFont(-1, 12, 800, 0, "Leelawadee")
  105.     $Label3 = GUICtrlCreateLabel("Najeeb software Corporation  Â©2022", 152, 144, 145, 18)
  106.     GUICtrlSetFont(-1, 8, 400, 0, "Leelawadee")
  107.     $Label1 = GUICtrlCreateLabel("Version 2.0", 116, 32, 69, 19)
  108.     GUICtrlSetFont(-1, 10, 400, 0, "Leelawadee")
  109.     $Label6 = GUICtrlCreateLabel("Thank you for using my software. Send E-mail", 49, 96, 206, 18)
  110.     GUICtrlSetFont(-1, 8, 400, 0, "Leelawadee")
  111.     $Label7 = GUICtrlCreateLabel("to najeebshahkhan@gmail.com if you have any suggestion.", 49, 108, 208, 26)
  112.     GUICtrlSetFont(-1, 8, 400, 0, "Leelawadee")
  113.     GUISetState(@SW_SHOW)
  114.  
  115.     While 1
  116.         $nMsg = GUIGetMsg()
  117.         Switch $nMsg
  118.             Case $GUI_EVENT_CLOSE
  119.                 Local $Aboutdlg
  120.  
  121.                 WinActivate("Najeeb Drive Icon Changer")
  122.                 GUIDelete($Aboutdlg)
  123.                 GUISetState(@SW_ENABLE)
  124.                 ExitLoop
  125.         EndSwitch
  126.     WEnd
  127. EndFunc   ;==>_AboutGUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement