brian_h Posted October 19, 2015 Share Posted October 19, 2015 Hi,I am using AutoIt to test a program containing a tree view, during which I navigate the tree using the ControlTreeView function. I control the program to have it add new items to the tree, and I can navigate to these using ControlTreeView with "Expand", "Select", etc. And if I control the program to have it delete an item from the tree, this is reflected when navigating the tree in AutoIt (using ControlTreeView), however if I delete an item and then add it again, ControlTreeView does not appear to see the new node,I assume that the nodes are being cached internally, so after deleting a node, its parent node has its child count set to zero in the cache, but when a new item is added via the program it does not change the cache so it cannot be "seen" by AutoIt.Is this correct, and if so, is there a way to have AuoiIt discard its cache, so that the next time I navigate using ControlTreeView it will get the items from the tree and not the cache?Thanks,Brian Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 19, 2015 Moderators Share Posted October 19, 2015 brian_h,Welcome to the AutoIt forums.As far as I know there is no cache within AutoIt - most commands pass directly to Windows via the API. So I feel it is far more likely that Windows itself is caching the treeview state so that AutoIt gets a false return when requesting the new data. Sorry not be of more help - can you let us know the name of the program in question? Perhaps someone else here has some experience of working with it.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
brian_h Posted October 19, 2015 Author Share Posted October 19, 2015 Hi M23,Thanks for the reply, and the welcome.The program is question is one we write ourselves, and its for a specialized market, so its unlikely anyone else will have experience working with it.The tree in question is a standard SysTreeView32 tree, and using the ControlTreeView function, I navigate down the tree to the item I want, select it, do some tests, then I execute a command in the program to delete the selected node. I then select the parent node and check it has a child count of zero, which it does. I then execute another command to add a new child node (this actually makes a database change and reloads the tree), but when I ask for the child count again it still returns zero, and if I try to expand the parent it returns an error. However, I can expand the node manually in the program and the child node is there. So at this point I'm a little bit stuck. I might try writing my own function for expanding the tree by sending messages directly to the it and see if that has any more success.Thanks.Brian Link to comment Share on other sites More sharing options...
LarsJ Posted October 20, 2015 Share Posted October 20, 2015 Take a look at the GuiTreeView UDF. It provides access to many more functions than the few functions that are implemented through ControlTreeView. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
brian_h Posted October 20, 2015 Author Share Posted October 20, 2015 Thanks LarsJ,I had already found the GetItemText method in the GuiListView.au3 file, it was a good example of handling the tricky bit of getting the text out (pretty much the same as required for the tree view), which involves creating a struct and copying it to global memory, and using that I managed to write my own Expand method for the tree that takes a path like the one passed to the ControlTreeView method.When I tried this I got exactly the same issue when trying to expand the parent of the new item in the tree, which convinced me that the problem was in the application and not AutoIt.After a bit of routing about in the application's source code, I did find the issue - the tree is loaded on demand from the database, so when a node is expanded we handle the notification and load the data for that branch (if any). When refreshing the tree, we only load the data for already expanded nodes, and set the child count for each leaf node to 1, so that the expand button is shown, and when it's clicked we attempt to load the children, and if there are none we set the child count to 0. However, it turns out that once a node has been expanded, the item's state gets updated with the TVIS_EXPANDEDONCE state, which tells the tree not to raise the TVN_EXPANDING notification the next time it is expanded, so the new child for the node never got loaded (although clicking on the expand button manually did still load the data!). I fixed this by clearing this state whenever we set the child count, so the notifications get raised the next time it is expanded, and now my AutoIt script works as it should.Thanks for the help.Brian 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