DIMM_V2 Posted December 3, 2023 Share Posted December 3, 2023 Hello , can someone please help me with my code , im trying to click on "Home" by text but this is not working ,thx ps - it's working by index , but not by text . based on this example = https://www.autoitscript.com/wiki/ControlTreeView my code : #RequireAdmin #include <GUIConstantsEx.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> ; Run the Everything application Run('C:\Program Files\Everything\Everything.exe') Sleep(1000) Send("^p") ; Get the handle of the SysTreeView32 control in the Everything window Local $hTreeView = ControlGetHandle("Everything Options", "", "[CLASS:SysTreeView32; INSTANCE:1]") ; Select the third item in the TreeView ControlTreeView("","", $hTreeView, " Expand", "General") ; ControlTreeView("","", $hTreeView, " Select", "General|Home") ; this is not working home Sleep(2500) ControlTreeView("", "", $hTreeView, "Select", "#0|#1") ; this is home #0|#1 Sleep(2000) ; Find the index of the item with the text "General" in the TreeView ;~ Local $itemIndex = ControlTreeView("Everything Options", "", $hTreeView, "FindString", "View") ControlTreeView("Everything Options", "", $hTreeView, "Select", "#4") Sleep(2000) ;~ ControlTreeView("Everything Options", "", $hTreeView, "Select", "#0|#1") ; home Local $homeItemIndex = ControlTreeView("Everything Options", "", $hTreeView, "FindString", "*Home*") Link to comment Share on other sites More sharing options...
Danp2 Posted December 3, 2023 Share Posted December 3, 2023 In the example, the window handle is passed as the first parameter to ControlTreeView. You aren't doing that, so I don't know how you expect this to work. P.S. You should check the value of @error following the command that you think is failing, which will help you understand what is happening. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DIMM_V2 Posted December 3, 2023 Author Share Posted December 3, 2023 (edited) 22 minutes ago, Danp2 said: In the example, the window handle is passed as the first parameter to ControlTreeView. You aren't doing that, so I don't know how you expect this to work. P.S. You should check the value of @error following the command that you think is failing, which will help you understand what is happening. * this code is working , but this is by index , i want to do that by text,so im not sure that the problem is in "parameter" ControlTreeView("", "", $hTreeView, "Select", "#0|#1") ; this is home #0|#1 if i understand well , it should be something like this ==> right ? because in my case i don't create any gui's . ControlTreeView($hTreeView, "", "Select", "#General|#Home") ; this is not working home ControlTreeView($hTreeView, "", "Select", "General|Home") ; this is not working home Edited December 3, 2023 by DIMM_V2 addional info Link to comment Share on other sites More sharing options...
Danp2 Posted December 3, 2023 Share Posted December 3, 2023 No, you can't just drop or move the parameters around. I may have been wrong about the need for the window handle. However, you should still check for errors following the command to better understand what is occurring. Have you done that? Also, see the Remarks section in the help file entry for ControlTreeView. I have no idea if this applies to your situation since you haven't provided the necessary details. You may want to take a look at the GuiTreeView functions in the help file to see if they are able to better interact with the target control. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DIMM_V2 Posted December 3, 2023 Author Share Posted December 3, 2023 (edited) 16 minutes ago, Danp2 said: No, you can't just drop or move the parameters around. I may have been wrong about the need for the window handle. However, you should still check for errors following the command to better understand what is occurring. Have you done that? Also, see the Remarks section in the help file entry for ControlTreeView. I have no idea if this applies to your situation since you haven't provided the necessary details. You may want to take a look at the GuiTreeView functions in the help file to see if they are able to better interact with the target control. how to check for errors , by debug to console from Scite ? if yes there is nothing special : "ever.au3"(19,293) : error: syntax error" for the second point : I have tryed with 32 bit versions for "Everything" the same result . necessary details : im trying to click to "General > Home" as on my picture . os : ( win11 @ [Version 10.0.22621.2715]) Edited December 3, 2023 by DIMM_V2 Link to comment Share on other sites More sharing options...
Danp2 Posted December 3, 2023 Share Posted December 3, 2023 2 minutes ago, DIMM_V2 said: how to check for errors , by debug to console from Scite ? Yes, that is one method. There are other options, such as using the Debug UDF that comes with AutoIt. Quote if yes there is nothing special : "ever.au3"(19,293) : error: syntax error" No idea what you are trying to say here. That error message indicates an issue with whatever is on line 19 in your script. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DIMM_V2 Posted December 3, 2023 Author Share Posted December 3, 2023 3 minutes ago, Danp2 said: Yes, that is one method. There are other options, such as using the Debug UDF that comes with AutoIt. No idea what you are trying to say here. That error message indicates an issue with whatever is on line 19 in your script. @@ Debug(32) : Failed to select item. Error code: 1 , this info i had already . 🤯 Link to comment Share on other sites More sharing options...
Danp2 Posted December 3, 2023 Share Posted December 3, 2023 That's great... but you hadn't shared these details here, so were we supposed to know this by telekinesis? FWIW, my crystal ball is at the shop for repair. 🔮😁 I again recommend that you take a look at the _GuiTreeView* functions, as they may be better able to interact with the SysTreeView32 control. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DIMM_V2 Posted December 3, 2023 Author Share Posted December 3, 2023 1 hour ago, Danp2 said: That's great... but you hadn't shared these details here, so were we supposed to know this by telekinesis? FWIW, my crystal ball is at the shop for repair. 🔮😁 I again recommend that you take a look at the _GuiTreeView* functions, as they may be better able to interact with the SysTreeView32 control. really ? this is my second line on the start of this post ==> .ps - it's working by index , but not by text . After some tests : this is working only with their own gui which is created by autoit, it can't run with external soft , or there is a bug ... so for me the function "ControlTreeView" present some bugs or not fully compatible. this is working code (this can change values in General , Home,Red,Green but fully useless : expandcollapse popup#RequireAdmin #include <GUIConstantsEx.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> Example() Func Example() Local $hGUI, $idTreeView ; Create a GUI $hGUI = GUICreate("TreeView Example", 300, 200) $idTreeView = GUICtrlCreateTreeView(10, 10, 280, 180) ; Add items to the TreeView Local $idRoot = GUICtrlCreateTreeViewItem("General", $idTreeView) Local $idChild1 = GUICtrlCreateTreeViewItem("Home", $idRoot) Local $idChild2 = GUICtrlCreateTreeViewItem("Red", $idRoot) Local $idChild3 = GUICtrlCreateTreeViewItem("Green", $idRoot) ; Show the GUI GUISetState(@SW_SHOW, $hGUI) ; Select the "Home" item _GUICtrlTreeView_SelectItem($idTreeView, $idChild1) WinActive("TreeView Example") $hWnd = WinGetHandle("TreeView Example") ; Get the handle of the SysTreeView32 control Local $hTreeView = ControlGetHandle($hWnd, "", "[CLASS:SysTreeView32; INSTANCE:1]") Sleep(2500) ControlTreeView($hWnd, "", $hTreeView, "Select", "General|Red") Sleep(1200) ControlTreeView($hWnd, "", $hTreeView, "Select", "General|Green") ; Run the GUI until the user closes it Do Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete($hGUI) EndFunc this should work but this is not working : #RequireAdmin #include <GUIConstantsEx.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> ; Run the Everything application Run('Everything.exe') Sleep(1000) Send("^p") Sleep(1000) ; Get the handle of the SysTreeView32 control in the Everything window $hWnd = WinGetHandle("Everything Options") Local $hTreeView = ControlGetHandle("Everything Options", "", "[CLASS:SysTreeView32; INSTANCE:1]") ; Select the third item in the TreeView ;~ ControlTreeView($hGUI, "", $hTreeView_1, "Select", "Root|Item 4") ; example ControlTreeView($hWnd , "", "Select", "General|Home") ControlTreeView($hTreeView , "", "Select", "General|Home") Link to comment Share on other sites More sharing options...
Danp2 Posted December 3, 2023 Share Posted December 3, 2023 23 minutes ago, DIMM_V2 said: really ? this is my second line on the start of this post ==> .ps - it's working by index , but not by text . Yes... really. Stating that something "doesn't work" isn't helpful when you don't include additional details like the value of @error following the function call. 🙄 Quote this is working code (this can change values in General , Home,Red,Green but fully useless : It's useful IMO because it accomplishes two things -- it allows anyone to run it without needing additional software to perform the test it demonstrates that ControlTreeView is working for at least basic SysTreeView32 controls. Quote this should work but this is not working : Nope. AFAICS, you aren't calling ControlTreeView with the correct parameters in this code. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DIMM_V2 Posted December 3, 2023 Author Share Posted December 3, 2023 18 minutes ago, Danp2 said: Yes... really. Stating that something "doesn't work" isn't helpful when you don't include additional details like the value of @error following the function call. 🙄 It's useful IMO because it accomplishes two things -- it allows anyone to run it without needing additional software to perform the test it demonstrates that ControlTreeView is working for at least basic SysTreeView32 controls. Nope. AFAICS, you aren't calling ControlTreeView with the correct parameters in this code. can you give an example ,that should work ? with ControlTreeView ? Link to comment Share on other sites More sharing options...
Danp2 Posted December 3, 2023 Share Posted December 3, 2023 You already posted a working example above with your General, Home, Red, Green one. This is one of the lines from there -- ControlTreeView($hWnd, "", $hTreeView, "Select", "General|Red") Now compare that to the ones from your next script -- ControlTreeView($hWnd , "", "Select", "General|Home") ControlTreeView($hTreeView , "", "Select", "General|Home") Notice any difference between those two lines and the first one? 🤔 DIMM_V2 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DIMM_V2 Posted December 4, 2023 Author Share Posted December 4, 2023 10 hours ago, Danp2 said: You already posted a working example above with your General, Home, Red, Green one. This is one of the lines from there -- ControlTreeView($hWnd, "", $hTreeView, "Select", "General|Red") Now compare that to the ones from your next script -- ControlTreeView($hWnd , "", "Select", "General|Home") ControlTreeView($hTreeView , "", "Select", "General|Home") Notice any difference between those two lines and the first one? 🤔 $hWnd = WinGetHandle("Everything Options") ControlTreeView ( "title", "text", controlID, "command" [, option1] ) ==> this is official info , how to use . ControlTreeView($hWnd,"", $hTreeView, "Select", "General|ui") ; ==> this is working . why this one is not working ==> ControlTreeView("Everything Options", $hTreeView, "Select", "General|Home") ==> i have the title here , right ? i dont't understand . Link to comment Share on other sites More sharing options...
Danp2 Posted December 4, 2023 Share Posted December 4, 2023 2 hours ago, DIMM_V2 said: ControlTreeView($hWnd,"", $hTreeView, "Select", "General|ui") ; ==> this is working . Are you sure? It doesn't work for me. Local $hWnd = WinGetHandle("Everything Options") Local $hTreeView = ControlGetHandle($hWnd, "", "[CLASS:SysTreeView32; INSTANCE:1]") ControlTreeView($hWnd , "", $hTreeView, "Select", "General|ui") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : ControlTreeView = Error code: ' & @error & @CRLF) This is my output -- @@ Debug(143) : ControlTreeView = Error code: 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Solution DIMM_V2 Posted December 4, 2023 Author Solution Share Posted December 4, 2023 (edited) 29 minutes ago, Danp2 said: Are you sure? It doesn't work for me. Local $hWnd = WinGetHandle("Everything Options") Local $hTreeView = ControlGetHandle($hWnd, "", "[CLASS:SysTreeView32; INSTANCE:1]") ControlTreeView($hWnd , "", $hTreeView, "Select", "General|ui") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : ControlTreeView = Error code: ' & @error & @CRLF) This is my output -- @@ Debug(143) : ControlTreeView = Error code: 1 Version : Everything 1.4.1.935 (x64) Version : Win 10 , build 2004 * maybe it is not working on windows 11, all my past tests are done on windows 11 ; except the last one , i will retest it later on win11. * for your test you must have the window Opened with label "Everything Options" , so it is not a main page . yes these lines are working ; full working code Run('Everything.exe') Sleep(1000) Send("^p") Sleep(1000) ; Get the handle of the SysTreeView32 control in the Everything window $hWnd = WinGetHandle("Everything Options") $hTreeView = ControlGetHandle("Everything Options", "", "[CLASS:SysTreeView32; INSTANCE:1]") Sleep(1000) ControlTreeView($hWnd,"", $hTreeView, "Select", "General|ui") ; kk Sleep(1000) ControlTreeView($hWnd,"", $hTreeView, "Select", "General|Home") ; kk Check Proof -) Edited December 4, 2023 by DIMM_V2 Link to comment Share on other sites More sharing options...
Danp2 Posted December 4, 2023 Share Posted December 4, 2023 FWIW, that was only a subset of the code (just enough to show the origin of the variables being used). Based on your test above, it appears to work on Win10 but not Win11. I believe the issue is related to failure to retrieve the text from the items. I wonder if this is a known issue? Maybe @jpm or another user will chime in here with some ideas. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted December 4, 2023 Share Posted December 4, 2023 Ok... so this appears to be the same issue as described in this prior thread. Running the script in x64 mode works for me. #AutoIt3Wrapper_UseX64=Y #include <GUIConstantsEx.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> ; Run the Everything application Run('C:\Program Files\Everything\Everything.exe') Sleep(1000) Send("^p") Sleep(1000) ; Get the handle of the SysTreeView32 control in the Everything window Local $hWnd = WinGetHandle("Everything Options") Local $hTreeView = ControlGetHandle($hWnd, "", "[CLASS:SysTreeView32; INSTANCE:1]") ControlTreeView($hWnd , "", $hTreeView, "Select", "General|Home") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : ControlTreeView = Error code: ' & @error & @CRLF) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DIMM_V2 Posted December 4, 2023 Author Share Posted December 4, 2023 1 hour ago, Danp2 said: FWIW, that was only a subset of the code (just enough to show the origin of the variables being used). Based on your test above, it appears to work on Win10 but not Win11. I believe the issue is related to failure to retrieve the text from the items. I wonder if this is a known issue? Maybe @jpm or another user will chime in here with some ideas. why this one is not working ==> ControlTreeView("Everything Options", $hTreeView, "Select", "General|Home") ==> i have the title here , right ? i dont't understand . * yes it works well on windows 11 too, Link to comment Share on other sites More sharing options...
Danp2 Posted December 4, 2023 Share Posted December 4, 2023 @DIMM_V2 I have no idea what you are attempting to communicate in your last post. DIMM_V2 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
junkew Posted December 4, 2023 Share Posted December 4, 2023 Start allways with checking the example in the helpfile for ControlTreeView titles can be frustrating with invisible characters, upper en lowercase. Use the spyingtools to help. why this one is not working ==> ControlTreeView("Everything Options", $hTreeView, "Select", "General|Home") ==> i have the title here , right ? ControlTreeView("Everything Options", $hTreeView, "Select", "General|Home") ControlTreeView("Everything Options", "", $hTreeView, "Select", "General|Home") the first is not working as you miss a parameter Danp2 and DIMM_V2 2 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets 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