分类: WINDOWS
2010-08-30 14:25:48
This guide focusses on the (re)mapping of the Fn key in Windows. The method used for this isn't limited to the Fn key, but can also be used for other "special" keys, like an eject button or multimedia keys. If you are an Apple user, to an easy way to remap your Fn key in OS X. I have no answers for Linux users, but maybe this site can help you in some way. The guide is based on the remapping of my aluminum Apple Wireless Keyboard in Windows XP. Along the way I'll explain which settings you need to modify to see if and how it will work with your hardware.
In order to make this guide accessible for everyone, no matter their level of expertise in these matters, I'll explain all steps in full detail. Too simple or too technical, you can always jump to the part where you'll find a short list of all the things you need to download and modify.
First of all, some information on the workings of the keyboard and the Fn key in particular. Each key has its own unique code, a scan code, by which the computer it's connected to can find out if a certain key is pressed and when it's released. The Fn key works a bit different. When you press and hold the Fn key, it'll change the scan codes of (some of) the other keys on the keyboard, so that a single key can send different scan codes back to the computer, each connected to a different function. That's why the Fn key is often used on notebooks, smaller keyboards or keyboards with a lot of multimedia keys. That way you can add many functions to a relatively small amount of keys.
The problem is that the Fn key usually doesn't have its own scan code. Depending on the keyboard and the computer it's connect to, it's possible that the Fn key doesn't modify the scan codes of the other keys, and therefor doesn't work. Because it also doesn't send out a scan code of its own, there's no way for the computer to know that there even is an Fn key, let alone what to do when it's pressed in combination with another key. Remapping tools can't help you either, because they're also based on the use of scan codes.
Another problem with the Fn key is its position on the keyboard. On many keyboards it's placed on the bottom left side, next to the Control key. Many people are used to the Control key being on the left side, and you might wish to use that far left Fn key in another way, like making it act as the Control key. Now you're facing the same problems; the Fn key might be working, but it's only changing the scan codes of specific keys, and doesn't send out a scan code of its own.
So, whether your Fn key doesn't work at all, or doesn't work the way you'd like it to, this guide can help you remap the Fn key. Coming up next is the way to make this happen.
Before you read any further, note that it's not always impossible to change the way the Fn key operates. As mentioned before, it depends on the hardware you are using. Toshiba wrote its own software, called to give their users the ability to change the behavior of the Fn key. Some IBM notebooks have an option in the BIOS settings to use the Fn key as a Control key, or to swap those keys. So, before you resort to remapping tools and fixes, check if these easier solutions apply to your hardware.
is an open source macro-making utility for Windows, and one of its many features is creating hotkeys. Micha, one of the members of the AHK forums, a DLL file to add support to AHK for Human Interface Devices. Using this DLL file, it's possible to readout keys of practically every HID; keyboards, mice, remote controls, etc.
First you'll need to setup AutoHotKey and the DLL file for HID support, and find the correct settings of your keyboard, so it'll receive information from your Fn key and other special keys. After you've setup the program and made sure your keyboard is recognized and AHK receives the needed information, you can load another AHK script which specifies what should happen once you press the Fn key. Once you've got this working, the only thing you need to do is learn a little bit about AHK so you can modify the configuration and add the hotkeys you want to use.
Download and install the of AHK. Next, an archive of the original DLL file and a few setup scripts. You can unpack the archive to wherever you like, as long as both the DLL file and the .ahk script remain in the same folder.
Start the register tool, by double clicking AutoHotkeyRemoteControlDLL.ahk
. You'll see a little application that lets you select a device and register it. It shows all the HIDs present on your computer.
In order for my keyboard to work, I selected 1: HID
, where Usage
was set to 1
and UsagePage
to 12
. Hit Register
and press your Fn key. If you see a popup with certain 'RawData' as in
the picture on the right, you've got the right values, and your Fn key
will be recognized.
If the values differ from 1 and 12, write these down because you'll be needing them later on. Try holding the Fn key, click OK
in the popup, and release the Fn key. Notice that the last two values in
the second popup are slightly different. These will tell us whether
your key is pressed or released, enabling us to use it as a modifier.
If your key isn't recognized by one of the devices and their settings as listed in the application, it's unfortunately not likely that you'll get your key to work.
It's been reported that this application
might crash while pressing keys using Windows Vista 64. If this
happens, you can still go on with step two and detect the correct
values manually. Check which HIDs are present on your system using this
app, and see what their values are for Usage
and UsagePage
.
Use those values in the next step, to determine with which settings you
receive a response from a certain key. I've had no problems using this
application in Windows XP SP2 and Windows Vista 32.
If you've received the popups with information by pressing and releasing the Fn key or other special keys, you're almost there. Now we know that the keys are working and your computer knows that they're there, we can continue with the configuration.
In this step, you'll need to download the config. If it opens as text in your browser, right click on the link and save the file as FnMapper.ahk
in the folder where the DLL is located.
Next, we'll go through some of the code, to see what needs adjusting. The excerpts should be easy to find.
These are the values that were set in the application in step 1. Make sure you enter the correct values; they'll be send to the DLL, so it can use them to register your keyboard.
Find this string in the code. First I need to explain what happens at this point. Each key on your keyboard (or any other device for that matter) is connected to a unique bit value. This value is used to identify the specific key, and the scan codes we talked about are based on these bits.
In the first line you see the variable KeyStatus
which receives information about this specific bit from the DLL using
the function NumGet. We need to find out what value corresponds with
the key you're pressing. For this purpose, you can use a message box
(popup) that tells you this value.
The second line is a comment, but it's ready to send you the value of KeyStatus
as soon as you remove the ;
at the beginning of the line. So remove the semicolon, save the file, and execute it by double clicking FnMapper.ahk
.
Once it's running, press your Fn key, or another special key, and write
down the corresponding value. In my case the Fn key on the Apple
Wireless Keyboard has a value of 16
and the Eject key is connected to 8
. I'll use these values as we go along; change them where needed to specify your own keys.
; Filter bit 5 (Fn key)
Transform, FnValue, BitAnd, 16, KeyStatus
; Filter bit 4 (Eject key)
Transform, EjectValue, BitAnd, 8, KeyStatus
The next part is to find out which keys are pressed. If we press the Fn key, it'll send back 16
,
and we know that it's pressed. But what happens when we press both the
Fn key and the Eject key simultaneously? We'll receive a value of 16
+ 8
= 24
. But since 24
isn't the same as 16
, how can we know that the Fn key was also pressed?
To find out just that, we can perform a so called Bitwise-and operation. This will tell us if this 24
value that we received is a single key connected the value 24
, a combination of two keys that also makes 24
, or that it's a combination of our Fn key's 16
and (an)other key(s). In case of the latter, our script will know that
the Fn key was pressed, even when it's combined with others.
Ok,
let's get on with the adjustments. As you might have guessed, this is
the part where you specify your special keys. The second part of the
Transform function, FnValue
in the second line, is the
variable that receives the information about whether this specific key
is pressed or not. So you should change the name of this variable to
something that describes your key.
In this case, I defined two keys, namely FnValue
and EjectValue
. Also change the digit in the Transform function to the KeyStatus
value that corresponded to your key. If you have more than two keys,
just copy and paste the line with the Transform function and change the
variable and digit. I advise you to add some comments starting with ;
so you can see right away which key you're specifying.
Last but not least, the part were we tell our script whether the special key in question is pressed or has been released. It's simply checks what the state of the key is
chinaunix网友2011-01-07 18:06:53
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com