Jump to content

Can't check listbox item


Recommended Posts

Hi folks

I have a problem with listboxes.

I have a listbox which shows me the sheet names form a selected excel.It will show the last element selected by default.

Posted Image

the code I am using is;

ControlFocus("myapp", "Sheet Details:", $hwnd)
_GUICtrlListBox_SelectString($hwnd, "Sheet4", -1)
send("{SPACE}")

Problem is that the checkbox and the selection aren't tied to each other. SO I have to send an extra spacebar press to check the item. Now if I wanted to check Sheet4 item in the listbox and if its already checked, it will simply uncheck it (as spacebar is still pressed)

I need a way of finding if the item at a certain index is checked or not. Or if possible, set check or uncheck on it irrespective of its current check status.

please note that the control id is for the entire list box and I can't have the controls for each element in the listbox.

any ideas?

regards

Rishav

Edited by Rishav
Link to comment
Share on other sites

  • Moderators

Most people here use Excel.au3 file in the Example scripts to manipulate data in excel.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...

Hi folks

I have a problem with listboxes.

I have a listbox which shows me the sheet names form a selected excel.It will show the last element selected by default.

Posted Image

the code I am using is;

ControlFocus("myapp", "Sheet Details:", $hwnd)
_GUICtrlListBox_SelectString($hwnd, "Sheet4", -1)
send("{SPACE}")

Problem is that the checkbox and the selection aren't tied to each other. SO I have to send an extra spacebar press to check the item. Now if I wanted to check Sheet4 item in the listbox and if its already checked, it will simply uncheck it (as spacebar is still pressed)

I need a way of finding if the item at a certain index is checked or not. Or if possible, set check or uncheck on it irrespective of its current check status.

please note that the control id is for the entire list box and I can't have the controls for each element in the listbox.

any ideas?

regards

Rishav

hello Rishav

Have u used these commands which iam giving below ? It will select both the checkbox and listitems.look into the

script i have used _GUICtrlListBox_ClickItem ($hwnd,$ListboxIndex,"",False,2)(no 2) at the last of this function and why do u need for each element.?it will click twice one for item and second click for checkbox.

$hwnd=ControlGetHandle("title","text","ControlID")

$ListboxIndex = _GUICtrlListBox_SelectString($hWnd, "Sheet4")

_GUICtrlListBox_ClickItem ($hwnd,$ListboxIndex,"",False,2)

Link to comment
Share on other sites

hello Rishav

Have u used these commands which iam giving below ? It will select both the checkbox and listitems.look into the

script i have used _GUICtrlListBox_ClickItem ($hwnd,$ListboxIndex,"",False,2)(no 2) at the last of this function and why do u need controlid for each element.?it will click twice one for item and second click for checkbox.

$hwnd=ControlGetHandle("title","text","ControlID")

$ListboxIndex = _GUICtrlListBox_SelectString($hWnd, "Sheet4")

_GUICtrlListBox_ClickItem ($hwnd,$ListboxIndex,"",False,2)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...