I ended up making quite a bit of changes.
The main thing is I switched over to keeping the data in an array in an attempt to make it a little quicker.
With the large number of constants from both Excel and Word the Initialization is definitely noticeable. It is only the first time you open the dialog though, after that it is quick to display and search.
Apparently setting up all the lines in the Gui ListView is the slow part so the array did not help as much as I had hoped
Code: Select all
; by burque505
; https://www.autohotkey.com/boards/viewtopic.php?p=256295#unread
; modified by FanaticGuru
SetBatchLines, -1 ; more CPU time for quicker Initialization
#Include [Library] Sift.ahk
#e::
if !Initialized
{
SysGet, VSBW, 2 ; SM_CXVSCROLL
Width := 240 + 80 + VSBW + 4 ; adjust for vertical scroll bar and make just wide enough not to have horizontal scroll bar
Gui +AlwaysOnTop
Menu, HelpMenu, Add, &Help, Help
Menu, HelpMenu, Add, &wdUnits, wdUnits
Gui, Menu, HelpMenu
Gui, Add, Edit, x10 y+10 w300 h25 vQueryText gQuery,
Gui, Add, Text, x+10 w30, Query
Gui, Add, ListView, grid x10 y+20 w%Width% r30 hwndHwnd gMyListView vMyListView, Constant | Value
LV_ModifyCol(1, 240) ; change width of alphanum field
LV_ModifyCol(2, 80)
; load Word data
Fileread, OutputVar, Enumerated Constants - Word.csv
Data := StrSplit(OutputVar, "`n", "`r")
; load Excel data
Fileread, OutputVar, Enumerated Constants - Excel.csv
Max := Data.MaxIndex()
Data.Insert(Max+1, StrSplit(OutputVar, "`n", "`r")*)
for Index, Element in Data
{
Cols := StrSplit(Element, ",")
LV_Add("", Cols.1, Cols.2)
}
Initialized := true
}
Gui, Show,, Enumerated Constants Search
return
Query:
Gui, Submit, NoHide
if QueryText
Results := Sift_Regex(Data, QueryText, "uw")
else
Results := Data
Max := Results.MaxIndex()
for Index, Element in Results
{
Cols := StrSplit(Element, ",")
LV_Modify(Index,, Cols.1, Cols.2)
}
Loop % Data.MaxIndex() - Max
LV_Modify(A_Index+Max,, "","")
SendMessage, 0x115, 6, 0,, ahk_id %Hwnd% ; force scroll to top
return
GuiClose:
GuiEscape:
Gui, Hide
return
MyListView:
if (A_GuiControlEvent == "R")
{
LV_GetText(Name, A_EventInfo, 1)
Clipboard := Name
MsgBox, 4096, Constant Name, Constant name: %Name%`n`n(on clipboard also)
}
if (A_GuiControlEvent == "DoubleClick")
{
LV_GetText(Number, A_EventInfo, 2)
Clipboard := Number
MsgBox, 4096, Constant Value, Constant integer value: %number%`n`n(on clipboard also)
}
return
Help:
v =
(LTrim
Type in some or all of an enumerated constant name to find.
You can delete, edit, and otherwise modify your search,
and the ListView will refresh accordingly.
When you see a constant you want to retrieve:
Double-right-click to get the name on the clipboard;
Double-click to get the integer value on the clipboard.
That's it!
)
MsgBox, 4096, Help, %v%
return
wdUnits:
units =
(LTrim
wdCell`t`t`t12`tA cell.
wdCharacter`t`t1 A character.
wdCharacterFormatting`t13`tCharacter formatting.
wdColumn`t`t9`tA column.
wdItem`t`t`t16`tThe selected item.
wdLine`t`t`t5`tA line.
wdParagraph`t`t4`tA paragraph.
wdParagraphFormatting`t14`tParagraph formatting.
wdRow`t`t`t10`tA row.
wdScreen`t`t7`tThe screen dimensions.
wdSection`t`t8`tA section.
wdSentence`t`t3`t`A sentence.
wdStory`t`t`t6`tA story.
wdTable`t`t`t15`tA table.
wdWindow`t`t11`tA window.
wdWord`t`t`t2`tA word.
)
MsgBox, 4096, wdUnits, %units%
return
You need to #include Sift and have the two files "Enumerated Constants - Word.csv" and "Enumerated Constants - Excel.csv".