Solved

Remapping Keys

Posted on 2001-09-03
8
443 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

756 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