Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Multiple Keyboards


  • Please log in to reply
2 replies to this topic
Maoserr (not logged in)
  • Guests
  • Last active:
  • Joined: --
Hi,

I have a "keyboard-like" device that shows up in the control panel as a keyboard, so I basically have two usb keyboards on my computer as far as windows is concerned.

Is there anyways AHK can differentiate between the two keyboards? I'm not so sure this is possible because as far as windows is concerned, it doesn't care where the keystrokes came from?

Slanter
  • Members
  • 739 posts
  • Last active: Jul 08 2011 05:26 AM
  • Joined: 28 May 2008
Quick search leads me to believe that this is currently not possible.

http://www.autohotke...tiple keyboards
http://www.autohotke...tiple keyboards
http://www.autohotke...tiple keyboards
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.

Thumpie Bunny Eve
  • Guests
  • Last active:
  • Joined: --
Carl Kenner tackled this failing of AutoHotkey with his software Glove PIE.

I think Carl Kenner would be happy to help this Open Source community, with his insight into multiple keyboard isolation. I'm just a script-Kiddy so i'm not the one who should ask, I'd never understand the details of how he did it! *^.^;;;

Glove PIE can work WITH AutoHotkey, and in fact -Most- of Glove PIE users are familiar with AutoHotkey. Glove PIE is about as difficult to learn as AutoHotkey. and has most of the same functionality. However a new feature to be released in GlovePIE 0.30, will be swallow(), which emulates the function of AutoHotkey's key:: event. AutoHotkey users take for granted the ability to press a key, and not actually have that key display itself, instead that key is omit, and an event is produced in it's place. That's a hard thing to do, keeping the other programs on your PC from finding out that a key was pushed..

To illustrate these differences i'll provide some examples:

Script AutoHotkey
w::Send bobafet
;Script Example: A press of [w] results in Notepad getting the word "bobafet"

Script GlovePIE0.29
Type("bobafet") = keyboard.w
//Script Example: A press of [w] results in Notepad getting the word "wbobafet"

Script GlovePIE0.30 To-Be-Released-Shortly
Type("bobafet") = swallow(keyboard.w)
//Script Example: A press of [w] results in Notepad getting the word "bobafet"


If some of the Open Source community dedicated to the development of this software, would consider contacting Carl Kenner about his work on Glove PIE i'm sure Both our communities could benefit. I would really like to see a provision made for multiple keyboard isolation. The technology is out there, and people are willing to share. To make things easier i'll provide links, in hopes that some of our AutoHotkey community will ask Carl Kenner for his help.


Glove PIE Home Page & Software DL - http://carl.kenner.g...es.com/glovepie
Glove PIE Yahoo forum: http://tech.groups.y...pie/message/605

Here are some quotes from Carl Kenner's GlovePIE0.30 documentation. The following read, may help form a language bridge between Carl and the AutoHotkey Dev's, as terminology between the 2 applications is so radically different at this time.

Glove PIE 0.30 Documentation - GlovePIE is Copyright 2007 by Carl Kenner

GlovePIE 0.30 documentation.rtf

Keyboard

You can read or write to the keyboard using the keyboard object, or just by using the name of the key without anything in front of it.

You can emulate keys that don’t actually exist on your keyboard if you want. For example the multimedia keys, or the Excel key, etc.

NEW! Keyboard emulation will now trigger the auto-repeat you normally get when you hold down a key on a real keyboard. Although you can disable this if you want. To disable it, set:
Keyboard.RepeatFakeKeys = False

Normally a keyboard will only repeat the most recent key that you pressed. GlovePIE will simulate that same behaviour by default. If you hate that feature, and wish you could move diagonally in Notepad by holding two keys at once, you can disable it like this:

Keyboard.RepeatMultipleFakeKeys = False

By default GlovePIE will use the same key repeat rate as your real keyboard. But you can tell GlovePIE to repeat keys at a different rate if you prefer:

Keyboard.RepeatRate = 10 Hz

It is measured in Hz (Hz just means times per second).

Like a real keyboard, keys don't start repeating until after a delay. After the delay it will start repeating. You can set the delay like this:

Keyboard.RepeatDelay = 0.4 seconds

NEW! A very cool feature is that you can now swallow keys. When you swallow keys, other programs will not be able to read them. Only GlovePIE will be able to read them.

For example:

A = swallow(Left)
D = swallow(Right)

This means that when you press the Left arrow key the game won't receive the left arrow key, but it will receive the A key. If you didn't use swallow, the game would receive both the real key (Left) and the fake key (A).

If you have multiple keyboards, you can only swallow the key on all keyboards, not on specific keyboards. If you swallow a key on all keyboards, it is impossible for GlovePIE to tell which keyboard it came from.

Keyboard emulation doesn’t work as well on Windows 9x, because it won’t work in DirectInput games on 9x.

Keys can be either true or false. True when they are down and false when they are up. Some keys (like Pause) only tell you when they are pressed but not released, so the computer assumes they are released soon after.

Unless you are using Windows 9x, the keyboard keys will be the actual physical keys, ignoring whatever keyboard layout you are using.

Keyboard values, for example the F1 key can be set or read in various ways:

Keyboard.F1
Key.F1
F1

Multiple Keyboards

You can read from multiple keyboards with GlovePIE, if you have Windows XP. You will probably need extra USB keyboards. Multiple keyboards are rare, and not especially useful. You can’t write to multiple keyboards, because I haven’t seen any programs other than mine that can tell which keyboard you used.

Just put a number after the word keyboard, like this:

midi.BassDrum1 = keyboard2.Enter

It uses RawInput instead of DirectInput for reading multiple keyboards, so sometimes you can get better or worse results just by changing one of your “keyboard”s to a “keyboard1” so that it uses RawInput instead. You only need to mention keyboard1 once in your script to force it to use RawInput. RawInput will conflict with some exclusive-mode DirectInput software.

You can tell how many keyboards there are with Keyboard.Count. You can tell whether a keyboard exists with Keyboard2.Exists.


Using the information above, i'll quickly illustrate how you can detect output from multiple USB keyboards in GlovePIE 0.30.
type("keyboard 0, key 3.") = swallow(keyboard0.three)
type("keyboard 1, key 3.") = swallow(keyboard1.three)
type("keyboard 2, key 3.") = swallow(keyboard2.three) //Found! ThrustMaster Tactical Board on keyboard2!
type("keyboard 3, key 3.") = swallow(keyboard3.three) //Found! Logitech G15 on keyboard3!
type("keyboard 4, key 3.") = swallow(keyboard4.three)
type("keyboard 5, key 3.") = swallow(keyboard5.three)
type("keyboard 6, key 3.") = swallow(keyboard6.three)
type("keyboard 7, key 3.") = swallow(keyboard7.three) //Found! Trust TrackBall KeyPad keyboard7!
type("keyboard 8, key 3.") = swallow(keyboard8.three)
type("keyboard 9, key 3.") = swallow(keyboard9.three)
//So i found which device is my tactical board! now lets do something with it!
type("I like candy!") = swallow(keyboard2.e) 
//now if i press the button that results in [e] on the ThustMaster, it'll type I like candy!
// Yay!  \o/


My purpose in this response, has been to provide searchable answers for this forum, and for Google-Surfers. The multiple keyboard isolation issue has been asked repeatedly, with no alternatives provided. I myself have asked it. I'm hoping this post is a step toward bridging the gap on technology that has been requested for a number of years now with no lighthouse guiding the way.

I pray this is a start in the right direction.
-Thumpie Bunny Eve