| View previous topic :: View next topic |
| Author |
Message |
Donny Bahama
Joined: 30 Dec 2006 Posts: 132 Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
|
Posted: Mon Apr 13, 2009 9:39 pm Post subject: Selecting an item from a listbox (via keyboard)? |
|
|
I can set the focus on a listbox, I can use up/down keys to navigate, but is there any way to select it via the keyboard?
I don't see anything in the docs under A_EventInfo, and pressing Enter or spacebar doesn't work. I know I could probably use a &Accelerator key, but that doesn't work for my application. Likewise, GuiControl (if it includes some method of doing this) won't help me either.
I'd be surprised if there was no means of doing this; it seems like such an obvious use case. What am I missing? |
|
| Back to top |
|
 |
TheGood
Joined: 30 Jul 2007 Posts: 580
|
Posted: Mon Apr 13, 2009 9:50 pm Post subject: |
|
|
Are you trying to select a specific item using the keyboard, or only set the focus on the listbox?
I don't think it's what you want, but if you just want to select a specific index, then use the LB_SETCURSEL message. |
|
| Back to top |
|
 |
Donny Bahama
Joined: 30 Dec 2006 Posts: 132 Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
|
Posted: Mon Apr 13, 2009 9:58 pm Post subject: |
|
|
Thanks for the help!
| TheGood wrote: | | Are you trying to select a specific item using the keyboard, or only set the focus on the listbox? | Trying to select a specific item.
| Quote: | | I don't think it's what you want, but if you just want to select a specific index, then use the LB_SETCURSEL message. | That looks like something I'd have to use via DLLCall (with which I have no experience) but that's not an option for me since it's unsupported by AHKCE. |
|
| Back to top |
|
 |
Donny Bahama
Joined: 30 Dec 2006 Posts: 132 Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
|
Posted: Mon Apr 13, 2009 10:01 pm Post subject: |
|
|
| I guess an OK button could be a workaround. (This is a Pocket PC/Windows Mobile app, and I'm trying to make it "finger-friendly" which necessarily includes support for the "D-Pad".) |
|
| Back to top |
|
 |
TheGood
Joined: 30 Jul 2007 Posts: 580
|
Posted: Mon Apr 13, 2009 10:10 pm Post subject: |
|
|
| Donny Bahama wrote: | | That looks like something I'd have to use via DLLCall |
Not at all
Here's an example:
| Code: | Gui, Add, ListBox, hwndhLB, Item1|Item2|Item3
Gui, Show
;Select the second item. LB_SETCURSEL
;The index is 0-based which means that the first item is index 0 and the second item is index 1, hence the wParam of 1.
SendMessage, 390, 1, 0,, ahk_id %hLB%
Return
|
|
|
| Back to top |
|
 |
Donny Bahama
Joined: 30 Dec 2006 Posts: 132 Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
|
Posted: Tue Apr 14, 2009 4:55 am Post subject: |
|
|
Thank you! That's pretty cool and I'm sure I'll get some use out of it some day, but for my current project, AHKCE doesn't support SendMessage.  |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
|
| Back to top |
|
 |
Donny Bahama
Joined: 30 Dec 2006 Posts: 132 Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
|
Posted: Tue Apr 14, 2009 7:36 am Post subject: |
|
|
| Sadly, ControlSend is unsupported as well. The numbers/letters option is probably preferable to an OK button since I'm working with such limited screen space (240x320). Thanks for the suggestion! |
|
| Back to top |
|
 |
|