Page 1 of 1

Rebinding a laptop´s specific key

Posted: 25 Apr 2019, 02:50
by n1klas
Hello,

I just started using AutoHotKey on my new Matebook 13.
I´d like to rebind the key that usually opens the Huawei Update App.
It´s the 4th key in the upper row from the left: https icdn3.digitaltrends.com /image/huawei-matebook-13-review-3-2-720x720.jpg Broken Link for safety
It works without pressing the FN key, if you want to use F10 you have to press FN aswell.
How do I use this key to launch a special app?

Thanks for the help.

Regards
Niklas

Re: Rebinding a laptop´s specific key

Posted: 25 Apr 2019, 03:46
by Osprey
Run this TooltipKeypress script:

Code: Select all

CoordMode, ToolTip, Screen
SetFormat, IntegerFast, H

CleanTimer := -3000	; Must be a negative number (the timer will run only once)

Loop, 5000
{
  Hotkey, % "~*" GetKeyName(Format("vk{:x}", a_index - 1)), GetText
  Hotkey, % "~*" GetKeyName(Format("sc{:x}", a_index - 1)), GetText
}
  ; "~" keeps the button original function
  ; "*" fires the hotkey even if extra modifiers are being held down

Gui, New, -MinimizeBox
Gui, Add, Edit, w200 h100,
Gui, Show
Return

GetText:
  SetTimer, CleanText, Off
  Sleep, 50
  Key := RegExReplace(A_ThisHotkey, "^..")    	; "^.." removes the first 2 characters ("~*") from the returned string
  KeyVK := GetKeyVK(Key)
  KeyVK := RegExReplace(KeyVK, "^..")
  KeySC := GetKeySC(Key)
  KeySC := RegExReplace(KeySC, "^..")
  Text .= Key
  ToolTip, % "Key Name: {" Key "}`nKey VK: {vk" KeyVK "}`nKey SC: {sc" KeySC "}`n`n" Text, 0, 0  ; X\Y coordinates
  SetTimer, CleanText, %CleanTimer%
Return

CleanText:
  Text := ""
  ToolTip
Return

GuiClose:
  ExitApp
Return
Press the key that you're talking about it and note what the tooltip says that the VK or SC code is, then create a hotkey for it in your own script, like so:

Code: Select all

vkxx::
    ; Stuff to do when the button is pressed
Return
If, for whatever reason, the above script doesn't return anything, AHK's documentation for an alternative method is here: https://autohotkey.com/docs/KeyList.htm#SpecialKeys