V
V
vladlecteur2019-02-20 12:12:10
autohotkey
vladlecteur, 2019-02-20 12:12:10

AutoHotkey: what script to write to change layout with Fn?

Good afternoon!
Help, please :)
I need to write a code for AutoHotkey so that on the ASUS N46VZ laptop (Windows 10) the Russian-English keyboard layout changes when the Fn button is released.
At the same time, if another button was also pressed while Fn was pressed (ie, Fn was used for a keyboard shortcut, for example, Fn + F6 brightens the screen), then the layout should not change. The behavior should be exactly like the behavior of the Win button - the Start menu only opens when the Win button is released, provided that it was pressed separately from other buttons.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xaosxaos2, 2020-11-03
@xaosxaos2

You will have to find the code for the Fn key, but the code that works for me is this:

ih := InputHook("L1")
ih.KeyOpt("{All}", "NV") 
ih.OnKeyDown := Func("OnKey").bind("Down")
ih.OnKeyUp := Func("OnKey").bind("Up")
ih.OnEnd := Func("OnEnd")

~LCtrl::
 ih.Start()
Return
Return

OnKey(direction, ih, vk, sc) {
 if (direction == "Up" and vk == 162) { ;вместо 162 код клавиши Fn
  PostMessage, 0x50,0x2, ,, A
 }
 ih.Stop()
}

OnEnd(ih) {
 ih.Stop()
  
}

Similar questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question