#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>
#include <file.au3>
#include <array.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("U盘美化精灵", 353, 268)
Global $PageControl1 = GUICtrlCreateTab(10, 50, 335, 210)
;第一页
Global $TabSheet1 = GUICtrlCreateTabItem("设置")
GUICtrlSetState(-1,$GUI_SHOW)
Global $Group1 = GUICtrlCreateGroup("", 21, 74, 310, 146);分组框
Global $Label1 = GUICtrlCreateLabel("选择U盘", 39, 98, 50, 18)
Global $Input1 = GUICtrlCreateInput("", 92, 94, 155, 22)
Global $Button1 = GUICtrlCreateButton("选择", 258, 93, 55, 23)
Global $Label2 = GUICtrlCreateLabel("U盘图标", 39, 127, 50, 18)
Global $Input2 = GUICtrlCreateInput("", 92, 123, 155, 22)
Global $Button2 = GUICtrlCreateButton("选择", 258, 123, 55, 23)
Global $Label3 = GUICtrlCreateLabel("U盘背景", 39, 156, 50, 18)
Global $Input3 = GUICtrlCreateInput("", 92, 152, 155, 22)
Global $Button3 = GUICtrlCreateButton("选择", 258, 152, 55, 23)
Global $Label4 = GUICtrlCreateLabel("文件名颜色", 39, 186, 60, 18)
Global $Input4 = GUICtrlCreateInput("", 102, 182, 145, 22)
Global $Button4 = GUICtrlCreateButton("选择", 258, 182, 55, 23)
Global $Button5 = GUICtrlCreateButton("U盘美化", 136, 228, 70, 23)
;第二页
Global $TabSheet2 = GUICtrlCreateTabItem("帮助")
Global $Group2 = GUICtrlCreateGroup("", 21, 74, 310, 172);分组框
Global $Label2_1 = GUICtrlCreateLabel(" "& @LF & "美化步骤:"& @LF & "1. 美化前需先选择要美化的U盘盘符"& @LF & "2. 选择U盘美化项目"& @LF & "3. 点击“U盘美化”进行美化,完成后出现完成提示。"& @LF & ""& @LF & "注意事项:"& @LF & "1. 图标必须为ICO格式"& @LF & "2. 背景图片必须为JPG格式"& @LF & "3. 图标、背景可以自定义,但需要转换为规定的格式。", 39, 80, 290, 150)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
;第三页
Global $TabSheet3 = GUICtrlCreateTabItem("关于")
Global $Group3 = GUICtrlCreateGroup("", 21, 74, 310, 172) ;分组框
Global $Group4 = GUICtrlCreateGroup("", 100, 90, 160, 60) ;分组框
Global $Label1 = GUICtrlCreateLabel("U盘美化精灵", 122, 98, 130, 30)
GUICtrlSetFont(-1, 15, 400, 0, "Arial")
GUICtrlSetColor(-1, 0x000080)
Global $Label1 = GUICtrlCreateLabel("版本:V1.0 ", 150, 132, 100, 18)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Local $xuanze = FileSelectFolder("请选择U盘盘符","")
GUICtrlSetData($Input1, $xuanze)
Case $Button2
Dim $szDrive, $szDir, $szFName, $szExt
Local $xuanzetubiao = FileOpenDialog("请选择U盘图标", @ScriptDir & "\tubiao", "图像文件 (*.ico)", 1 ) ;读取图标
Local $TestPath = _PathSplit($xuanzetubiao, $szDrive, $szDir, $szFName, $szExt);拆分文件路径和文件名
GUICtrlSetData($Input2, $szFName & $szExt )
Case $Button3
Dim $szDrive, $szDir, $szFName, $szExt
Local $xuanzebeijing = FileOpenDialog("请选择U盘背景图片", @ScriptDir & "\beijing", "图像文件 (*.jpg)", 1 )
Local $TestPath = _PathSplit($xuanzebeijing, $szDrive, $szDir, $szFName, $szExt);拆分文件路径和文件名
GUICtrlSetData($Input3, $szFName & $szExt )
Case $Button4
Dim $iReturnType,$iColorRef,$iRefType,$hWndOwnder
Local $xuanzeyanse = _ChooseColor($iReturnType = 0 , $iColorRef = 0 , $iRefType = 0 , $hWndOwnder = 0);打开颜色选择框
GUICtrlSetData($Input4, $xuanzeyanse);读取颜色,并写入到$Input5显示框
Case $Button5;执行美化
$lujing = GUICtrlRead($input1)
$tubiao = GUICtrlRead($input2)
$beijing = GUICtrlRead($input3)
$yanse = GUICtrlRead($input4)
If $tubiao <> "" Then
IniWrite("" & $lujing & "\autorun.inf", "autorun", "ICON" , $tubiao) ;将参数写入到配置文件
FileCopy ($tubiao, $lujing , 0 ) ;移动文件到U盘
FileSetAttrib("" & $lujing & "\autorun.inf", "+RHA" , 0)
FileSetAttrib($lujing & "" & $tubiao, "+RHA" , 0)
EndIf
If $beijing <> "" Then
IniWrite("" & $lujing & "\desktop.ini", "ExtShellFolderViews", "{BE098140-A513-11D0-A3A4-00C04FD706EC}", "{BE098140-A513-11D0-A3A4-00C04FD706EC}" ) ;将参数写入到配置文件
IniWrite("" & $lujing & "\desktop.ini", "{BE098140-A513-11D0-A3A4-00C04FD706EC}", "Attributes", 1) ;将参数写入到配置文件
IniWrite("" & $lujing & "\desktop.ini", "{BE098140-A513-11D0-A3A4-00C04FD706EC}", "IconArea_Image" , $beijing ) ;将参数写入到配置文件
FileCopy ( $beijing, $lujing , 0 ) ;移动文件到U盘
FileSetAttrib("" & $lujing & "\desktop.ini", "+HA" , 0)
FileSetAttrib( $lujing & "" & $beijing, "+HA" , 0)
EndIf
If $yanse <> "" Then
IniWrite("" & $lujing & "\desktop.ini", "ExtShellFolderViews", "{BE098140-A513-11D0-A3A4-00C04FD706EC}", "{BE098140-A513-11D0-A3A4-00C04FD706EC}" ) ;将参数写入到配置文件
IniWrite("" & $lujing & "\desktop.ini", "{BE098140-A513-11D0-A3A4-00C04FD706EC}", "IconArea_Text" , $yanse ) ;将参数写入到配置文件
FileSetAttrib("" & $lujing & "\desktop.ini", "+HA" , 0)
EndIf
MsgBox(0, "提示", "已完成U盘美化!")
EndSwitch
WEnd