Activate Mouse Keys by emulating "Alt + Shift + Numlock"

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
alancantor
Posts: 76
Joined: 11 Jun 2019, 11:28

Activate Mouse Keys by emulating "Alt + Shift + Numlock"

Post by alancantor » 24 Jan 2021, 13:45

I'd like to remap the hotkey for activating the Mouse Keys feature in Windows from its default, Alt + Shift + Numlock, to something that is easier to remember and that involves fewer key presses. Like F12.

I can't seem to find the magic combination of AHK instructions that will send the hotkey. For example, none of following work:

Code: Select all

F12:: 

SendInput {Alt}{Shift}{Numlock}

Send {Alt}{Shift}{Numlock}

SendInput {Alt down}{Shift down}{Numlock}{Shift up}{Alt up}

Send {Alt down}{Shift down}{Numlock}{Shift up}{Alt up}

Return
[Mod edit: [code][/code] tags added.]
User avatar
mikeyww
Posts: 27072
Joined: 09 Sep 2014, 18:38

Re: Activate Mouse Keys by emulating "Alt + Shift + Numlock"

Post by mikeyww » 24 Jan 2021, 13:51

This is a DIY approach with the same effect. To answer your question more directly: I'm not sure that you can directly activate those Windows special keys. There are some registry entries for them, but also a bit tricky to implement. The approach below may be more successful. Here you can also adjust the acceleration to meet your needs.

Code: Select all

moveMin := 2, moveMax := 150, overSec := 5
F12::SoundBeep, (mouseKeysOn := !mouseKeysOn) ? 1500 : 1000, 30 ; F12 = Toggle MouseKeys
F4:: ; F4 = Exit
SoundBeep, 1000, 30
ExitApp

#If mouseKeysOn
Numpad1::
Numpad2::
Numpad3::
Numpad4::
Numpad6::
Numpad7::
Numpad8::
Numpad9::
start := A_TickCount
While GetKeyState(A_ThisHotkey, "P") { ; Accelerate while key is held
 amount := Min(moveMax, Round(moveMin + (A_TickCount - start) * (moveMax - moveMin) / overSec / 1000))
 move(SubStr(A_ThisHotkey, 7), amount)
}
Return

move(key, amount) {
 Static mouseKey := { 7: [-1, -1], 8: [ 0, -1], 9: [ 1, -1]
                    , 4: [-1,  0]             , 6: [ 1,  0]
                    , 1: [-1,  1], 2: [ 0,  1], 3: [ 1,  1]}
 MouseMove, amount * mouseKey[key].1, amount * mouseKey[key].2,, R
}
Post Reply

Return to “Ask for Help (v1)”