Solved

Remapping Keys

Posted on 2001-09-03
8
438 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

831 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