在网上看到一个字体删除程序:
今天试着做了一个,目前遇到一些困难,寻求帮助。
程序目的:
1/(已实现)寻找字体文件夹下所有 TTF 字体并形成树状列表;
2/(已实现)预设一些可以删除的字体,若存在,则默认选定;
3/(未实现)单击一个按钮,删除选定的字体。
现在的难题是,无法得到复选框后面的字体名,请高手帮忙完成这个代码。
GUIctrlRead 只能得到复选框的状态,而不能得到其后的文本。
#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <Array.au3>
$Debug_TV = False
Global $hItem, $hTreeView,$search
Global $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
FileChangeDir(@WindowsDir&"\fonts\")
dim $i=0,$size=0
_filelist("C:\Windows\Fonts\")
$main=GUICreate("Test - Newbie", 400, 300)
$hTreeView = GUICtrlCreateTreeView(5, 20, 250, 268, $iStyle, $WS_EX_CLIENTEDGE)
GUISetFont (9,400,1,"Tahoma")
$label=GUICtrlCreateLabel("左边默认选定的字体都是多余的英文字体,删除他们不会对您的系统造成影响。",270,20,120,60)
$button1=GUICtrlCreateButton("删除左边"&@CRLF&"选定的字体",270,90,100,50,$BS_MULTILINE)
GUISetState()
$search = FileFindFirstFile("*.ttf")
For $x = 1 To $i
$file = FileFindNextFile($search)
If $file <> "" Then
$filesize=Round(FileGetSize(@WindowsDir&"\fonts\"&$file)/1024,1)
$x= GUICtrlCreateTreeViewItem($file&" , "&$filesize&" KB",$hTreeView)
If $file= "ANTQUAB.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "ANTQUABI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "ANTQUAI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "ARIALN.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "ARIALNB.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "ARIALNBI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "ARIALNI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "BKANT.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "BOOKOS.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "BOOKOSB.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "BOOKOSBI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "BOOKOSI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "BSSYM7.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CALIBRI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CALIBRIB.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CALIBRII.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CALIBRIZ.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CAMBRIA.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CAMBRIAB.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CAMBRIAI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CAMBRIAZ.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CANDARA.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CANDARAB.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CANDARAI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CANDARAZ.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CENTURY.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CONSOLA.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CONSOLAB.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CONSOLAI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CONSOLAZ.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CONSTAN.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CONSTANB.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CONSTANI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CONSTANZ.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CORBEL.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CORBELB.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CORBELI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "CORBELZ.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "GARA.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "GARABD.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "GARAIT.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "georgia.ttf" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "georgiab.ttf" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "georgiai.ttf" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "georgiaz.ttf" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "GOTHIC.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "GOTHICB.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "GOTHICBI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "GOTHICI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "MSMINCHO.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "MTCORSVA.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "REFSAN.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "REFSPCL.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "SEGOEUI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "SEGOEUIB.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "SEGOEUII.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "SEGOEUIZ.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "SIMLI.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "SIMYOU.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "WINGDNG2.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
If $file= "WINGDNG3.TTF" Then
GUICtrlSetState($x,$gui_Checked)
EndIf
EndIf
Next
FileClose($search)
;WinSetOnTop($main,"",1)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd
Func _filelist($searchdir) ;统计文件个数
$search = FileFindFirstFile($searchdir & "*.ttf")
If $search = -1 Then return -1 ;;;;如果找不到,返回值 -1
While 1
$file = FileFindNextFile($search) ;;;查找下一个文件
If @error Then ;;;如果找不到文件
FileClose($search) ;;;则关闭此句柄
return ;;返回
EndIf
$i=$i+1
WEnd
EndFunc
[ 本帖最后由 新手上路 于 2008-12-13 21:20 编辑 ] |