SHIFT does not appear to work for NumPad hotkeys

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Humbug
Posts: 18
Joined: 14 Jul 2017, 14:11

SHIFT does not appear to work for NumPad hotkeys

11 Jan 2021, 09:24

Hi all,
all of these work:

Code: Select all

NumPad1::
while GetKeyState("NumPad1","p")
{
	;DoADoubleClick()
	DoAClick()
}
return
^NumPad1::
while GetKeyState("NumPad1","p")
{
	;DoADoubleClick()
	DoAClick()
}
return

+^NumPad1::
while GetKeyState("NumPad1","p")
{
	;DoADoubleClick()
	DoAClick()
}
return
However, these do not:

Code: Select all

+NumPad1::
while GetKeyState("NumPad1","p")
{
	;DoADoubleClick()
	DoAClick()
}
return

Shift & NumPad1::
while GetKeyState("NumPad1","p")
{
	;DoADoubleClick()
	DoAClick()
}
return
What might prevent the use of the SHIFT key?
This is also on Windows 10.
Thank you!
Last edited by Humbug on 11 Jan 2021, 14:10, edited 1 time in total.
Humbug
Posts: 18
Joined: 14 Jul 2017, 14:11

Re: SHIFT does not appear to work for hotkeys

11 Jan 2021, 11:42

There is indeed an explanation, and I found the table, too.
However, I could not figure out what a SHIFT+NUMPAD1 would become with NUMLOCK on.
User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: SHIFT does not appear to work for hotkeys

11 Jan 2021, 12:46

The following worked for me.

Code: Select all

shiftedKey = x
Numpad1::Send % GetKeyState("Shift", "P") ? shiftedKey : 1
NumpadEnd::Send {Shift up}%shiftedKey%
reluct
Posts: 134
Joined: 28 Nov 2018, 05:07

Re: SHIFT does not appear to work for hotkeys

11 Jan 2021, 13:05

I got 1 and x but not Shift. :(
User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: SHIFT does not appear to work for hotkeys

11 Jan 2021, 13:42

What is the output that you want?
reluct
Posts: 134
Joined: 28 Nov 2018, 05:07

Re: SHIFT does not appear to work for hotkeys

11 Jan 2021, 14:08

Hold the shift on Numpad1, and cancel the hold on it. I was looking for a script like this.
Humbug
Posts: 18
Joined: 14 Jul 2017, 14:11

Re: SHIFT does not appear to work for hotkeys

11 Jan 2021, 14:10

mikeyww wrote:
11 Jan 2021, 13:42
What is the output that you want?
If you are asking me, I'd like it to do a click on all NUMPAD1 combinations - SHIFT, CTRL, SHIFT+CTRL like you see in the original post.
All are working except SHIFT+NUMPAD1.
User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: SHIFT does not appear to work for NumPad hotkeys

11 Jan 2021, 14:16

Hmm. Sorry I'm not following what the desired actions are. Others may be able to chime in with solutions.
Humbug
Posts: 18
Joined: 14 Jul 2017, 14:11

Re: SHIFT does not appear to work for NumPad hotkeys

12 Jan 2021, 06:19

mikeyww wrote:
11 Jan 2021, 14:16
Hmm. Sorry I'm not following what the desired actions are. Others may be able to chime in with solutions.
NumPad1 - works.
Shift+NumPad1 - no luck.
CTRL+NumPad1 - works.
Shift+CTRL+NumPad1 - works.

Each of these needs to call DoAClick() ;-)
User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: SHIFT does not appear to work for NumPad hotkeys

12 Jan 2021, 06:53

Replace your script with the following.

Code: Select all

*NumpadEnd::
*Numpad1::
If !GetKeyState("Alt", "P") && !GetKeyState("LWin", "P") {
 Send {Shift up}
 DoAClick()
} Else Send 1
Return
Humbug
Posts: 18
Joined: 14 Jul 2017, 14:11

Re: SHIFT does not appear to work for NumPad hotkeys

13 Jan 2021, 06:39

mikeyww wrote:
12 Jan 2021, 06:53
Replace your script with the following.
Nice, thank you!
Humbug
Posts: 18
Joined: 14 Jul 2017, 14:11

Re: SHIFT does not appear to work for NumPad hotkeys

13 Jan 2021, 07:07

Here's what I ended up with.

Code: Select all

*NumpadEnd::
*Numpad1::
if (GetKeyState("NumLock", "T"))
{
	DoAClick()
}
else
{
	Send {NumpadEnd}
}
return
Now, if only there was a way to pass the original modifier keys along ;-)
User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: SHIFT does not appear to work for NumPad hotkeys

13 Jan 2021, 08:07

It's hard to comment because I don't know what your function does.
Humbug
Posts: 18
Joined: 14 Jul 2017, 14:11

Re: SHIFT does not appear to work for NumPad hotkeys

13 Jan 2021, 15:08

mikeyww wrote:
13 Jan 2021, 08:07
It's hard to comment because I don't know what your function does.
As the name suggests, it simply clicks ;-)

Code: Select all

DoAClick()
{
	Click
	Sleep 25
}
Problem is, I need to pass the modifiers somehow.
Meaning, for example, that a SHIFT+NumPad1 becomes a SHIFT+Click. A CTRL+SHIFT+NumPad1 becomes a CTRL+SHIFT+Click. And so on.
Same deal with the NumPadEnd.
User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: SHIFT does not appear to work for NumPad hotkeys

13 Jan 2021, 19:45

Code: Select all

mod := {Shift: "+", Ctrl: "^"}

*NumpadEnd::
*Numpad1::
If !GetKeyState("Alt", "P") && !GetKeyState("LWin", "P") {
 str =
 For key, thisMod in mod
  str .= GetKeyState(key, "P") ? thisMod : ""
 Send {Shift up}%str%{LButton}
 Sleep, 25
} Else Send 1
Return
The following might also work (need to test):

Code: Select all

*NumpadEnd::
*Numpad1::
If !GetKeyState("Alt", "P") && !GetKeyState("LWin", "P") {
 Send % "{Blind}" (A_ThisHotkey = "*NumpadEnd" ? "+" : "") "{LButton}"
 Sleep, 25
} Else Send 1
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], vikasgandhi and 325 guests