#include
#include
#include
#include
Local $idListBox
Local $idButton
Local $hLB
Local $hWin
Local $wasFound = 0
BuildGUI()
Main()
Do
$event = GUIGetMsg()
If $event = $idButton Then
Main()
EndIf
Until $event = $GUI_EVENT_CLOSE
GUIDelete()
Func BuildGUI()
; Create GUI
GUICreate("TES Helper by OgreVorbis", 400, 332)
$idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL))
$idButton = GUICtrlCreateButton("Go Again!", 164, 300)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_COMMAND, "ListBox_Clicked")
EndFunc
Func ListBox_Clicked($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $lParam
$iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
$iCode = BitShift($wParam, 16) ; Hi Word
If $iCode = $LBN_DBLCLK And $iIDFrom = $idListBox Then
$iIndex = _GUICtrlListBox_GetCaretIndex($idListBox)
$sText = _GUICtrlListBox_GetText($idListBox, $iIndex)
$goThere = Int(StringLeft($sText, StringInStr($sText, " ") - 1))
_GUICtrlListView_SetItemSelected($hLB, -1, False) ; clear the selection
_GUICtrlListView_SetItemSelected($hLB, $goThere, True, True) ; set the selected item
;ControlListView($hWin, "", $hLB, "SelectClear") - this is an alternate method, but junkier
;ControlListView($hWin, "", $hLB, "Select", $goThere)
_GUICtrlListView_EnsureVisible($hLB, $goThere) ; scroll to it
WinActivate($hWin)
EndIf
EndFunc
Func Main()
If WinExists("Object Window") Then
_GUICtrlListBox_ResetContent($idListBox)
$hWin = WinGetHandle("Object Window")
$hLB = ControlGetHandle($hWin, "", "List2")
Local $numItems = _GUICtrlListView_GetItemCount($hLB)
Local $title
Local $iD = -1
Local $sSearch = ""
$wasFound = 0
MsgBox(0, "Win", "Total objects in list = " & String($numItems))
$sSearch = InputBox("Search", "What object do you want to search for?")
If $sSearch = "" Then Return
ToolTip("Please wait. . .", @DesktopWidth / 2, @DesktopHeight / 2, "Searching", 1, 2)
_GUICtrlListBox_BeginUpdate($idListBox)
$iD = _GUICtrlListView_FindInText($hLB, $sSearch, $iD, False)
$title = _GUICtrlListView_GetItemText($hLB, $iD, 0)
If $iD <> -1 Then
_GUICtrlListBox_AddString($idListBox, String($iD) & " " & $title)
$wasFound = $wasFound + 1
EndIf
While True
$iD = _GUICtrlListView_FindInText($hLB, $sSearch, $iD, False)
If $iD = -1 Then ExitLoop
$title = _GUICtrlListView_GetItemText($hLB, $iD, 0)
_GUICtrlListBox_AddString($idListBox, String($iD) & " " & $title)
$wasFound = $wasFound + 1
WEnd
_GUICtrlListBox_EndUpdate($idListBox)
ToolTip("")
If $wasFound = 0 Then
MsgBox(16, "Nothing", "Nothing was found for this term.")
Else
MsgBox(64, "Results", "The search returned " & String($wasFound) & " results.")
EndIf
Else
MsgBox(16, "Fail", "TES must not be open or there is another problem :-(")
Exit
EndIf
EndFunc