Code: Select all
Gui, +Owner
Gui, o:Destroy ; Ensures that only one instance of the miniform occurs at a time.
Gui, o:-MinimizeBox +alwaysOnTop
Gui, o:font, c%varFontColorCode% s11
gui, o:color, %varColorCode%
Gui, o:Add, Text, ,For [%entrylbl%]`nSelect one%mylbl%
Loop, Parse, theList, `n,`r ; Parses list.
{
fchar := SubStr(A_LoopField, 1, 1)
If fchar is Number ; Get first char and see if it's a digit.
item := SubStr(A_LoopField, 3, 99) ; If so, chop first 2 chars.
else
item := A_LoopField ; If not a digit, use entire line.
If (Debug = 1) ; DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG
MsgBox, fchar: %fchar%`nitem : %item%
Gui, o:Add, %guiType%, Checked%fchar% vCheckbox%a_index%, %item% ;Dynamically make one per item.
}
Gui, o:Add, Button, default xm w50 gMyOpts, Use
If (guiType = "Checkbox") { ; Only add these buttons if it's checkboxes.
Gui, o:Add, Button, yp x+5 w50 gAll, All
Gui, o:Add, Button, yp x+5 w50 gNone, None
}
Gui, o:Add, Button, yp x+5 w50 gCancelOpts, Cancel
Gui, o:Show,x%X% y%Y% , Option Items ; Show miniform at same location as main MutliTool form.
Return
All: ; From Select "All" button of mini form.
Gui, o:Submit, NoHide
WinGet, list, ControlList
For each, control in StrSplit(list, "`n")
GuiControl,,Checkbox%A_Index%,1
return
None: ; From Select "None" button of mini form.
Gui, o:Submit, NoHide
WinGet, list, ControlList
For each, control in StrSplit(list, "`n")
GuiControl,,Checkbox%A_Index%,0
return
MyOpts: ; Go here when user clicks "Use" button.
Gui, o:Submit
vCount= ; Need this var for puntuation.
Loop, parse, theList, `n
{
fchar := SubStr(A_LoopField, 1, 1)
If Checkbox%a_index% <> 0
{
vCount = %a_index%
If fchar is Number ; Again, if 1st char is digit, chop 1st two.
item := SubStr(A_LoopField , 3, 9999)
else
item := A_LoopField ; Otherwise, use whole line.
IfEqual, CurrTab, Notices
{
IfEqual, vPun, 1 ; If Puncuation flag found, separate with comma
myOptions = %myOptions%, %item%
else
myOptions = %myOptions% %item%
}
else
myOptions = %myOptions%`n%item% ; If currTab is Tests, keep list as a list
}
}
IfEqual, vPun, 1
{ ; If punctuation was used, chop first comma, then insert "and" before last item.
myOptions := SubStr(myOptions, 3, 999999)
IfEqual, vCount, 2 ; If there were exactly 2 items checkmarked, just use "and."
myOptions := StrReplace(myOptions,", " . item," and " . item)
myOptions := StrReplace(myOptions,", " . item,", and " . item) ; Otherwise, Oxford comma.
}
MyEntry := StrReplace(MyEntry, theList, " " . myOptions,, 1)
MyEntry := StrReplace(MyEntry, theKey, "",, 1) ; Only replace first occurrence.
If RegExMatch(MyEntry, "s)\R\V*\bOptional\b\V*=\R", "") ; Options key found in expansion text.
Gosub, TopOfLoop ; If found, run this section again.
Else
Gosub, ContinueScript ; If they've all been replaced, continue below.
Return