Floppy Posted December 24, 2008 Share Posted December 24, 2008 (edited) Hello, sorry for my english... How can I list all fonts installate on the system in a combo-box? I'm tried to read the subkeys of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts with the script: $reg_index=0 Do $reg_index=$reg_index+1 $reg_read=RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts",$reg_index) GUICtrlSetData($font,$reg_read&"|") Until @error<>0 But, I get an error message ("Available data no longer available", or something like this) in the combo-box, instead of the fonts. Can anyone help me, please? Thanks in advance... Edited December 24, 2008 by FSoft Link to comment Share on other sites More sharing options...
Zedna Posted December 24, 2008 Share Posted December 24, 2008 Maybe $reg_read_all = "" $reg_index=0 Do $reg_index=$reg_index+1 $reg_read=RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts",$reg_index) $reg_read_all &= $reg_read & "|" Until @error<>0 GUICtrlSetData($font,$reg_read_all) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Floppy Posted December 24, 2008 Author Share Posted December 24, 2008 Doesn't work.... Link to comment Share on other sites More sharing options...
Kip Posted December 24, 2008 Share Posted December 24, 2008 (edited) Use RegEnumVal instead of RegEnumKey GUICreate("sdsd") $font = GUICtrlCreateCombo("",10,10,150,23) GUISetState() $reg_read_all = "" $reg_index=0 Do $reg_index += 1 $reg_read = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts",$reg_index) $iError = @error If Not $iError Then $reg_read_all &= $reg_read & "|" Until $iError<>0 GUICtrlSetData($font,$reg_read_all) While 1 WEnd Edited December 24, 2008 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Floppy Posted December 25, 2008 Author Share Posted December 25, 2008 (edited) Thanks, the script works...but the fonts are showed with the suffix (True Type): for example "Arial Black (True Type)". For fix this I have add the command: $reg_read=StringReplace($reg_read,"(True Type)","") ..but doesn't work... Another question: How can I show a preview of the fonts in the combo? Edited December 25, 2008 by FSoft Link to comment Share on other sites More sharing options...
Kip Posted December 25, 2008 Share Posted December 25, 2008 (edited) GUICreate("sdsd") $font = GUICtrlCreateCombo("",10,10,150,23) GUISetState() $reg_read_all = "" $reg_index=0 Do $reg_index += 1 $reg_read = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts",$reg_index) $iError = @error If Not $iError Then $iPos = StringInStr($reg_read," (") $sFontName = $reg_read If $iPos Then $sFontName = StringLeft($reg_read,$iPos-1) $reg_read_all &= $sFontName & "|" EndIf Until $iError<>0 GUICtrlSetData($font,$reg_read_all) While 1 WEnd Another question: How can I show a preview of the fonts in the combo?You can't do that with a regular combobox. Edited December 25, 2008 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
rasim Posted December 25, 2008 Share Posted December 25, 2008 @FSoftExample:#include <GuiConstantsEx.au3> Dim $sRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" GUICreate("Test", 400, 100) $cCombo_Font = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData($cCombo_Font, _RegEnumVal($sRegKey)) $cLabel = GUICtrlCreateLabel("Font preview", 230, 10, 155, 20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $cCombo_Font GUICtrlSetFont($cLabel, 10, Default, Default, GUICtrlRead($cCombo_Font)) EndSwitch WEnd Func _RegEnumVal($sKey) Local $i = 1, $sVal, $sResult While 1 $sVal = RegEnumVal($sKey, $i) If @error Then ExitLoop $i += 1 $sResult &= $sVal & "|" WEnd Return StringRegExpReplace($sResult, " \(.*?\)", "") EndFunc ;==>_RegEnumVal Link to comment Share on other sites More sharing options...
Floppy Posted December 25, 2008 Author Share Posted December 25, 2008 Thanks, it works...but now there's another problem: The fonts aren't sorted alphabetically (is this a correct english term? ). How can I sort it? thank you! Link to comment Share on other sites More sharing options...
Developers Jos Posted December 25, 2008 Developers Share Posted December 25, 2008 change this line: $cCombo_Font = GUICtrlCreateCombo("", 10, 10, 200, 20, Bitor($CBS_SORT,$CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_VSCROLL) Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Floppy Posted December 25, 2008 Author Share Posted December 25, 2008 thank you Link to comment Share on other sites More sharing options...
amin84 Posted July 19, 2012 Share Posted July 19, 2012 Tnx for this. Exactly what I wanted. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now