Jump to content

Read all assigned keys from Keyboard


Recommended Posts

Hi All,

I've bought a Ergodox EZ programmable keyboard with layers of key maps (eg, layer 0 = dvorak, layer 1 = numberpad & nav, layer 2 = qwerty, etc), I've also got a small USB screen that can pull information from the registry. What I would like to determine is a way to pull the value of each current key from the keyboard, I can then write the values to the registry and pull them into my USB screen so I can see the keyboard key layout.

I'm stuck with retrieving the key values, I've looked at _IsPressed(), _WinAPI_GetKeyState(), _WinAPI_GetKeyboardState(), _WinAPI_GetKeyboardType(), _WinAPI_GetKeyNameText(), but none of them appear to be able to pull the keyboard key values without user interaction.

The idea being, in pseudo code, bear in mind no error checking etc in this code, "GetKeyValue()" is what I'm needing help with and is a made up function, as is "HardwareKey1" etc:

$keyOnePrev = ""
$numOfKeys = 76
While 1
   $keyOneCurrent = GetKeyValue(HardwareKey1)
   If $keyOneCurrent <> $keyOnePrev Then
      For $key = 1 To $numOfKeys
         $keyToWrite = GetKeyValue(HardwareKey & $key)
         RegWrite("HKEY_CURRENT_USER\Software\myKeyboard", "key" & $key, "REG_SZ", $keyToWrite)
      Next
   EndIf
   $keyOnePrev = $keyOneCurrent
   Sleep(5000)
WEnd

Thanks guys!

Edited by WoodGrain
typos, update $keyOneCurrent script location
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...