Solved

Remapping Keys

Posted on 2001-09-03
8
437 Views
Last Modified: 2008-02-26
I want to build a program in C++ Builder (Win9X)
that will be able to remap keys systemwide.
For exemple, if I press F1 it will type "// my tag"
and things like that in any program.

Do you have any idea how that could be done?

I searched the net many hours without finding
any clues...

Samples would be welcome, even if not C++ Builder stuff

Thanks!!!

0
Comment
Question by:HellSlayer
8 Comments
 
LVL 2

Expert Comment

by:LoungeLizard
ID: 6451943
Do you want the keys to be remapped only while you are busy with your app, or in general i.e. if you switched to MS Word for example, do you still want the F1 to do something other than it normally would?

In the first case it is easiest to simply use the OnKeyDown event and then examine the key that was pressed and do something about it.
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6452071
Are you talking about doing this in the editor or in a program?

If you're talking about the editor, you may be able to create a macro and assign it to a key.  I personally would choose something other than F1 because it is normally reserved for the HELP key.

If you're talking about a program, you can trap the F1 key and other key.

Are you coding for DOS or Windows?
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6452156
Use TActionList component, it can help you.
Other option: use mainform's Menu property. This produces a static menubar at the top of the screen and every item
of menu can react to some shortcut.

0
 
LVL 11

Accepted Solution

by:
vo1d earned 300 total points
ID: 6452685
if u wanna remap keys systemwide, u will ve to use
SetWindowsHookEx and
LowLevelKeyboardProc() function.
for more details, take a look at the msdn of microsoft.
http://www.msdn.microsoft.com/library/
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:HellSlayer
ID: 6455159
I want to remap the keyboard systemwide
under Win9X

if I press a key I want it to do something
else than it would do normaly
0
 
LVL 3

Expert Comment

by:Diplomat
ID: 6455191
In order to do that you'll need to write a global dll hook that will capture windows messages related to the keyboard, then translate these keystrokes to whatever you want to do. And this will work in any Windows application running.

This is a rather complex project depending on your level of C++ programming. I myself had a similar project and it took me many months to complete. It's not as simple as just by showing some sample codes.

To summarize, you need to master at least the followings:
1. Understand how windows messages are processed.
2. Know how to write a global dll.

One place to start is to look for 'Hook' under VC++ Help, or at the MSDN Library. There you will also be able to access some sample codes provided by Microsoft.
0
 

Author Comment

by:HellSlayer
ID: 6455214
Perfect!!!

I searched everything but hook...   :)

Thank You!
0
 

Author Comment

by:HellSlayer
ID: 6455237
Months!!!!!
...
Well...
I'll do my best...
I hope it wont be that long...

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now