I want a hotkey to only work if Numlock is on

Ask gaming related questions (AHK v1.1 and older)
l ryux
Posts: 4
Joined: 11 Jul 2015, 07:08

I want a hotkey to only work if Numlock is on

23 Aug 2015, 06:33

This is what came to my mind, but it doesn't work:

Code: Select all

GetKeyState, state, Numlock, T ; if Numlock is on, pressing "a" makes an "x" and else pressing "a" makes a "c"

state := GetKeyState ("Numlock", "T")

if state = D {

	a:: x

}else{

	a:: c
}
Return
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: I want a hotkey to only work if Numlock is on

23 Aug 2015, 07:44

Code: Select all

; if Numlock is on, pressing "a" makes an "x" and else pressing "a" makes a "c"

a::
    If GetKeyState("Numlock", "T")
        Send, x
    Else
        Send, c
Return
l ryux
Posts: 4
Joined: 11 Jul 2015, 07:08

Re: I want a hotkey to only work if Numlock is on

25 Aug 2015, 10:17

looks good, I gonna test it
l ryux
Posts: 4
Joined: 11 Jul 2015, 07:08

Re: I want a hotkey to only work if Numlock is on

25 Aug 2015, 10:44

It is very incosistent when numlock is toggled, it would sometimes put out "x", but sometimes "x" and "c" at once.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: I want a hotkey to only work if Numlock is on

25 Aug 2015, 15:39

l ryux wrote:It is very incosistent when numlock is toggled, it would sometimes put out "x", but sometimes "x" and "c" at once.
Have you tested with Notepad or any text editor? For me, there is no inconsistency there.
What did you use for testing?

A bug that only occurs sometimes is often very difficult to find.
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: I want a hotkey to only work if Numlock is on

14 Sep 2015, 18:12

try this

Code: Select all

#If GetKeyState("NumLock","T")
$a::x
#If

#if !GetKeyState("NumLock","T")
$a::c
#If
:wave: There is always more than one way to solve a problem. ;)
skribb

Re: I want a hotkey to only work if Numlock is on

11 May 2016, 15:53

YoucefHam wrote:try this

Code: Select all

#If GetKeyState("NumLock","T")
$a::x
#If

#if !GetKeyState("NumLock","T")
$a::c
#If
seems to work for me

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Rohwedder, Rxbie and 65 guests