How to send vk and sc with modifiers?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fona
Posts: 65
Joined: 07 Apr 2022, 06:43

How to send vk and sc with modifiers?

Post by fona » 09 Jun 2022, 09:33

Hi everyone,
I tried different options but nothing works. I want to send virual keys or scan codes with modifiers.

Code: Select all

sc01E:: ;sc(scan code) of A. 
SendInput {LCtrl down}{Alt down}{vk53}{Alt up}{LCtrl up}  ;Ctrl + Alt + S
This one below dosn't work either

Code: Select all

sc01E:: ;sc(scan code) of A. 
SendInput {LCtrl}{Alt}{vk53}{Alt}{LCtrl}  ;Ctrl + Alt + S
or

Code: Select all

sc01E:: ;sc(scan code) of A. 
SendInput {vkA2 down}{vkA4 down}{vk53}{vkA4 up}{vkA2 up}  ;Ctrl + Alt + S

gregster
Posts: 9111
Joined: 30 Sep 2013, 06:48

Re: How to send vk and sc with modifiers?

Post by gregster » 09 Jun 2022, 10:07

fona wrote:
09 Jun 2022, 09:33

Code: Select all

sc01E:: ;sc(scan code) of A. 
SendInput {LCtrl down}{Alt down}{vk53}{Alt up}{LCtrl up}  ;Ctrl + Alt + S
What do you expect to happen when sending Ctrl+Alt+S ?
In which program? A game? A program running with elevated rights?

The first (and the third) code works for me, according to my KeyHistory (the second would release the modifiers before sending s).

Code: Select all

41  01E	h	d	0.72	a              	
A2  01D	i	d	0.00	LControl       	
A4  038	i	d	0.02	LAlt           	
53  01F	i	d	0.00	s              	
53  01F	i	u	0.00	s              	
A4  038	i	u	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
41  01E	s	u	0.20	a        
Btw, you should close your multi-line hotkeys with a return. Otherwise you could see unwanted side-effects.

fona
Posts: 65
Joined: 07 Apr 2022, 06:43

Re: How to send vk and sc with modifiers?

Post by fona » 09 Jun 2022, 11:38

gregster wrote:
09 Jun 2022, 10:07
fona wrote:
09 Jun 2022, 09:33

Code: Select all

sc01E:: ;sc(scan code) of A. 
SendInput {LCtrl down}{Alt down}{vk53}{Alt up}{LCtrl up}  ;Ctrl + Alt + S
What do you expect to happen when sending Ctrl+Alt+S ?
In which program? A game? A program running with elevated rights?

The first (and the third) code works for me, according to my KeyHistory (the second would release the modifiers before sending s).

Code: Select all

41  01E	h	d	0.72	a              	
A2  01D	i	d	0.00	LControl       	
A4  038	i	d	0.02	LAlt           	
53  01F	i	d	0.00	s              	
53  01F	i	u	0.00	s              	
A4  038	i	u	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
41  01E	s	u	0.20	a       
Btw, you should close your multi-line hotkeys with a return. Otherwise you could see unwanted side-effects.
I forgot to say that I use two keyboards eng and ru. It works for me in eng keyboard and it sends Ctrl + Alt + S, but not when I switch to russian keyboard. I use it in Photoshop

gregster
Posts: 9111
Joined: 30 Sep 2013, 06:48

Re: How to send vk and sc with modifiers?

Post by gregster » 09 Jun 2022, 11:52

Ah, I have neither.
So what doesn't work? Doesn't the hotkey trigger? You can try with a msgbox.
Does Photoshop ignore it? What is KeyHistory saying with the russian layout active?

fona
Posts: 65
Joined: 07 Apr 2022, 06:43

Re: How to send vk and sc with modifiers?

Post by fona » 09 Jun 2022, 14:12

gregster wrote:
09 Jun 2022, 11:52
Ah, I have neither.
So what doesn't work? Doesn't the hotkey trigger? You can try with a msgbox.
Does Photoshop ignore it? What is KeyHistory saying with the russian layout active?
I figured it out. Thank you for trying to help me

gregster
Posts: 9111
Joined: 30 Sep 2013, 06:48

Re: How to send vk and sc with modifiers?

Post by gregster » 09 Jun 2022, 14:20

For others having similar problems in the future, it would surely be beneficial, if you could share how you figured it out, or what the problem was.

Post Reply

Return to “Ask for Help (v1)”