2

On Windows, how can I block a key combination like Alt+F2+F8. Note that I have two base keys (F2 and F8) in it. Usually you can only block key combinations with one base key and up to three modifiers (Shift, Ctrl, Win).

With a small utility called KeyCodes I monitored what Windows sees when holding down Alt+F2+F8.
No surprise here.

enter image description here

I already tried AutoIt's function HotKeySet, but unfortunately...

The following hotkeys cannot be set:
[...]
Any global hotkeys a user has defined using third-party software, any combos of two or more "base keys" such as '{F1}{F2}', and any keys of the form '{LALT}' or '{ALTDOWN}'.

Q: How can I block a key combination containing two base keys

2
  • 1
    What exactly do you want to happen? If user presses Alt-F2 it sees it, if the user presses Alt-F8 it sees that too, but if user presses Alt-F2-F8 it sees neither? Unfortunately the user won't press F2 and F8 exactly simultaneously and even if they did, the system will process them sequentially anyway. So at some moment there will be just Alt-F2 or just Alt-F8 and they'll take effect... – Jan Hudec Jan 13 '14 at 10:44
  • In rare cases, its possible that a user presses Alt+F2+F8. That’s your problem; you are trying to “fix” user error. There are plenty of keys that could cause undesired behavior when used incorrectly, e.g., Del, Esc, Alt+F4, but you don’t see people running out to find a way to prevent those from working. Unless people are pressing Alt+F2+F8 frequently for some reason, then the unwanted behavior is just a way to reinforce learning to be more careful about what they press. – Synetech Jan 14 '14 at 15:37
1
+100

I think this (untested) AutoHotKey script will work :

$F2::
GetKeyState, state, F8
if state != D
SendInput {F2}
Return

$F8::
GetKeyState, state, F2
if state != D
SendInput {F8}
Return
4
  • Is there something like $F2 down:: SendInput {F2 down} and $F2 up:: SendInput {F2 up}? Here is a keyboard log made with KeyCodes where I hold down F2: With AHK script running and without AHK script running. You see what I mean? (Whats this "spacebar" btw. O_o) – nixda Jan 13 '14 at 16:37
  • See the last boxed entry in Hotkeys manual. The example says *LWin::Send {LControl Down} and also *LWin Up::Send {LControl Up}. Reading that article can answer many questions. – harrymc Jan 13 '14 at 17:43
  • It was a bit tricky but I got it to work, thx. – nixda Jan 15 '14 at 13:37
  • Better add the final script to your post, to help future readers. – harrymc Jan 15 '14 at 14:17
1

Maybe you can give AutoHotKey a try, with this script:

pressed:= false
~!F2::
   pressed = true
   return
~*F2 Up::
   pressed = false
   return
!F8::
   if (pressed = "true"){
      return
   } else {
      Send {!F8}
   }
   return

It blocks F8 when AltF2 is pressed, and let it go through otherwise. I tested it here, but I'm not sure it's the behaviour you exactly want...

2
  • Sry, this is not working. When I press ALT+F8 it only executes F8, but not the key combination I want. – nixda Jan 13 '14 at 9:54
  • 1
    I knew I forgot something. Can you try this corrected version? – m4573r Jan 13 '14 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.