Expansion Posted February 17, 2011 Share Posted February 17, 2011 I'm writing a script that monitors an application for child SysTreeView32 windows. When it detects such a window, I want it to select a folder in the Tree View, according to a path that I specify in the script. (ex. C:\\Files\test\) How can I select the folder in the Tree View, according to a specified path? Also, do you have any idea whether is possible to do the same thing with a DirectUIHWND window? Link to comment Share on other sites More sharing options...
KaFu Posted February 17, 2011 Share Posted February 17, 2011 How can I select the folder in the Tree View, according to a specified path?Not directly. Take a look at ControlTreeView() how to obtain Treeview Info. You have to fetch the treeviews item text and loop through the results until the item matching your definition is selected (GetItemCount > "GetText", "item" > "Expand", "item" > GetItemCount .... > "Select", "item").Also, do you have any idea whether is possible to do the same thing with a DirectUIHWND window?From a theoretical standpoint... yes. From a practical standpoint... I don't know how , those controls are real buggers. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Expansion Posted February 20, 2011 Author Share Posted February 20, 2011 (edited) thank you. I've managed to write that function. But, I'm facing a new problem. I can't find the handle to the SysTreeView. #include <GUIConstantsEx.au3> #include <TreeviewConstants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #Include <GuiButton.au3> $hwnd=HWND(0x000B0884) ;handle for the application window $treeview_hwnd=ControlGetHandle ($hwnd,"",100) ;100= controlID If @error Then MsgBox(4096, "Error", "Could not find the correct window") Else MsgBox(4096, "handle is", $treeview_hwnd) EndIf In fact, I can't find child windows with ControlGetHandle if I'm passing the handle(for the main application) instead of the title of the SysTreeView(which, actually has no title). How should I call ControlGetHandle? Edited February 20, 2011 by Expansion Link to comment Share on other sites More sharing options...
KaFu Posted February 20, 2011 Share Posted February 20, 2011 First please keep this from the help-file in mind (which is true for all standard Treeview / Listview controls):"As AutoIt is a 32-bit application some commands are not available when referencing a 64-bit application as Explorer when running on 64-bit Windows."That means if your target app is 32bit the script also has to be complied as 32bit, if the target app is 64bit the script also has to be.Then you have to search for the control handle of the Treeview. These are generated dynamically and normally change on every start of the program. To do so I would recommend the excellent by Ascend4nt. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Expansion Posted February 20, 2011 Author Share Posted February 20, 2011 Luckly I was running both of them on 32bit, but it's good to know, because I'm planning to write some scripts for a few 64bit apps, too. I've discovered my problem. SysTreeView32 was not a direct child window, but a descendant window. So, _EnumChildWindows should be the solution for me, right? Link to comment Share on other sites More sharing options...
KaFu Posted February 20, 2011 Share Posted February 20, 2011 No guarantee given, but that's how I would start ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Expansion Posted February 20, 2011 Author Share Posted February 20, 2011 (edited) I bumped into another problem, that I did not consider in the first place. The script that I'm writing monitors for the creation of a specific TreeView, and selects a folder based on a number that is incremented. For example, first time when it detects the TreeView it should select "C:\test\1". Second time, "C:\test\2", third time "C:\test\3" and so on. The problem is that it should stop detecting the same TreeView, otherwise it would keep on creating and selecting multiple folders for a single TreeView detection. IMHO, there are 3 options: 1) based on comparing with previous handle, but there might be a very small possibility that the TreeView receives the same handle. 2) waiting for me to click on the OK button from the Dialog Window that contains the TreeView 3) other ideas, if there are I'd go for number 2), but I have no clue on how to intercept a buttonclick[when you have the button handle and controlID], or whether if it's possible, or simple enough. Edited February 20, 2011 by Expansion Link to comment Share on other sites More sharing options...
KaFu Posted February 20, 2011 Share Posted February 20, 2011 Maybe search for $hTreeview => while WinExists($hTreeview) sleep(10) wend => search for next $hTreeview? OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Expansion Posted February 20, 2011 Author Share Posted February 20, 2011 Wow, that is perfect. Thank you. Link to comment Share on other sites More sharing options...
Expansion Posted February 20, 2011 Author Share Posted February 20, 2011 Is there a simple way to control these type of dialog windows?Or I'd have to improvise something? ComboBox+ListView get/check If so, any ideas? I'm asking because, most of the time, I come up with complex solutions. Link to comment Share on other sites More sharing options...
KaFu Posted February 20, 2011 Share Posted February 20, 2011 (edited) File name: is an Edit control which you can set with ControlSetText() (or controlsend() / send(), but I would always first try ControlSetText() as it is much more reliable). To "browse" to a path, ControlSetText() the path to the edit control (edit1 ?) and ControlSend "Enter" to the edit control. To save to a certain filename, just copy the full-path (location + name) to the edit control via ControlSetText() and controlclick "Save" (button1 ?). Edited February 20, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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