Solved Advanced Caps Lock remap

Djhg2000

New member
Local time
8:45 PM
Messages
10
Hi!


In Debian Sid I have set up my Caps Lock key to open a new browser tab with Google in my default browser unless I have new mail in which case the Caps Lock LED will light up and the mapping will change to GMail.

This is accomplished with a few lines of BASH and some C (full source available if anyone wants it).


Now I'm asking all of the Windows 7 gurus reading this if there's a way to do the same in 7. The LED part is kind of optional, but I need some sort of visual hint if the key is dynamically mapped.

Unfortunately for me the C code isn't very portable as it talks directly to the Linux kernel through the IOCTL interface, meaning I'd have to rewrite major parts of it from scratch (if it can be done easily with standard APIs I might consider it though).


If I have to code or script anything I'll provide the full source and any compiled binaries in return to the forum.


Thanks in advance
/ Djhg2000


Update:
I wrote a script for AutoHotkey Basic to do just what I wanted.
:party: Thanks to everyone here for being so friendly and helpful! :party:
 
Last edited:

My Computer

OS
Windows 7 Home Premium 64-bit / Debian Sid 64-bit
For one, I'd LOVE to have that source code... xD
Two, I'm quite sure there's a way to do it in 7, you just have to find out how to make everything work together. I'll take a look into it and see what I can find out about the different things involved. Heck, I might even take a crack at doing it myself if I can (Edit: just checked, my usual language has no methods of interfacing with online junk, so nevermind). Then again, you're probably better at programming than I am.
Also, welcome to SevenForums. :)
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom built
OS
Windows 8 Pro 64-bit
CPU
Intel Core i7 950 @4.4GHz
Motherboard
EVGA 131-GT-E767
Memory
12GB DDR3 1333MHz @1400 (9-9-9-24)
Graphics Card(s)
2x AMD Radeon HD 6770
Sound Card
Sound Blaster Audigy
Monitor(s) Displays
Acer S231HL + Acer E19T5W
Screen Resolution
1920x1080 + 1440x900
Hard Drives
128GB Samsung 840 Pro
1TB Seagate Barracuda 7200RPM 64mb
500GB Seagate Barracuda 7200RPM 16mb
PSU
Corsair GS800
Case
Custom-made
Cooling
CM Hyper212+, lots of fans
Keyboard
NMB RT8255C+
Mouse
Func MS-3
Internet Speed
30/1.5
Antivirus
Microsoft Security Essentials/Spybot SD/Malwarebytes
Browser
Google Chrome
Other Info
Onkyo TX-27 receiver & two Realistic Optimus T100s.
Thank you, but I'm just a hobby programmer so I'd guess my code is pretty far from professional level code ;)

Actually, the mail checking stuff is done by curl in the BASH script (which mostly just glues things together for now) and the C code handles (or rather is supposed to) handle stuff you must do as the root user.

It turns out the curl utility is available for Windows as well (both 32- and 64-bit) in addition to BASH with all of its features which means all that's missing to have an experimental setup would be the key handling.

Turns out Cygwin supports the IOCTL related functions, so I'll have a shot at compiling the unmodified source and report back once that's done. Then all I'll have to do is remap the Caps Lock key to the launcher script and figure out a simple way to handle GUI inputs without the zenity utility (if Cygwin provides this too I'll be so happy!).

So even if there's a Linux emulation layer in there most of the stuff should actually work right off the bat. You might even have the experimental setup up and running by tomorrow if we're lucky! :party:
 

My Computer

OS
Windows 7 Home Premium 64-bit / Debian Sid 64-bit
It might work within cygwin apps, but it probably won't work for windows in general.

Typically in the past what you had to do was install a lower KB filter driver which you could do whatever you wanted with keystrokes before they entered userland. But Vista and 7 have made that almost impossible because it is like the primary way a keylogger is able to steal your CC#s etc :(

Best bet is to find a KB that allows you as a matter of the driver to remap keys. Several gaming type KBs have this kind of functionality, though I can't name one that I know for a fact can do this exact thing with that specific key. Logitech gaming KBs have extra fuinction keys you can map to launch programs and such as well.

If you want to actually code this and be able to hand it out to people, I would actually ask this Q in a windows programming forum, like one of the microsoft programing news feeds (search them first). It's going to be a very deep and specific answer. KB filter drivers were a bit trickey in the old XP days. Now it's even worse :) In order to distribute and hope that it installs on other peoples machines (especially x64 machines) you may even have to get it codesigned. Not fun!
 

My Computer

Computer Manufacturer/Model Number
Scratch built
OS
Windows 7 x64 Ultimate
CPU
i7 960
Motherboard
Asus P6X58D
Memory
12 Gig Corsair Dominator
Graphics Card(s)
Nvidia 480
Sound Card
Maudio Delta 44 + breakout box
Monitor(s) Displays
Dell UltraSharp U2410 24in and Samsung 21 dual monitors
Screen Resolution
1920x1200 and 1280x1024
Hard Drives
Primary: Intel X-25M G2 160G SSD
Secondary: Segate baracuda 1.0 TB
HDs in AHCI mode.
PSU
Corasair TX850
Case
Cooler Master HAF
Cooling
Corsair H50
Keyboard
Logitech G15 + N52 game pad
Mouse
Logitech MX518
Internet Speed
15kbs down 4.5kbps up
Other Info
WEI 7.6
CPU & RAM 7.6
Graphics 7.9
Hard disk 7.7
It might work within cygwin apps, but it probably won't work for windows in general.

Typically in the past what you had to do was install a lower KB filter driver which you could do whatever you wanted with keystrokes before they entered userland. But Vista and 7 have made that almost impossible because it is like the primary way a keylogger is able to steal your CC#s etc :(

Best bet is to find a KB that allows you as a matter of the driver to remap keys. Several gaming type KBs have this kind of functionality, though I can't name one that I know for a fact can do this exact thing with that specific key. Logitech gaming KBs have extra fuinction keys you can map to launch programs and such as well.
I think it is still possible to remap keys within systemwide level (or atleast pseudo-systemwide) with normal KBs
AutoHotkey - Free Mouse and Keyboard Macro Program with Hotkeys and AutoText ?

Not sure about LED part :S

Edit: actually LED can be controlled aswell Keyboard LED control (capslock/numlock/scrolllock lights)
 

My Computer

OS
Windows 7 Ultimate x86 SP1
^ Was literally just about to post this.
Remapping the keys using AHK's really easy, plus all you'd have to do is just write a very small program that would map the keys and set the LEDs according to the situation.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom built
OS
Windows 8 Pro 64-bit
CPU
Intel Core i7 950 @4.4GHz
Motherboard
EVGA 131-GT-E767
Memory
12GB DDR3 1333MHz @1400 (9-9-9-24)
Graphics Card(s)
2x AMD Radeon HD 6770
Sound Card
Sound Blaster Audigy
Monitor(s) Displays
Acer S231HL + Acer E19T5W
Screen Resolution
1920x1080 + 1440x900
Hard Drives
128GB Samsung 840 Pro
1TB Seagate Barracuda 7200RPM 64mb
500GB Seagate Barracuda 7200RPM 16mb
PSU
Corsair GS800
Case
Custom-made
Cooling
CM Hyper212+, lots of fans
Keyboard
NMB RT8255C+
Mouse
Func MS-3
Internet Speed
30/1.5
Antivirus
Microsoft Security Essentials/Spybot SD/Malwarebytes
Browser
Google Chrome
Other Info
Onkyo TX-27 receiver & two Realistic Optimus T100s.
Actually I found this:
Keyboard Remapping: CAPSLOCK to Ctrl and Beyond - Scancode Map, registry, keyboard, WM_APPCOMMAND, Flip3D, 3dFlip, Win7, Vista, dwmApi

With a registry hack you can reassign the Caps Lock key to, say, VK_BROWSER_HOME which has the scancode "E0 32". This means the binary key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\Scancode Map" should contain this:
Code:
00 00 00 00 00 00 00 00 02 00 00 00 E0 32 3A 00 00 00 00 00

Now, it so happens that VK_BROWSER_HOME has a reconfigurable action (APPCOMMAND_BROWSER_HOME) and is AppKey 7. This should mean that if we rename the key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\7\Association" to "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\7\ShellExecute" and give it the following value:
Code:
"start http://www.google.com"
we should get a nice new tab of Google each time we press caps lock.

At least that's the theory as I have yet to reboot and try it.
Assuming this does work, we can eventually replace that start command with the path to my script which also keeps track of the current new mail status.

To summarize:
  1. Remap Caps Lock to VK_BROWSER_HOME
  2. Replace the default action with the path to my script
  3. Now each time you press the Caps Lock key the script will redirect you to either Google or GMail
  4. Set up some sort of visual hint if you have new mail

Now lets pretend I knew this more than 10 minutes ago ;)

Edit:
I'd like to avoid closed source tools to accomplish this (it's in my nature, I'm a Linux guy after all :geek:) even though that LED stuff looks similar to the IOCTL calls with a 3-bit bitmask for controlling the LEDs.
Now we know it's possible and we just have to figure out how AHK does it.
 

My Computer

OS
Windows 7 Home Premium 64-bit / Debian Sid 64-bit
Glad you found a solution. Please report back, how it works out.

The only thing I am missing is how to check mail status, i am sure it is trivial. But I haven't really searched it yet :p

p.s. If you were reffering to AHK, it is open source and licenced under GNU GPL.
 

My Computer

OS
Windows 7 Ultimate x86 SP1
Glad you found a solution. Please report back, how it works out.

The only thing I am missing is how to check mail status, i am sure it is trivial. But I haven't really searched it yet :p

p.s. If you were reffering to AHK, it is open source and licenced under GNU GPL.

Actually it didn't work too well, I think I set up the key remap wrong but I can't find where the error is.

On another note, you're right, I found this https://github.com/Lexikos/AutoHotkey_L :party:

Looks like I'll be playing around with AHK for a while ;)
 

My Computer

OS
Windows 7 Home Premium 64-bit / Debian Sid 64-bit
I will try to look into it in more details aswell, once I actually get to PC. ( can't realy do anything on phone)

But don't get your expectations too high on me, I am not even amature programmer, I just like experementing with stuff :)
 

My Computer

OS
Windows 7 Ultimate x86 SP1
Ok so I've looked into this a bit more and I'm currently porting the BASH script to AHK, stay tuned for a quick and dirty test version ;)

Edit:
If you want to have a sneak-peek, this is the script I started out with:
http://www.shellperson.net/quickly-check-gmail-with-bash/
It has evolved quite a bit since I found it but I want to make sure I don't forget to give him proper credit for the whole "detect new mail"-part :)

Edit2:
I'm stuck at trying to make the script detect new mail properly (currently hangs if I have new mail) and the keyboard LEDs doesn't seem to be working properly for me as they all stay blank. It's also getting a bit too late here (approx. 3:50 AM local time) so I'll post what I have so far and keep going tomorrow (I must say for someone who's used to C and BASH the syntax of AHK feels kind of awkward to work with).

Code:
KeyboardLED(4,"on")
InputBox, Username, Username, Enter username for mail.google.com
InputBox, Password, Password, Enter password for mail.google.com, hide
KeyboardLED(4,"off")

loop
{
	; Thanks to aMailuhr for this line at http://www.autohotkey.com/forum/topic4486.html
	urldownloadtofile, https://%Username%:%Password%@mail.google.com/mail/feed/atom, temp.txt

	i := 0
	loop, read, temp.txt
	{
		if (++i == 5)
		{
			if (A_LoopReadLine != "<fullcount>0</fullcount>")
			{
				Capslock::Run mail.google.com
				MsgBox, New mail
				KeyboardLED(4,"on")
			}
			else
			{
				;Capslock::Run www.google.com ;Throws an error at me for remaping the key twice, fatal limitation?
				MsgBox, %A_LoopReadLine%
				KeyboardLED(4,"off")
			}
			sleep 5000
		}
	}
}

; Thanks to evl, Shimanov, Peter and JGR for the KeyboardLED function at http://www.autohotkey.com/forum/topic10532.html
KeyboardLED(LEDvalue, Cmd)  ; LEDvalue: ScrollLock=1, NumLock=2, CapsLock=4 ; Cmd = on/off/switch 
{ 
  Static h_device 
  If ! h_device ; initialise 
    { 
    device =\Device\KeyBoardClass0 
    SetUnicodeStr(fn,device) 
    h_device:=NtCreateFile(fn,0+0x00000100+0x00000080+0x00100000,1,1,0x00000040+0x00000020,0) 
    } 

  VarSetCapacity( output_actual, 4, 0 ) 
  input_size = 4 
  VarSetCapacity( input, input_size, 0 ) 

  If Cmd= switch  ;switches every LED according to LEDvalue 
   KeyLED:= LEDvalue 
  If Cmd= on  ;forces all choosen LED's to ON (LEDvalue= 0 ->LED's according to keystate) 
   KeyLED:= LEDvalue | (GetKeyState("ScrollLock", "T") + 2*GetKeyState("NumLock", "T") + 4*GetKeyState("CapsLock", "T")) 
  If Cmd= off  ;forces all choosen LED's to OFF (LEDvalue= 0 ->LED's according to keystate) 
    { 
    LEDvalue:= LEDvalue ^ 7 
    KeyLED:= LEDvalue & (GetKeyState("ScrollLock", "T") + 2*GetKeyState("NumLock", "T") + 4*GetKeyState("CapsLock", "T")) 
    } 
  ; EncodeInteger( KeyLED, 1, &input, 2 ) ;input bit pattern (KeyLED): bit 0 = scrolllock ;bit 1 = numlock ;bit 2 = capslock 
  input := Chr(1) Chr(1) Chr(KeyLED) 
  input := Chr(1) 
  input= 
  success := DllCall( "DeviceIoControl" 
              , "uint", h_device 
              , "uint", CTL_CODE( 0x0000000b     ; FILE_DEVICE_KEYBOARD 
                        , 2 
                        , 0             ; METHOD_BUFFERED 
                        , 0  )          ; FILE_ANY_ACCESS 
              , "uint", &input 
              , "uint", input_size 
              , "uint", 0 
              , "uint", 0 
              , "uint", &output_actual 
              , "uint", 0 ) 
} 

CTL_CODE( p_device_type, p_function, p_method, p_access ) 
{ 
  Return, ( p_device_type << 16 ) | ( p_access << 14 ) | ( p_function << 2 ) | p_method 
} 


NtCreateFile(ByRef wfilename,desiredaccess,sharemode,createdist,flags,fattribs) 
{ 
  VarSetCapacity(fh,4,0) 
  VarSetCapacity(objattrib,24,0) 
  VarSetCapacity(io,8,0) 
  VarSetCapacity(pus,8) 
  uslen:=DllCall("lstrlenW","str",wfilename)*2 
  InsertInteger(uslen,pus,0,2) 
  InsertInteger(uslen,pus,2,2) 
  InsertInteger(&wfilename,pus,4) 
  InsertInteger(24,objattrib,0) 
  InsertInteger(&pus,objattrib,8) 
  status:=DllCall("ntdll\ZwCreateFile","str",fh,"UInt",desiredaccess,"str",objattrib,"str",io,"UInt",0,"UInt",fattribs 
                  ,"UInt",sharemode,"UInt",createdist,"UInt",flags,"UInt",0,"UInt",0, "UInt") 
  return % ExtractInteger(fh) 
} 


SetUnicodeStr(ByRef out, str_) 
{ 
  VarSetCapacity(st1, 8, 0) 
  InsertInteger(0x530025, st1) 
  VarSetCapacity(out, (StrLen(str_)+1)*2, 0) 
  DllCall("wsprintfW", "str", out, "str", st1, "str", str_, "Cdecl UInt") 
} 


ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4) 
; pSource is a string (buffer) whose memory area contains a raw/binary integer at pOffset. 
; The caller should pass true for pSigned to interpret the result as signed vs. unsigned. 
; pSize is the size of PSource's integer in bytes (e.g. 4 bytes for a DWORD or Int). 
; pSource must be ByRef to avoid corruption during the formal-to-actual copying process 
; (since pSource might contain valid data beyond its first binary zero). 
{ 
  Loop %pSize%  ; Build the integer by adding up its bytes. 
    result += *(&pSource + pOffset + A_Index-1) << 8*(A_Index-1) 
  if (!pIsSigned OR pSize > 4 OR result < 0x80000000) 
    return result  ; Signed vs. unsigned doesn't matter in these cases. 
  ; Otherwise, convert the value (now known to be 32-bit) to its signed counterpart: 
  return -(0xFFFFFFFF - result + 1) 
} 


InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4) 
; The caller must ensure that pDest has sufficient capacity.  To preserve any existing contents in pDest, 
; only pSize number of bytes starting at pOffset are altered in it. 
{ 
  Loop %pSize%  ; Copy each byte in the integer into the structure as raw binary data. 
    DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF) 
}
 
Last edited:

My Computer

OS
Windows 7 Home Premium 64-bit / Debian Sid 64-bit
ok, I changed it a bit and tried it.

*Without LED lights
*I used direct username and Password
*It appears we need if/else arguments inside the Hotkey, to eliminate duplicate hotkey error.
Code:
loop
{
	; Thanks to aMailuhr for this line at http://www.autohotkey.com/forum/topic4486.html
	urldownloadtofile, https://Username:[email protected]/mail/feed/atom, temp.txt

	i := 0
	loop, read, temp.txt
	{
		if (++i == 5)
		{
Capslock::
			if (A_LoopReadLine != "<fullcount>0</fullcount>")
			{


Run https://mail.google.com
				
			}
			else 
			{
				

Run https://www.google.com
			}
			sleep 5000
return
		}
	}
}

The problem is, that "A_LoopReadLine" is doing something wrong as in this script case it always open gmail.
However you can test that if/else argument is working, by changing
Code:
A_LoopReadLine[COLOR="Red"] !=[/COLOR] "<fullcount>0</fullcount>
to
Code:
A_LoopReadLine [COLOR="Red"]=[/COLOR] "<fullcount>0</fullcount>

In this case it will always open google...
Thus it means that mail fetch script always reporting as:
Code:
 A_LoopReadLine != "<fullcount>0</fullcount>


P.S. sorry for bad formating. had to work with notepad... :eek:
 

My Computer

OS
Windows 7 Ultimate x86 SP1
Here you go, an initial sort of working test version.

Known issues:
The main loop is broken, stops after binding the key (but the key is properly bound according to inbox status)
LED indication may not work, feedback needed (Windows version and desktop/laptop)

I'm starting to think C or some flavor of it would suit the task better, this script is definitely massive compared to the BASH script...

Edit:
I still haven't been able to figure out why it hangs after configuring the hotkey, any ideas?
I looked into creating a native C app to work around the LED issue by hooking the keyboard and essentially disable Caps Lock by simulating the user holding Shift when pressing a-z while the LED is lit and it seems to involve creating a DLL, risking system stability and a lot of work. I'm fine with the work bit if that's the way it has to be done but I definitely don't want to risk system stability.

Suddenly I get the impression that doing this properly in Sid (or any Linux distro) is a lot easier than in 7, especially since the LED is hard coded to Caps Lock at the keyboard driver level. Since I don't intend to write a keyboard driver I think the only reasonable way to notify the user of new mail is through a balloon tip (is it still called that?). Any other ideas?
 

Attachments

Last edited:

My Computer

OS
Windows 7 Home Premium 64-bit / Debian Sid 64-bit
Actually I found this:
Keyboard Remapping: CAPSLOCK to Ctrl and Beyond - Scancode Map, registry, keyboard, WM_APPCOMMAND, Flip3D, 3dFlip, Win7, Vista, dwmApi

With a registry hack you can reassign the Caps Lock key to, say, VK_BROWSER_HOME which has the scancode "E0 32". This means the binary key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\Scancode Map" should contain this:
Code:
00 00 00 00 00 00 00 00 02 00 00 00 E0 32 3A 00 00 00 00 00
Now, it so happens [.....]

If you want that to work, the code in the registry should be 32 E0, not E0 32. The registry swaps the bytes around. So, the code would have to read:
Code:
00 00 00 00 00 00 00 00 02 00 00 00 32 E0 3A 00 00 00 00 00
in order to work.

Cheers!
 

My Computer

Computer Manufacturer/Model Number
All mine
OS
Windows 2000/XP/7 Ultimate 32bit/7 Enterprise 64bit
CPU
Phenom II 1100
Motherboard
Asus Formula IV
Memory
8GB Apacer/Mushkin
Graphics Card(s)
Radeon HD 6950 2GB
Sound Card
SoundBlaster X-Fi
Monitor(s) Displays
NEC 2690WUXi
Hard Drives
Seagate 2TB/1.5TB/500GB/200GB
Samsung 1TB
Western Digital 500GB/320GB
PSU
Thermaltake ToughPower 800W
Case
Custom-made
Cooling
Custom-made Water
Actually I found this:
Keyboard Remapping: CAPSLOCK to Ctrl and Beyond - Scancode Map, registry, keyboard, WM_APPCOMMAND, Flip3D, 3dFlip, Win7, Vista, dwmApi

With a registry hack you can reassign the Caps Lock key to, say, VK_BROWSER_HOME which has the scancode "E0 32". This means the binary key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\Scancode Map" should contain this:
Code:
00 00 00 00 00 00 00 00 02 00 00 00 E0 32 3A 00 00 00 00 00
Now, it so happens [.....]

If you want that to work, the code in the registry should be 32 E0, not E0 32. The registry swaps the bytes around. So, the code would have to read:
Code:
00 00 00 00 00 00 00 00 02 00 00 00 32 E0 3A 00 00 00 00 00
in order to work.

Cheers!

Thanks, it works now!

Unfortunately for us, I discovered that many browsers themselves claim both VK_BROWSER_HOME and VK_LAUNCH_MAIL for themselves (the latter isn't really the browsers business anyway in my opinion, but that's how it is) which means I had to find another key to use.

The best candidate so far seems to be VK_LAUNCH_APP2 which none of the browsers I tested claimed, the downside is if you have a multimedia keyboard you'll loose the functionality of any Calculator key if it's bound to VK_LAUNCH_APP2 (I'd imagine at least most generic ones does this). The second drawback is that the ShellExecute registry key for APPCOMMAND_LAUNCH_APP2 can't seem to handle parameters, which has an easy fix (batch script) but still worth noting.

Current status:
  • I'll abandon the AutoHotkey script for now in favor of a native batch script port of the BASH script
  • It will require a few extra binaries in the PATH environment variable, but they won't conflict with any existing binaries and are pretty useful anyway
  • Current dependencies are curl or wget (tries in order of fastest implementation, only done once per execution of the script in daemon mode)

 

My Computer

OS
Windows 7 Home Premium 64-bit / Debian Sid 64-bit
You can get any damn key you want... Personally, I've remapped a shitload of my Apple keyboard's extra keys through the registry, put [Alt] keys where they should be, moved Caps Lock to F13 (big key right above backspace) and renamed Caps Lock to F13, so I can do whatever I want with it...
The same goes for you. Choose some key nobody's using, even a key that doesn't exist in most keyboards, and you're done. You can even get an F25 key... If you search a bit, you will see that there are scancodes available for F-keys above 12, which nobody's using, since they just don't exist in 99.9999999% of the keyboards out there.
Cheers mate!
 

My Computer

Computer Manufacturer/Model Number
All mine
OS
Windows 2000/XP/7 Ultimate 32bit/7 Enterprise 64bit
CPU
Phenom II 1100
Motherboard
Asus Formula IV
Memory
8GB Apacer/Mushkin
Graphics Card(s)
Radeon HD 6950 2GB
Sound Card
SoundBlaster X-Fi
Monitor(s) Displays
NEC 2690WUXi
Hard Drives
Seagate 2TB/1.5TB/500GB/200GB
Samsung 1TB
Western Digital 500GB/320GB
PSU
Thermaltake ToughPower 800W
Case
Custom-made
Cooling
Custom-made Water
You can get any damn key you want... Personally, I've remapped a shitload of my Apple keyboard's extra keys through the registry, put [Alt] keys where they should be, moved Caps Lock to F13 (big key right above backspace) and renamed Caps Lock to F13, so I can do whatever I want with it...
The same goes for you. Choose some key nobody's using, even a key that doesn't exist in most keyboards, and you're done. You can even get an F25 key... If you search a bit, you will see that there are scancodes available for F-keys above 12, which nobody's using, since they just don't exist in 99.9999999% of the keyboards out there.
Cheers mate!

Thanks again, but I need a key which is mapped to one of the AppKey handlers (apparently defined in Winuser.h) for it to have the right functionality, though if you have any trick for this too I'd be happy to hear about that as well.

While writing this post I discovered the dark truth about the APPCOMMAND_LAUNCH_APP2 key binding... in addition to launching the specified command it also triggers Ctrl+Alt+L for some reason, which is definitely an undesirable effect.

At least in theory, only F49 and above are safe to map because they don't correspond to F1-F12 with any modifier keys (such as Shift+F1 which equals F13, better explained in this UnixWare manual page).

Anyway, I'm now experimenting with a different approach, set Caps Lock to one of the "dead" F keys and set up a shortcut to the command I want to run on the desktop and bind my key to it.

Edit:
That didn't work, back to Calculator key...
 

My Computer

OS
Windows 7 Home Premium 64-bit / Debian Sid 64-bit
Mate, why would you care what UNIX specs are? The F-keys above F12 in Windows have nothing to do with CTRL or SHIFT or whatever. They have their own scancodes, and you can see that in this document.
Sorry I don't have any tricks up my sleeve, but I never wanted to do what you want. On the other hand, you can just write a short script with AutoHotKey, like the other guys said, and do what you want easily. No need to write your own programme.
 

My Computer

Computer Manufacturer/Model Number
All mine
OS
Windows 2000/XP/7 Ultimate 32bit/7 Enterprise 64bit
CPU
Phenom II 1100
Motherboard
Asus Formula IV
Memory
8GB Apacer/Mushkin
Graphics Card(s)
Radeon HD 6950 2GB
Sound Card
SoundBlaster X-Fi
Monitor(s) Displays
NEC 2690WUXi
Hard Drives
Seagate 2TB/1.5TB/500GB/200GB
Samsung 1TB
Western Digital 500GB/320GB
PSU
Thermaltake ToughPower 800W
Case
Custom-made
Cooling
Custom-made Water
Mate, why would you care what UNIX specs are? The F-keys above F12 in Windows have nothing to do with CTRL or SHIFT or whatever. They have their own scancodes, and you can see that in this document.
Sorry I don't have any tricks up my sleeve, but I never wanted to do what you want. On the other hand, you can just write a short script with AutoHotKey, like the other guys said, and do what you want easily. No need to write your own programme.

Seems like you where right, just thought Windows did the F13-F24 thing too.

Like stated above, I tried to make an AutoHotkey script but couldn't figure out how to get past the hanging hotkey assignment to proceed with the infinite loop. Other than that, the script works as intended (my conclusion is that Windows 7 broke the LED feature).

The batch script port is coming along nicely anyway, porting from BASH isn't as painful as I thought it would be (but extra binaries are still needed).
 

My Computer

OS
Windows 7 Home Premium 64-bit / Debian Sid 64-bit
I tested the script.
I am getting the same problems, LED and loop is not working.

As I have said I am not really good with coding.
If you want to go with AHK your best bet will be asking help from AHK community itself.

I am sure they can easily solve loop and LED problem.

Forums: AutoHotkey Community - Mouse and Keyboard Macros and Hotkeys
Or drop by to their IRC: freenode Web IRC (qwebirc)

I hope you will find the solution somehow.
 

My Computer

OS
Windows 7 Ultimate x86 SP1
Back
Top