How do I edit a drop down list displaying too many options? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bballjoe12
Posts: 114
Joined: 20 Aug 2017, 09:11

How do I edit a drop down list displaying too many options?

14 Feb 2018, 12:54

I have the following code in a Main.ahk file:

Code: Select all

#SingleInstance Force
#Persistent
SetWorkingDir %A_WorkingDir%

ShowHotkeyHelp:
	Includelist0 = 0
	InclIdx = 0 ; for handling include files
	splitpath, A_Scriptfullpath, ohname, ohdir, ohext, ohnameNE, ohdrv
	
HelpText := ""	
On_air_flag=0
		
A20130124125417:
	oldTrim := A_AutoTrim
	AutoTrim, On
	HlpSrcFile = %ohname%
		
	Loop
	{	fileReadline, thisline, %HlpSrcFile%, %A_Index%
		If ErrorLevel
			Break
		
		; ignore single line comments
		firstch := SubStr(thisline,1,1)
		If (firstch = ";")
			continue
		; Ignore IfInString test lines
		IfInString, thisline, IfInString
			continue
			
		;....................	
		; process rem comments
		;IfInString, thisline, %beginBlockComment%
		IfInString, thisline, /*
		{	InComment = 1	
			Continue
		}
		;IfInString, thisline, %endBlockComment%
		IfInString, thisline, */
		{	InComment = 0
			Continue
		}
		; handle a line within a block comment
		If (InComment = 1)
			Continue
		
		; process hotkey command
		; line as hotkey def there are two forms of a hotkey assignment. one uses the 
		; label Hotkey the other uses the double colon in the key assignment.
		tempstr = %thisline% ;<-- to cause autotrim to activate
		firstword := SubStr(tempstr,1,6)
		;If (firstword = "Hotkey")
		;{	
		;	HelpText .= tempstr "`n"
		;	Continue
		;}
		
		; double colon hotkey or hotstring
		IfInString, thisline, ::
		{	
			HelpText .= thisline "`n", %HlpDestFile%
			Continue
		}
		
		; process single line comment statement
		IfInString, thisline, `;
			Continue
		
		; handle #include files this is so you can identify
		; hotkeys from additional files
		IfInString, thisline, #IncludeAgain		;<-- ignore multiple includes of the same file
			Continue
			
		IfInString, thisline, #Include
		{	InclIdx++ ;<-- count the include file
			IncludeList0 := IncIdx
			inclstr := (SubStr(thisline, 10))
			IncludeList%InclIdx% = %inclstr%
			HelpText .= thisline %a_Index%`n, %HlpDestFile%
			Continue
			
		}
	}		
	AutoTrim := oldtrim
	
	; walk backwards through the include files 
	If (InclIdx > 0)
	{	inclstr := IncludeList%InclIdx%
		InclIdx--
		Splitpath, InclStr,ohname,,,ohnameNE
		HelpText .= Hotkeys included in %ohname%`r`n`r`n, %HlpDestFile%
		Goto A20130124125417
	}

	StringReplace, HelpText, HelpText, Send,, All
	StringReplace, HelpText, HelpText, !,ALT + `r, All
	StringReplace, HelpText, HelpText, #,Windows Key + `r, All
	StringReplace, HelpText, HelpText, ^,CTRL + `r , All
	StringReplace, HelpText, HelpText, {Enter}, `n , All
	StringReplace, HelpText, HelpText, {Tab 3}, `n , All	
	StringReplace, HelpText, HelpText, :, `r`r - , All
	IfInString, HelpText, :
		{
		StringReplace, HelpText, DeleteLine, :, `r`r - , All
		}		
	
Gui, DeleteHotKeys: Show, w330 h140, Delete HotKeys

GameIndex := 0
loop, read, test hotkey.ahk
{
Game%A_Index% := A_LoopReadLine
Game0 = %A_Index%
}
 
Loop,%Game0%
    List .= Game%A_Index%  . "|" 
 
Gui, DeleteHotKeys: Add, DropDownList, x16 y31 w300 vDeleteKey Choose1, %List%
Gui, DeleteHotKeys: Add, Text, x108 y6 w202 h23 +0x200, Select a HotKey to delete:
Gui, DeleteHotKeys: Add, Button, w63 x136 y58 gChoose, Delete
Gui, DeleteHotKeys: Show,,Delete HotKey
return
 
Choose:
Gui, DeleteHotKeys: Submit, Nohide
MsgBox, 36, Continue?, Are you sure you want to delete the selected HotKey? `r`r%DeleteKey%
	IfMsgBox No
		return
	else
	;FileRead(ReadToDelete, Keyboard.ahk)
	
Sleep 10	
return

SetWorkingdir, %OldWorkingDir%
Return

; Only need the below to show
!a::Send Active Directory Account Unlock - CHI_CO
!d::Send Active Directory Password Reset - CHI_CO
!m::Send Millennium Account Unlock - CHI_CO

The drop down box that is displayed, is showing every single line of code within my Main.ahk script. I need only the lines after the ; to display. The lines after the ; change text and it may be 3-20 lines. How do I edit my Drop Down Box correctly?
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: How do I edit a drop down list displaying too many options?  Topic is solved

14 Feb 2018, 16:07

You could add a specific string just above the hotkeys in a comment. In case that the hotkeys are for sure at the end of the file.
With loop/regex/instr you could detect the line and start searching/reading from there.
ciao
toralf

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Bing [Bot], Peiya, ShatterCoder and 316 guests