AutoHotkey Community

It is currently May 26th, 2012, 4:10 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: April 13th, 2009, 10:39 pm 
Offline

Joined: December 30th, 2006, 4:13 pm
Posts: 132
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 13th, 2009, 10:50 pm 
Offline

Joined: July 30th, 2007, 11:32 pm
Posts: 581
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 13th, 2009, 10:58 pm 
Offline

Joined: December 30th, 2006, 4:13 pm
Posts: 132
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 13th, 2009, 11:01 pm 
Offline

Joined: December 30th, 2006, 4:13 pm
Posts: 132
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
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".)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 13th, 2009, 11:10 pm 
Offline

Joined: July 30th, 2007, 11:32 pm
Posts: 581
Donny Bahama wrote:
That looks like something I'd have to use via DLLCall


Not at all :D
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2009, 5:55 am 
Offline

Joined: December 30th, 2006, 4:13 pm
Posts: 132
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
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. :(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2009, 8:27 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
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 FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2009, 8:36 am 
Offline

Joined: December 30th, 2006, 4:13 pm
Posts: 132
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
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!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, gamax92, poserpro and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group