WindowsKey + number Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
pospa
Posts: 8
Joined: 23 Jun 2022, 09:22
Contact:

WindowsKey + number

Post by pospa » 23 Jun 2022, 09:32

Hi,
I am trying to send WinKey+<number> to open specific program from Taskbar, yet behaviour is not the same as actual WinKey+<number> press. If I press that combination using keyboard it open the program or minimize/restore if is already running. Yet

Code: Select all

Send, #<number>
and even

Code: Select all

Send, {LWin down}<number>{LWin up}
run new instance every single time. Any hint how to mimic real WinKey+<number> press, please? Thanks

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: WindowsKey + number

Post by mikeyww » 23 Jun 2022, 10:11

You can try this exact script by itself with no other code, and no other scripts running.

Code: Select all

F3::Send #3

User avatar
pospa
Posts: 8
Joined: 23 Jun 2022, 09:22
Contact:

Re: WindowsKey + number

Post by pospa » 23 Jun 2022, 10:19

I have tried, yet still the same. Number 7 on my Taskbar is Visual Studio Code. I am running just one script with just that one line like

Code: Select all

F7::Send #7
For every single press of F7 key, new VS code instance is open. If I press WinKey+7 it is switching among already running instances of VS code.

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: WindowsKey + number

Post by mikeyww » 23 Jun 2022, 10:47

Strange. I do not know why.

User avatar
pospa
Posts: 8
Joined: 23 Jun 2022, 09:22
Contact:

Re: WindowsKey + number

Post by pospa » 23 Jun 2022, 10:49

Can you at least reproduce or am I the only one having this issue, please? :-)

shanshans
Posts: 27
Joined: 13 Dec 2015, 08:10

Re: WindowsKey + number

Post by shanshans » 23 Jun 2022, 11:10

Code: Select all

f7::

Send, {LWin down}
sleep 20              ; needed ?
send {7 down}
keywait f7
send {7 up}
send, {LWin up}
return
I am using a highly modified taskbar , so i don't it will work or not, haha, but it is a start maybe.

User avatar
pospa
Posts: 8
Joined: 23 Jun 2022, 09:22
Contact:

Re: WindowsKey + number

Post by pospa » 23 Jun 2022, 11:36

Nice, works like a charm. This is exactly what I have boon looking for. Thanks :D
shanshans wrote:
23 Jun 2022, 11:10

Code: Select all

f7::

Send, {LWin down}
sleep 20              ; needed ?
send {7 down}
keywait f7
send {7 up}
send, {LWin up}
return
I am using a highly modified taskbar , so i don't it will work or not, haha, but it is a start maybe.

User avatar
pospa
Posts: 8
Joined: 23 Jun 2022, 09:22
Contact:

Re: WindowsKey + number

Post by pospa » 24 Jun 2022, 02:34

Actually it worked under very specific circumstances I am not able to reproduce any more. :-( So help still needed. Any other hint @mikeyww, @shanshans, please? Thanks

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: WindowsKey + number

Post by mikeyww » 24 Jun 2022, 05:23

In some cases, the Up version helps.

Code: Select all

F3 Up::Send #3

User avatar
pospa
Posts: 8
Joined: 23 Jun 2022, 09:22
Contact:

Re: WindowsKey + number

Post by pospa » 24 Jun 2022, 08:23

Doesn't work. :-( I have tried on a different PC with Windows 10 and even Windows 11, yet it is still the same.
mikeyww wrote:
24 Jun 2022, 05:23
In some cases, the Up version helps.

Code: Select all

F3 Up::Send #3

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: WindowsKey + number

Post by mikeyww » 24 Jun 2022, 08:33

Is your script running? You used this script with no other code? No other scripts, hotkey managers, keyboard or mouse utilities running? No conflicting hotkeys in other software?

:arrow: KeyHistory can show you what is happening with the keys.

Code: Select all

F3 Up::
Send #3
KeyHistory
Return
image220624-0935-001_cr.png
Key history
image220624-0935-001_cr.png (10.41 KiB) Viewed 1493 times

User avatar
pospa
Posts: 8
Joined: 23 Jun 2022, 09:22
Contact:

Re: WindowsKey + number

Post by pospa » 24 Jun 2022, 09:06

I have found what is the difference. As I wrote, it works Yesterday for a while. It is depends on keyboard layout. Yet what is even more weird to me is fact, like historical values in column Key of KeyHistory changes every single time I switch layout.
with ENG-US:

Code: Select all

Window: C:\Users\pospa\OneDrive\Desktop\Test.ahk - AutoHotkey v1.1.34.03
Keybd hook: yes
Mouse hook: no
Enabled Timers: 0 of 0 ()
Interrupted threads: 0
Paused threads: 0 of 0 (0 layers)
Modifiers (GetKeyState() now) = 
Modifiers (Hook's Logical) = 
Modifiers (Hook's Physical) = 
Prefix key is down: no

NOTE: To disable the key history shown below, add the line "#KeyHistory 0" anywhere in the script.  The same method can be used to change the size of the history buffer.  For example: #KeyHistory 100  (Default is 40, Max is 500)

The oldest are listed first.  VK=Virtual Key, SC=Scan Code, Elapsed=Seconds since the previous event.  Types: h=Hook Hotkey, s=Suppressed (blocked), i=Ignored because it was generated by an AHK script, a=Artificial, #=Disabled via #IfWinActive/Exist, U=Unicode character (SendInput).

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
A2  01D	 	d	29.25	LControl       	Program Manager
76  041	s	d	0.27	F7             	
76  041	h	u	0.08	F7             	
5B  15B	i	d	0.00	LWin           	
A2  01D	i	u	0.00	LControl       	
37  008	i	d	0.00	ý              	
37  008	i	u	0.00	ý              	
5B  15B	i	u	0.02	LWin           	
A2  01D	i	d	0.00	LControl       	
A2  01D	 	u	0.11	LControl       	Test.ahk - Visual Studio Code
A2  01D	 	d	7.22	LControl       	
76  041	s	d	0.25	F7             	
76  041	h	u	0.09	F7             	
5B  15B	i	d	0.00	LWin           	
A2  01D	i	u	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
37  008	i	d	0.00	ý              	
37  008	i	u	0.00	ý              	
5B  15B	i	u	0.02	LWin           	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.00	LControl       	
A2  01D	 	u	0.20	LControl       	
78  043	 	d	4.75	F9             	
78  043	 	u	0.06	F9             	C:\Users\pospa\OneDrive\Desktop\Test.ahk - AutoHotkey v1.1.34.03
74  03F	 	d	60.20	F5             	
Press [F5] to refresh.

with CES-CZ:

Code: Select all

Window: C:\Users\pospa\OneDrive\Desktop\Test.ahk - AutoHotkey v1.1.34.03
Keybd hook: yes
Mouse hook: no
Enabled Timers: 0 of 0 ()
Interrupted threads: 0
Paused threads: 0 of 0 (0 layers)
Modifiers (GetKeyState() now) = 
Modifiers (Hook's Logical) = 
Modifiers (Hook's Physical) = 
Prefix key is down: no

NOTE: To disable the key history shown below, add the line "#KeyHistory 0" anywhere in the script.  The same method can be used to change the size of the history buffer.  For example: #KeyHistory 100  (Default is 40, Max is 500)

The oldest are listed first.  VK=Virtual Key, SC=Scan Code, Elapsed=Seconds since the previous event.  Types: h=Hook Hotkey, s=Suppressed (blocked), i=Ignored because it was generated by an AHK script, a=Artificial, #=Disabled via #IfWinActive/Exist, U=Unicode character (SendInput).

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
A2  01D	 	d	29.25	LControl       	Program Manager
76  041	s	d	0.27	F7             	
76  041	h	u	0.08	F7             	
5B  15B	i	d	0.00	LWin           	
A2  01D	i	u	0.00	LControl       	
37  008	i	d	0.00	ý              	
37  008	i	u	0.00	ý              	
5B  15B	i	u	0.02	LWin           	
A2  01D	i	d	0.00	LControl       	
A2  01D	 	u	0.11	LControl       	Test.ahk - Visual Studio Code
A2  01D	 	d	7.22	LControl       	
76  041	s	d	0.25	F7             	
76  041	h	u	0.09	F7             	
5B  15B	i	d	0.00	LWin           	
A2  01D	i	u	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
37  008	i	d	0.00	ý              	
37  008	i	u	0.00	ý              	
5B  15B	i	u	0.02	LWin           	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.00	LControl       	
A2  01D	 	u	0.20	LControl       	
78  043	 	d	4.75	F9             	
78  043	 	u	0.06	F9             	C:\Users\pospa\OneDrive\Desktop\Test.ahk - AutoHotkey v1.1.34.03
74  03F	 	d	60.20	F5             	
Press [F5] to refresh.


How come, historical data are changing in KeyHistory after switching layout, please? Btw WinKey+7 (or ý, which is on 7 with CES layout) works as it should, yet not with AHK. And I am not running any other tool for keyboard and only one AHK script like this:

Code: Select all

^F8 Up::
Send, {LWin down}
sleep 20              
send {7 down}
send {7 up}
send, {LWin up}
return

^F7 Up::Send #7

^Numpad7 Up:: Send #7

F9:: KeyHistory

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: WindowsKey + number  Topic is solved

Post by mikeyww » 24 Jun 2022, 09:31

You could try a scan code.

Code: Select all

F3::Send #{SC004}
Explained: Scan code

User avatar
pospa
Posts: 8
Joined: 23 Jun 2022, 09:22
Contact:

Re: WindowsKey + number

Post by pospa » 24 Jun 2022, 09:41

Thanks @mikeyww, Scan Code works all the time no matter what layout I have selected. :-) :bravo:

Now I only have to re-program my additional keyboard to F13 - F24 to not interfere with my standard 122-key keyboard and I can remap using AHK freely. :-)
Is AHK using SC64-6E + 76 for F13-24, please?
mikeyww wrote:
24 Jun 2022, 09:31
You could try a scan code.

Code: Select all

F3::Send #{SC004}
Explained: Scan code

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: WindowsKey + number

Post by mikeyww » 24 Jun 2022, 09:50

In your post, you showed that the key history displays the scan codes in the "SC" column. Best of luck! :thumbup:

Post Reply

Return to “Ask for Help (v1)”