Solved

Remapping Keys

Posted on 2001-09-03
8
431 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:HellSlayer
Comment Utility
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
Comment Utility
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
Comment Utility
Perfect!!!

I searched everything but hook...   :)

Thank You!
0
 

Author Comment

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

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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 video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

743 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

17 Experts available now in Live!

Get 1:1 Help Now