sfresher Posted September 23, 2008 Share Posted September 23, 2008 (edited) For example, how can I automate this task? Select tree System tools > Event viewer > Security. Right click on security, select "Clear all events". Edited September 23, 2008 by sfresher Link to comment Share on other sites More sharing options...
Zedna Posted September 23, 2008 Share Posted September 23, 2008 (edited) Select tree System tools > Event viewer > Security #include <GuiTreeView.au3> $hTreeView = ControlGetHandle("Computer Management", "", "SysTreeView321") $hItem = _GUICtrlTreeView_FindItemEx($hTreeView, "System Tools|Event Viewer|Security") _GUICtrlTreeView_SelectItem($hTreeView, $hItem) Edited September 23, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
sfresher Posted September 23, 2008 Author Share Posted September 23, 2008 Thanks a lot! I am still having one question: What if the Computer Management windows has multiple treeviews? How can we get the handle for each of these treeviews? And how do we distinguish them? #include <GuiTreeView.au3> $hTreeView = ControlGetHandle("Computer Management", "", "SysTreeView321") $hItem = _GUICtrlTreeView_FindItemEx($hTreeView, "System Tools|Event Viewer|Security") _GUICtrlTreeView_SelectItem($hTreeView, $hItem) Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 24, 2008 Share Posted September 24, 2008 Thanks a lot! I am still having one question: What if the Computer Management windows has multiple treeviews? How can we get the handle for each of these treeviews? And how do we distinguish them? You can examine them with AU3Info.exe to see what their CLASS and INSTANCE are, which combine to form ClassNameNN, i.e. "[CLASS:SysTreeView32; INSTANCE:1]" and "[CLASS:SysTreeView32; INSTANCE:2]" become "SysTreeView321" and "SysTreeView322". There are more ways to specify a control. Look in the help file index at "Controls". Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
sfresher Posted September 29, 2008 Author Share Posted September 29, 2008 A new problem pops up: What if the tree item may dynamically change their name? Can I use a wildcard selection to select the tree item? For example, System Tools > Event Viewer[%] > Security, where % maybe 01, 02, 03. #include <GuiTreeView.au3> $hTreeView = ControlGetHandle("Computer Management", "", "SysTreeView321") $hItem = _GUICtrlTreeView_FindItemEx($hTreeView, "System Tools|Event Viewer|Security") _GUICtrlTreeView_SelectItem($hTreeView, $hItem) Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 29, 2008 Share Posted September 29, 2008 (edited) A new problem pops up: What if the tree item may dynamically change their name? Can I use a wildcard selection to select the tree item? For example, System Tools > Event Viewer[%] > Security, where % maybe 01, 02, 03. It's not a name, it's just text in the item. A TreeView item is referenced by index number and handle with the UDF functions and by a funky formatted string in the native ControlTreeView() functions. The code posted uses the UDF functions, which includes things like _GUICtrlTreeView_FindItem(). See the example posted there in the help file. It does not allow wildcards. So you would have to code a recursive search using things like _GUICtrlTreeView_GetChildCount(), _GUICtrlTreeView_GetFirstChild(), _GUICtrlTreeView_GetNextChild(), _GUICtrlTreeView_GetText(). Edited September 29, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
sfresher Posted September 30, 2008 Author Share Posted September 30, 2008 Thanks a lot, PsaltyDS. You have answered quite a few numbers of my questions and kind of enlightened my programming experience with AutoIt. It's not a name, it's just text in the item. A TreeView item is referenced by index number and handle with the UDF functions and by a funky formatted string in the native ControlTreeView() functions. The code posted uses the UDF functions, which includes things like _GUICtrlTreeView_FindItem(). See the example posted there in the help file. It does not allow wildcards. So you would have to code a recursive search using things like _GUICtrlTreeView_GetChildCount(), _GUICtrlTreeView_GetFirstChild(), _GUICtrlTreeView_GetNextChild(), _GUICtrlTreeView_GetText(). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now