我有一个 GUI 记录文件夹中所有 chm 的列表。单击“运行”按钮时,它将打开列表中的第一个 chm,直到依此类推。然后我创建了一个应该扩展树的函数。
我的问题是我的功能,它一直有效,直到MsgBox()
那里停止。当我运行我的程序时,没有显示错误。
#include <GuiConstantsEx.au3>
#include <GuiListBox.au3>
#include <GuiTreeView.au3>
#include <File.au3>
#include <Array.au3>
;GUI
$guiTitle = "Automation"
GUICreate($guiTitle, 250, 430)
Global $hWnd = ControlGetHandle("[CLASS:HH Parent;TITLE:AutoIt Help]", "", "[CLASS:SysTreeView32; INSTANCE:1]")
Global $hChild = _GUICtrlTreeView_GetFirstChild($hWnd, 0)
Local $source = InputBox("Source Folder","Please enter the source folder","")
;InputBox
If @error = 1 Then
Exit
EndIf
If @error = 4 Then
Exit
;GUI_List
Else
$add = GUICtrlCreateButton("Show", 10, 53, 230, 20)
$picList = GUICtrlCreateList("", 10, 78, 230, 300)
$run = GUICtrlCreateButton("Run", 170, 385, 70, 30)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
;add
Case $add
Global $FileList = _FileListToArray($source, "*.chm")
If @error = 1 Then
MsgBox(0, "", "No Files Found.")
Exit
EndIf
If @error = 4 Then
MsgBox(0, "", "No Files Found.")
Exit
EndIf
For $i = 1 To $FileList[0] ;List_IFIX Pictures
GUICtrlSetData($picList, $FileList[$i])
Next
;run
Case $run
If _GUICtrlListBox_GetCount($picList) = 0 Then
MsgBox(0, "", "No Files Found.")
Else
For $i = 1 To $FileList[0]
If Not WinExists("AutoIT Help]") Then
ShellExecute($source & "\" & $FileList[1])
_Expand($hWnd, $hChild)
EndIf
Next
EndIf
;exit
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
EndIf
这是我的功能:
Func _Expand($hWnd, $hChild)
WinWaitActive("AutoIT Help")
MsgBox(0,"","Expand")
While 1
$hChild = _GUICtrlTreeView_GetNextChild($hWnd, $hChild)
If _GUICtrlTreeView_GetText($hWnd, $hChild) = "Tutorials" Then ExitLoop
WEnd
_GUICtrlTreeView_Expand(ControlGetHandle("[CLASS:HH Parent;TITLE:AutoIt Help]","", "[CLASS:SysTreeView32; INSTANCE:1]"),$hchild, True)
EndFunc