AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Selecting an item from a listbox (via keyboard)?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
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

PostPosted: Mon Apr 13, 2009 9:39 pm    Post subject: Selecting an item from a listbox (via keyboard)? Reply with quote

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
View user's profile Send private message
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Mon Apr 13, 2009 9:50 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Donny Bahama



Joined: 30 Dec 2006
Posts: 132
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA

PostPosted: Mon Apr 13, 2009 9:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
Donny Bahama



Joined: 30 Dec 2006
Posts: 132
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA

PostPosted: Mon Apr 13, 2009 10:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Mon Apr 13, 2009 10:10 pm    Post subject: Reply with quote

Donny Bahama wrote:
That looks like something I'd have to use via DLLCall


Not at all Very Happy
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
View user's profile Send private message Visit poster's website
Donny Bahama



Joined: 30 Dec 2006
Posts: 132
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA

PostPosted: Tue Apr 14, 2009 4:55 am    Post subject: Reply with quote

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. Sad
Back to top
View user's profile Send private message
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Tue Apr 14, 2009 7:27 am    Post subject: Reply with quote

If it supports controlsend:

Browse a listbox with arrow keys
http://www.autohotkey.com/forum/topic32143.html

or you can use a number / letter for each listbox :

1 this1
2 that1
a this2
b that2

if you type 1 it would select this1 if you type a it would select this2 etc
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
Donny Bahama



Joined: 30 Dec 2006
Posts: 132
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA

PostPosted: Tue Apr 14, 2009 7:36 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group