Friday, November 7, 2014

keyboard - Remapping Function Keys for media vs. Alt + Function Key for specific app


I have an HP Laptop and I finally got around to changing the BIOS setting to reverse the annoying Fn+Function Key "feature" since I regularly F2, F5 & F11 with VBA & Office (a lot more often than I need to change screen brightness, etc)...


People can do whatever they want with their function keys behind closed doors, but mine were finally back to being real function keys, as God intended.


However I missed having the convenience of the function keys that acted as Media Keys to control VLC, Winamp & Spotify:
F6F7F8F9 🔈-F10 🔈+F11 🔇


So I installed AutoHotKey to remap some of them back to the HP defaults:


F6::Media_Prev
F7::Media_Play_Pause
F8::Media_Next
F9::Volume_Down
F10::Volume_Up

This works but I would like to use F11 for both Volume_Mute and to open the VBE window in Access/Excel (normally Alt+F11 functionality).





  • Is there a way (with or without AutoHotKey) to set it up so that the key will behave differently depending on which window is active?



    If ActiveWindow is {Excel or Access} then:


    Alt+F11 remains as Alt+F11


    If any other window us active then:


    F11 AutoHotKey: Volume_Mute



  • if that's not possible, what would my script look like to map like:



    Alt+F11 remains as Alt+F11


    and


    F11 AutoHotKey: Volume_Mute




There's another change or two I'm debating, but with an answer to this, I should be able to figure out the rest. Thanks!


(HP Folio 13 Windows 7 64bit)


Answer



Use an #If statement to selectively enable a hotkey. You can change the WinTitle if you like as well.


#If Not (WinActive ("ahk_exe excel.exe") Or WinActive ("ahk_exe access.exe"))
F11::Volume_Mute
#IfWinActive ; make sure all hotkeys after this are not qualified with the above #If statement

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...