Link to home
Start Free TrialLog in
Avatar of alloc
alloc

asked on

Keystrokes in ListView component

Hi experts,
I have minimal experience with delphi and have recently come across a fork in the road with something I'm not able to figure out. I downloaded TCPkeyhook from bitlogic.co.uk and attempted to change the Demo projects. Instead of using the memobox component I'd like to use the listview component. The project I have in mind is a listview with 2 columns using bitlogic's keyhook.dll. It will report the active window to the listview in colum1 and column 2 will hold the keystrokes. It seems everytime I set my project up this way and activate the keyhook project it add's a new item (creates a new cell) for every key pressed. I want column 2 to hold the keys pressed in a given active window until focus leaves that window and keys are typed in a different window, thus triggering a new added item. *e.g*

|Active Window|                 |Key Strokes|
        Run                          I am still in Run
     NotePad                      I am now in Notepad

column's
1.) Active Window
2.) Keystrokes recorded

Ive been doing something like:

// ---------------------------------------------------------------------->
function GetActiveWindowTitle: string;
var
Wnd: Thandle;
PC: Array[0..$FFF] of Char;
begin
Result := '';
Wnd := GetForeGroundWindow; {GetActiveWindow}
GetWindowText(Wnd, PC, sizeof(PC)); {SendMessage(Wnd, wm_GetText, $FFF, Integer(@PC));}
Result := StrPas(PC);
end;

with ListView1.items.add do
    begin
        caption := (GetActiveWindowTitle);
        with subitems do
        begin
            add(AKeyNames.KeyChar);

// ------------------------------------------------------------------>

and ending up with this: *e.g*

|Active Window|             |Key Strokes|
        Run                           W
        Run                            R
        Run                            O
        Run                            N
        Run                            G

I'd like to see how this solution is solved with code, Ive seen plenty of theory and it's got me pretty much nowhere. 500 points to the person who solves this dillema.

You may download the Demo Projects w/ DLL here
http://www.bitlogic.co.uk/downloads/keyhook.zip

Thank You,
 Alloc
Avatar of esoftbg
esoftbg
Flag of Bulgaria image

Hi Alloc,
I've next message during my attemt to download the Demo Projects:

Blocked URL:  www.bitlogic.co.uk
This page has been blocked due to security and Privacy concerns. Some Possible Reasons:
  Tracks or Profiles you.
  Gathers Private and Confidential Information from you.
  Installs software on your machine without your approval.
  Has Unsafe Content.

Do you know something about ?
Avatar of alloc
alloc

ASKER

bitlogic is a company of delphi software developers. No idea why it would say that.
u can downqload project here http://r1422379.hostultra.com/Project.zip
ASKER CERTIFIED SOLUTION
Avatar of esoftbg
esoftbg
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of alloc

ASKER

Thanks esoftgb for responding so promptly,
However, not really what I'm looking for. For a more concise picture of what I want: please view..
http://www.freewebs.com/clantn/untitled.jpg

If I were to have 'Run' as an active window and typed 'hello' I'd want it to appear in the listview as

|Window|     |Keys|            
Run               hello                    <--- I want it to display like this

rather than this....

|Window|     |Keys|
Run                h
Run                e                          <--- this is not what I want, I want the above example
Run                l
Run                l
Run                o

PS. I'm also wanting to use the TCPKeyHook from Bitlogic's website. The Demo Project w/ DLL I linked you to in my 2nd post.

Thanks,
Alloc
Please download the example again ....
I hope it is almost you want.

Best Regards,
Emil
Avatar of alloc

ASKER

Thanks david for the insight, I truely appreciate it. However, I wanted to use the ListView component only and esoftbg's example does exactly what I wanted and doesnt use a memo component. thanks experts ;)

Thanks again.
Alloc
Alloc,
You are welcome !