How to send key once while press down the other key at the same time? Topic is solved

Ask gaming related questions
Ransom
Posts: 8
Joined: 22 Jul 2020, 22:44

How to send key once while press down the other key at the same time?

22 Jul 2020, 22:54

Hi community:
I am using opentrack to track my head position for flight simulation.
The software does not allow me to use left alt for tracking active for some reason, therefore i have to use AHK to remap left alt to another key troke (namely Home).
So this is my goal:
Press down and hold left alt key, the home key will be pressed down and held. in the meantime, num 2 key will be pressed and released one time.

so far I experimented with this script:
LAlt::Send {Home down}

For some reason it worked in notepad, but have no effect on opentrack.
Then I changed the script to:
LAlt::Home

Then it worked!
I am just very curious why the first script didn't work.
And How would I add a Num2 key press once with left alt being pressed and held?
Thanks!
Last edited by BoBo on 23 Jul 2020, 00:24, edited 1 time in total.
Reason: Moved to Gaming section.
Rohwedder
Posts: 3396
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to send key once while press down the other key at the same time?  Topic is solved

23 Jul 2020, 01:07

Hallo,
try (only tested in the editor):

Code: Select all

#InputLevel 1
LAlt::Home
#InputLevel 0
~Home::
Sleep, 200
Send, {Numpad2}
KeyWait, LAlt
Return
Ransom
Posts: 8
Joined: 22 Jul 2020, 22:44

Re: How to send key once while press down the other key at the same time?

23 Jul 2020, 10:54

@Rohwedder
Wow thank you! I didn't expect an answer this fast.
So just to explain your code to the anyone that wonders the same:
LAlt triggers Home, and Home sends a single Numpad2 press. "KeyWait, LAlt" is waiting LAlt to be released so that the script wont keep sending Numpad2 presses.
~on Home means it will still let Home be home.
Thanks again.

Return to “Gaming”

Who is online

Users browsing this forum: Bing [Bot], tahtinen62 and 12 guests