Guest Zico Posted June 17, 2008 Share Posted June 17, 2008 Hi, I'm completely new to AutoIt, so many apologies in advance, if I'm not conforming to the correct etiquette etc.!, or if this has already been addressed (if it has, I couldn't find it) Anyway, I have a problem with SelectString not working in a ControlCommand call. I have some code written in C++ that uses WxWidgets and has quite a few GUI windows, that I'm trying to test using AutoIt. I have a ListBox, where the following call works :- ControlCommand("", "", "[CLASS:ListBox; ID:1601]", "AddString", 'FRED') in that I see "FRED" added to the ListBox. I then try to do the following, to select an item in the ListBox, e.g. :- ControlCommand("", "", "[CLASS:ListBox; ID:1601]", "SelectString", 'PETE') where PETE is in the ListBox. At this point I'm hoping that PETE would have been selected (i.e. highlighted) in the ListBox. However, nothing is selected. Am I doing something wrong? Any help would be greatly appreciated. Regards, Zico Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 17, 2008 Share Posted June 17, 2008 Try it with the _GuiCtrlListBox_* functions. 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...
Guest Zico Posted June 18, 2008 Share Posted June 18, 2008 Hi, Many thanks for your reply. I tried using the _GUICtrlListBox functions as you suggested (for which you need the handle) but then I came across another problem. I have a main window application (using C++ and WxWidgets) and within that window I have 3 ListBoxes. Using WinGetHandle I can get a handle for the main window, but when I try and get the handle for one of the ListBoxes I just get blank returned. The AU3Info program can see the handle for the Control, but for some reason, I find it impossible to access this info from within the script. i.e. :- Local $hWnd = WinGetHandle("[CLASS:ListBox; INSTANCE:3]") returns blank. Any ideas anyone? Any help greatly appreciated, with either this or the original problem (SelectString not working for ListBox with ControlCommand) Regards, Zico Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 18, 2008 Share Posted June 18, 2008 Hi, Many thanks for your reply. I tried using the _GUICtrlListBox functions as you suggested (for which you need the handle) but then I came across another problem. I have a main window application (using C++ and WxWidgets) and within that window I have 3 ListBoxes. Using WinGetHandle I can get a handle for the main window, but when I try and get the handle for one of the ListBoxes I just get blank returned. The AU3Info program can see the handle for the Control, but for some reason, I find it impossible to access this info from within the script. i.e. :- Local $hWnd = WinGetHandle("[CLASS:ListBox; INSTANCE:3]") returns blank. Any ideas anyone? Any help greatly appreciated, with either this or the original problem (SelectString not working for ListBox with ControlCommand) Regards, Zico Use ControlGetHandle() for the control and WinGetHandle() for the window. 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...
Guest Zico Posted June 20, 2008 Share Posted June 20, 2008 Many thanks. Your help is greatly appreciated, especially to a newbie like myself. Link to comment Share on other sites More sharing options...
Guest Zico Posted June 20, 2008 Share Posted June 20, 2008 Hi, Many thanks (PsaltyDS) for advising me to use ControlGetHandle instead of WinGetHandle, since I now get the handle for the ListBox. However, I'm now back to a similar problem to the one I started with where AddString works but SelectString does not work. The relevant part of my script is as follows :- Local $hWnd = ControlGetHandle("","",1601) MsgBox(0, "Found Handle", $hWnd) _GUICtrlListBox_AddString($hWnd, 'FREDDY') _GUICtrlListBox_SelectString($hWnd, 'PETE') where 1601 is the ID of the ListBox Control. As I say I'm using WxWidgets - is this a problem? - though it seems strange that AddString works yet SelectString does not, or am I using the wrong function again. Basically, I'm looking for a function that will select (i.e. highlight) a ListBox item. Any help would be greatly appreciated. Kind regards, Zico Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 22, 2008 Share Posted June 22, 2008 Hi,Many thanks (PsaltyDS) for advising me to use ControlGetHandle instead of WinGetHandle, since I now get the handle for the ListBox.However, I'm now back to a similar problem to the one I started with where AddString works but SelectString does not work. The relevant part of my script is as follows :-Local $hWnd = ControlGetHandle("","",1601)MsgBox(0, "Found Handle", $hWnd)_GUICtrlListBox_AddString($hWnd, 'FREDDY')_GUICtrlListBox_SelectString($hWnd, 'PETE')where 1601 is the ID of the ListBox Control. As I say I'm using WxWidgets - is this a problem? - though it seems strange that AddString works yet SelectString does not, or am I using the wrong function again. Basically, I'm looking for a function that will select (i.e. highlight) a ListBox item.Any help would be greatly appreciated.Kind regards, ZicoThe various functions have a lot of caveats about single/multi-select styles, etc. You just have to experiment with your case. For example, try _GuiCtrlListbox_FindString() and then _GuiCtrlListbox_SetCurSel() with the index you get (debug display the index so you know it's being found). 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...
Guest Zico Posted June 23, 2008 Share Posted June 23, 2008 The various functions have a lot of caveats about single/multi-select styles, etc. You just have to experiment with your case. For example, try _GuiCtrlListbox_FindString() and then _GuiCtrlListbox_SetCurSel() with the index you get (debug display the index so you know it's being found). Many thanks for your advice. I did a fair bit of experimenting as you suggested, and discovered that the crucial thing that was missing for me, was a call to _GuiCtrlListbox_BeginUpdate(). Once I'd done this, then the selections using _GuiCtrlListbox_SetSel() and other such similar functions sprang into life.All your help has been much appreciated.Regards, Zico 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