imagine Posted March 19, 2017 Share Posted March 19, 2017 I'm trying to click on a box (there's 3 boxes in a column but I just want to click the first box) that has a class of Syslistview32. I've got the following code using a UDF _GUICtrlListView_ClickItem(0x000000000001089E, 1, "left", True, 1) Only problem is that it doesn't click on the box but rather it clicks the top left of the program window. I'm wondering if the handle is incorrect as the examples I've looked at have $ signs in the handle. Am I implementing the code wrong? Here's the control info from info finder: >>>> Control <<<< Class: SysListView32 Instance: 1 ClassnameNN: SysListView321 Name: Advanced (Class): [CLASS:SysListView32; INSTANCE:1] ID: 1340 Text: List1 Position: 1228, 297 Size: 449, 289 ControlClick Coords: 36, 33 Style: 0x50010409 ExStyle: 0x00000204 Handle: 0x000000000001089E Link to comment Share on other sites More sharing options...
Subz Posted March 19, 2017 Share Posted March 19, 2017 Try ControlListView function, GuiCtrl items are for AutoIt Guis. Link to comment Share on other sites More sharing options...
LarsJ Posted March 19, 2017 Share Posted March 19, 2017 Subz, What do you mean by "GuiCtrl items are for AutoIt Guis."? You have used the same argument here. Neither in this post nor the other post does the original poster refer to native GuiCtrl functions. They are referring to _GuiCtrl UDF functions (note the underscore). It's true that the native GuiCtrl functions (without underscore) which takes a control ID as input parameter are restricted to AutoIt GUIs. But it's definitely not true that the _GuiCtrl UDF functions (with underscore) which takes a control handle as input parameter are restricted to AutoIt GUIs. These functions can generally be used to automate all standard controls in the Control Library whether the controls are contained in an AutoIt GUI or a third-party GUI. Your very short but not completely accurate statement can easily lead to wrong conclusions by new members as apparently happened here. That said, it's quite excellent answers you've given, but I do not like your very short statement. Regards Lars. 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...
Subz Posted March 19, 2017 Share Posted March 19, 2017 @LarsJ Apologies, I had always been under the impression both GuiCtrl and _GuiCtrl could only handle AutoIt Gui's only, just realised that if I used ControlGetHandle I could use the _GuiCtrlListView functions, so my apologies to @Imagine and to anyone else for putting you wrong, truth be told I'm still a novice with Autoit and still learning as I go, probably shouldn't make vague statements, again my apologies. PS: Will update the other post as well Link to comment Share on other sites More sharing options...
LarsJ Posted March 19, 2017 Share Posted March 19, 2017 Yes, I had guessed that you had misunderstood something there. Good that we got it sorted out. You are a valuable member of our forums. Lars. 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...
Bowmore Posted March 19, 2017 Share Posted March 19, 2017 @imagine You are correct in surmising that the control handle is in correct. Handles are allocated by the operating by the operating system when a window or control is created. Every time an application is run the handles allocated will be different. Therefore we need to read the handle values in our code before we can use them. Normally you will only have to read the handle once and store it in a variable and then use that variable whenever you need the control handle. This is a simple example of how to do that. ; Get the handles for the main application window and theSyslistview32 control Local $hWnd = WinWait("Title of the Window containing Syslistview32", "", 10) Local $hlistView = ControlGetHandle($hWnd, "", "List1") _GUICtrlListView_ClickItem($hlistView, 1, "left", True, 1) "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
imagine Posted March 19, 2017 Author Share Posted March 19, 2017 (edited) Hi @Subz @LarsJ, I always appreciate any help I can get, it's what makes forums like this so enjoyable for me. I'm also just starting out with Autoit as well and find the wealth of information here astonishing. Makes me wonder why I had not discovered Autoit earlier in my life. @Bowmore, your code worked great. The only issue is that the list has 3 columns (#, Selected, Visible, Part Name) as seen in my screenshot. With the code, what happens is that the # column is selected instead of the Selected column where the check boxes are. Instead of clicking on the check boxes, the entire row is selected or highlighted because the mouse clicks on for example, 2 in the # column instead of the check box. I've removed the # column and that allowed the code to selected the check boxes instead. So I assume that by default, anything in the # column will be clicked on first. Is there any way to specify which column in the list to click? Edited March 19, 2017 by imagine Link to comment Share on other sites More sharing options...
Subz Posted March 19, 2017 Share Posted March 19, 2017 Can you try: _GUICtrlListView_SetItemChecked($hlistView, 1, True) Link to comment Share on other sites More sharing options...
imagine Posted March 19, 2017 Author Share Posted March 19, 2017 (edited) 2 hours ago, Subz said: Can you try: _GUICtrlListView_SetItemChecked($hlistView, 1, True) With the inclusion of that line, it still defaults to clicking on the # column first. Maybe _GUICtrlListView_SetColumn will work..I'll check and report back. Edited March 19, 2017 by imagine Link to comment Share on other sites More sharing options...
imagine Posted March 20, 2017 Author Share Posted March 20, 2017 Tried the following to get the code to click on the check box rather than column # but none seem to work. #include <GuiListView.au3> Local $hWnd = WinWait("Materialise Magics 21.0 - Untitled", "", 10) Local $hlistView = ControlGetHandle($hWnd, "", "List1") _GUICtrlListView_GetColumn($hWnd, 1) _GUICtrlListView_SetItemChecked($hlistView, 1) _GUICtrlListView_SetColumn($hWnd, 1, "List1") _GUICtrlListView_ClickItem($hlistView, 1, "left", True, 1) 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