Simulating keyboard actions with delphi

Hi experts!

I have this problem: In a program I am working on, I have some custom Listbox with items. I can click on one item and the item will be selected... So I use the information of the item and process it. As soon I process this item, I want to simulate the action of doubleclick to go to the next item. Because this is a custom made listbox, I don't have access to indexitems. So I guess is a good idea to simulate the click (or double click) over the next item.

Is there a way to do this thru delphi 7?

regards
Manuel Lopez (lopem)
LVL 3
Manuel Lopez-MichelonePhD candidateAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

2266180Commented:
use mouse_event for mouse or keybd_event for keyboard
see the following for examples and explanatiosn:
mouse: http://delphi.about.com/od/vclusing/a/mouseadvanced.htm
keyboard: http://delphi.about.com/od/adptips2004/a/bltip0604_4.htm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Geert GOracle dbaCommented:
you are developping a Delphi application
and by stating  "Because this is a custom made listbox"
what do you mean ?

surely it is a Delphi component with events ?
and if so it should have properties too
maybe like FocusedIndex or ItemIndex
i couldn't guess why these properties are unavailable
but if so, it is a poor component
how do you know what item was clicked or dblclicked ?

there should be an event too : OnDblClick
if nothing is assigned then the code is in the component ?

and maybe you can subclass so you have acess to all properties (including private and protected) with

type
  TMagicListbox = class(TYourListbox)
  end;

and when you use the TYourListbox cast it to the new type:
TMagicListbox(YourListbox)
and you will have all properties

TMagicListbox(YourListbox).ItemIndex := 0; // for the first element

TMagicListbox(YourListbox).ItemIndex := TMagicListbox(YourListbox).ItemIndex +1;
to focus the next element

0
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

2266180Commented:
>>  you can subclass so you have acess to all properties (including private and protected)

that is half true. with subclassing yuo get access to protected stuff only. not private :) in order to get access to private stuff, you need to declare the subclassing calss in teh same unit as the subclassed class. (I say stuff so to include: properties, members and methods)
0
Geert GOracle dbaCommented:
>>ciuly
i stand corrected about that stuff :D

0
Manuel Lopez-MichelonePhD candidateAuthor Commented:
Hi, Geertz,

I am using some components to build some chess application. They are very well written but some of the components have few peculiar behaviour, for instance, the custom Listbox I was talking about (a way to load a PGN file to a listbox. A PGN file is a collection of chess games in some format called Portable Game Notation).

Of course teh component has OnDoubleclick, OnClick, etc. methods but they don't work as usual. For instance, if you want to see a chess game, there is not enough just to go to PGN1.Items[PGN1.ItemIndex]. For some reason you have to push the [enter]  key over the item selected or double click on it.  If you dont do this, you can't have access to a particular chess game. If I put the onDoubleClick method in my procedure, it always gives to me some sort of error saying the parameters are incorrect. Of course, I am doing something wrong but I couldn't figure out was wrong. To make things worst, the help file is in german  so I can actually understand some of it using altavista online translator.

I found that the simple way to accomplish my task and to get rid of the error was just to insert some [enter] key thru programming or simulate a doubleclick over the item I selected.  I know this is not the best thing to do but I was really fed up with the error...

When I read your remark I was thinking how it is possible to have some simple problems with these components? In any case, I actually solved my problems but I know I have to dig a little bit more around the chess components I am using.

best regards and thanks for your comments.

Manuel López (lopem)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.