AutoHotkey Community

It is currently May 27th, 2012, 7:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: keyboard filter
PostPosted: June 11th, 2006, 10:14 pm 
Offline

Joined: June 11th, 2006, 9:46 pm
Posts: 6
Hi all, I downloaded the windows DDK (device driver kit - for windows XP/SP2) and adapted its keyboard filter template a little. This driver adds the shift+alt key to the stream of keys generated, whenever a key is pressed, and releases the shift+alt as soon as a key is released. .

This is not very useful in itself, but I gave it a try to connect both a USB keyboard, and also a PS/2 keyboard to my computer. These two keyboards have different drivers. If I replace the driver for the PS/2 keyboard with the filter-driver, then whenever I press a key on that keyboard, it will always be accompanied by shift+alt (right-shift and left-alt to be more precise).

This key combination can be intercepted and modified by autohotkey, and turned into some kind of macro, eg with the following script line: "!+a::Send map_A"

I can press A on my usb-keyboard (which has a normal driver) and produce a regular A as output. With the combination of filter driver and autohotkey, I can press A on my ps/2 keyboard and produce the string "map_A".

Whether this is useful or not, is in the eye of the beholder of course.

In case you're interested, the driver + the important part of the source are in this zip file (the driver is in a subdirectory):
http://home.wanadoo.nl/sjaan.bierman/kbfiltr.zip

Note that the sample source is only useful in combination with the kbfilter sample in the DDK package.

(ps. I had to hard-code the scan-codes for the alt/shift keys - namely codes 0x036 and 0x038, so it may not work for all keyboards.).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2006, 1:53 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
That sounds really cool. There have been quite a few requests to support multiple keyboards/mice, and this seems like a great solution.

Thanks for posting your work and for presenting it so clearly.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 14th, 2006, 12:33 pm 
Offline

Joined: June 11th, 2006, 9:46 pm
Posts: 6
It is probably also possible to modify a key into becoming an extended key, but I don't know if and how autohotkey handles that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2006, 1:18 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Extended keys can be distinguished from their non-extended counterparts by the presence of a leading 1 in their scan code (as shown in key history). For example, the down-arrow key is scan code 150, but the down-arrow key on the number pad is 050.

Since most extended scan codes are unused, you could use the SCnnn:: method to create hotkeys out of nonstandard scan codes (ones that you could perhaps generate in your keyboard filter/driver).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2006, 9:50 am 
Offline

Joined: June 11th, 2006, 9:46 pm
Posts: 6
Okay, I created a second filter, which doesn't do much except setting the extended-key flag associated with the scan code. With this filter, the second keyboard will always output an extended key.

However, the keys are no longer recognized as normal characters (try typing an extended-a key - it simply won't show up in your editor), so you will have to access them by their scan code.
In the zip file, I included a scancode-test program which I found somewhere on the internet - that one shows you the scancodes in hexadecimal format, of any key that you type. I understand that it's also possible to use the key-history of autohotkey, but that separate program might be more convenient.

If you load a script with a line like this:
"SC102::Send map_02"
it will convert a key press "1" on the keyboard that uses this filter-driver to the string "map_02". That's because key "1" has scan-code 2.

You can find the driver here: http://home.wanadoo.nl/sjaan.bierman/kbfiltr_ext.zip

Note that if the key is already extended, the filter won't make a difference (eg the arrow key you mentioned, but also the right-alt key, will still act like the arrow key and like right-alt), but those cases are uncommon.

Also note, that as far as I can tell, turning normal keys (like A, or Shift) into extended key values, won't conflict with the most "special" commands that windows recognizes - like turning off your computer. I noticed some overlap though - regarding volume control.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2006, 1:56 pm 
Offline

Joined: June 11th, 2006, 9:46 pm
Posts: 6
I've also made a filter for a PS/2 keyboard, which will create letters by typing a certain combination of keys : namely, one of the A,S,D,F keys in combination with one of the the H,J,K,L,Space keys.
This is not directly relevant to autohotkey, but I thought I'd post it here anyway.
Here's the mapping:

asdf --> asdf
hjkl --> hjkl
space --> space
h+asdf --> wxec
j+asdf --> rvtb
k+asdf --> ynum
l+asdf --> giop
space+asdf --> qz,.

There exist special devices which work this way, and which are recommended for anti-rsi. I've never used such a device, but wanted to make something like this using my own keyboard, to see how it "feels".

http://home.wanadoo.nl/sjaan.bierman/kbfiltr_combo.zip

Note that I hard-coded the scan-codes, so this may not work on every keyboard, but us-layouts should be okay, I think.

Edit: note, that the other keys are not affected, so you can type more or less normally as well. Only the asdf hjkl and space keys will behave slightly different (appear only when released, and create different letters when used in combination).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2006, 12:41 am 
Offline

Joined: July 20th, 2005, 4:49 am
Posts: 65
Hey GeomanNL

I like where you are going with this.

Could you tell me how you downloaded the DDK? It seems to be available only via msdn subscription.

Do you know if you can build the code using mingw without the DDK?

Any other advice about how you built this would be much appreciated

thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2006, 8:05 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
You can dowload it using P2P software.

I did it using Emulle 1 month from now.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2006, 10:01 am 
I used msdn subscription, perhaps the p2p works too.
I don't work with mingw; I'm sorry, but can't give advice there.

I used msvc6 to edit the one source file you need to modify.
Then I enter the command-prompt that is included in the DDK, go to the source directory, and type "make". It then compiles and if any, shows errors which I then edit with the other program. It looks a bit clumsy, but the code is so small that it is not a big problem to do it this way.

I had also downloaded the program keytry.exe, to see the scan codes of the keys.

Also, there is the "Keyboard scan code specification" which I read, I think you need to read it before starting. Follow one of the links here:
http://www.microsoft.com/whdc/device/input/Scancode.mspx

Finally, also check the source file WINDDK\inc\wxp\ntddkbd.h to see which variables are in the most important classes.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2006, 10:02 am 
Offline

Joined: June 11th, 2006, 9:46 pm
Posts: 6
(I accidentally posted this as a guest)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2006, 10:55 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
GeomanNL wrote:
(I accidentally posted this as a guest)
Recently, Chris made a change (using JavaScript) to warn when you post as a Guest without nickname.
Out of curiosity, did you ignored/missed this warning or did it didn't worked (is this an English sentence?) for you?

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2006, 11:13 am 
Offline

Joined: July 20th, 2005, 4:49 am
Posts: 65
majkinetor wrote:
I did it using Emulle 1 month from now.


Back to the future, eh?

I guess you know who won the world cup then... :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2006, 12:35 pm 
Offline

Joined: June 11th, 2006, 9:46 pm
Posts: 6
I saw the warning, copied the message text to a file, but I think I've hit enter in the process, and it got posted anyway :oops:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2006, 8:28 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
2 MisterW
?
No, I don't, I hate football.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2006, 2:43 am 
Offline

Joined: July 20th, 2005, 4:49 am
Posts: 65
majkinetor wrote:
2 MisterW
?
No, I don't, I hate football.


Sorry, I thought you were implying something about timestamps you weren't.

You meant "I did it using Emule 1 month ago"


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group