Keyboard key symbols - display in Gui ListView (hotkey cheatsheet)

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
emp00
Posts: 165
Joined: 15 Apr 2023, 12:02

Keyboard key symbols - display in Gui ListView (hotkey cheatsheet)

Post by emp00 » 19 Aug 2023, 06:26

Dear Team, I'm using a simple "cheatsheet" Gui displaying my set of AHK hotkeys (see script below). Both keys and description are displayed with the Verdana font in a ListView reading the keys from a tab separated txt file. Screenshot 1 below shows how the result looks like.

Question: How can I display the hotkeys in the first column in a more compact format, preferably with slim keyboard symbols instead of bulky text?
Examples: a) like here in the forum with the "kbd"-tag e.g. Ctrl-Win-T b) even better see 2nd screenshot below. Thanks for your suggestions!

My cheatsheet script:

Code: Select all

+F1::	; Shift-F1 ---> Display Hotkey CheatSheet from tab separated file, two columns: HOTKEYS.txt
{
	myGui := Gui()
	myGui.BackColor := "0x06666" ; Green
	myGui.Title := "AHK MasterHotkeys CheatSheet"
	myGui.SetFont("s11", "Verdana")
	myGui.OnEvent("Close", GuiClose)
	ogcListViewNbCommandParametersDescription := myGui.Add("ListView", "r26 w1200 +Grid", ["Command                            ", "Description"])
	Loop Read, "HOTKEYS.txt"
	{
		var_ := StrSplit(A_LoopReadLine,A_TAB)
		ogcListViewNbCommandParametersDescription.Add("", var_[1], var_[2])
	}
	ogcButtonOK := myGui.Add("Button", "w1200 h30", "< &OK >")
	ogcButtonOK.OnEvent("Click", GuiClose)  ; Call GuiClose when clicked.
	myGui.Show()
	ogcButtonOK.Focus()

	GuiClose(*)
	{
		myGui.Destroy()
	}
}
Result how it currently looks:
Image

Example how I would like the keys to be displayed in the first column - preferably as slim keys instead of bulky text
Image

metallizer
Posts: 32
Joined: 13 Aug 2021, 13:34

Re: Keyboard key symbols - display in Gui ListView (hotkey cheatsheet)

Post by metallizer » 21 Aug 2023, 01:04

Instead of space in "Command " you can use ModifyCol. eg: ogcListViewNbCommandParametersDescription.ModifyCol(1, 300) where 1 is column number and 300 the width, in pixels.
about the icons in the list, I think you can experiment with this:

Code: Select all

        myGui := Gui()
        myGui.BackColor := "0x06666" ; Green
        myGui.Title := "AHK MasterHotkeys CheatSheet"
        myGui.SetFont("s11", "Verdana")
        myGui.OnEvent("Close", GuiClose)
        myGuiLV := myGui.Add("ListView", "r26 w1200 +Grid", ["Command", "Description"])
        ImageListID := IL_Create(10)  ; Create an ImageList to hold 10 small icons.
        myGuiLV.SetImageList(ImageListID)  ; Assign the above ImageList to the current ListView.
        Loop 10  ; Load the ImageList with a series of icons from the DLL.
            IL_Add(ImageListID, "shell32.dll", A_Index) 
        Loop Read, "HOTKEYS.txt"
        {
            var_ := StrSplit(A_LoopReadLine,A_TAB)
            myGuiLV.Add("", "Icon", var_[2])
        }
        myGuiLV.ModifyCol(1, 300)
        ogcButtonOK := myGui.Add("Button", "w1200 h30", "< &OK >")
        ogcButtonOK.OnEvent("Click", GuiClose)  ; Call GuiClose when clicked.
        myGui.Show()
        ogcButtonOK.Focus()
Or you use Unicode representations of modifier keys

ludamo
Posts: 44
Joined: 25 Mar 2015, 02:21

Re: Keyboard key symbols - display in Gui ListView (hotkey cheatsheet)

Post by ludamo » 21 Aug 2023, 03:31

Just a suggestion. You could look at a font called SWGamekeys MT which has the keys displayed similar to that in your 2nd image. I think the font is included in the MS® intellimouse software download.

emp00
Posts: 165
Joined: 15 Apr 2023, 12:02

Re: Keyboard key symbols - display in Gui ListView (hotkey cheatsheet)

Post by emp00 » 21 Aug 2023, 13:47

Thanks @metallizer great hint for the ModifyCol tweak! @ludamo unfortunately I cannot rely on rather exotic fonts due to missing admin rights and for portability reasons.

As a quick-win first shot I chose this simple StrReplace using Unicode characters for the Win+Shift keys. Unfortunately those seem to be unavailable for Ctrl, Alt and AltGr as well as F1, F2, ... keys. However, already better than before, saving some space in my cheatsheet.

Code: Select all

		var_[1] := StrReplace(var_[1], "Win", "⊞")		; Win = Unicode U+229E
		var_[1] := StrReplace(var_[1], "Shift", "⇧")	; Shift = Unicode U+21E7

Post Reply

Return to “Ask for Help (v2)”