Bind 1 to Ctrl+1 with complications - Immortal Fenyx Rising Topic is solved

Ask gaming related questions (AHK v1.1 and older)
arnad
Posts: 3
Joined: 01 Oct 2020, 11:30

Bind 1 to Ctrl+1 with complications - Immortal Fenyx Rising

Post by arnad » 04 Dec 2021, 05:04

Goal
I would like to write a script that does the following:

I press 1 down
The script presses Ctrl down
It waits a moment
Then presses 1 down

I release 1
It releases Ctrl and 1

Background
In the game, the godly powers are triggered by prvy case Ctrl) and a power-specific key (1-5). While you can rebind both the modifier and the power keys, it is not possible to unbind the modifier and trigger the powers with one button only. Which is why I would like to have a single button (1 in this case) trigger Ctr+1. Now for the complications.

Delay
Simply sending Ctrl+1 does not work, because the game expects you to press ctrl, then takes a moment to animate the godly powers UI and only then can you press 1. So I need to introduce a delay between Ctrl and 1.

Hold
The game differentiates between Ctrl + 1 (Tap) and Ctrl + 1 (Hold). Since I need both functionalities, I need to write the script in such a way that it keeps those two buttons pressed as long as I keep the button pressed that I want to map this to.

Current Attempt
My current idea ist something like this:

Code: Select all

1::
SendEvent {Ctrl Down}
Sleep 1000
SendEvent {1 Down}
1 Up::
SendEvent {Ctrl Up}{1 Up}
This sort of works (I can trigger the godly powers by keeping 1 pressed), but it has several problems:
Hold
This solution does not behave as if I was holding Ctrl+1 down, but as if i was pressing them again and again.
Release
When I tap 1 instead of holding it, ctrl is released before 1 is pressed down, resulting in 1 being pressed on its own. I would like to only react to the 1 Up-Event when the Ctrl+Sleep+1 command has run its course.

Any help, also in the form of concepts that I should look into would be greatly appreciated.

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Bind 1 to Ctrl+1 with complications - Immortal Fenyx Rising  Topic is solved

Post by Rohwedder » 04 Dec 2021, 06:24

Hallo,
try:

Code: Select all

$1::
SendEvent {Ctrl Down}
KeyWait, 1, T1
IF ErrorLevel
	SendEvent {Blind}{1 Down}
KeyWait, 1
SendEvent {Ctrl Up}{1 Up}
Return

arnad
Posts: 3
Joined: 01 Oct 2020, 11:30

Re: Bind 1 to Ctrl+1 with complications - Immortal Fenyx Rising

Post by arnad » 07 Dec 2021, 14:29

Thank you so much! That works brilliantly. I don't really understand what's going on, but I'll figure that out with the help of the documentation.

For anyone finding this and wanting to use it for their own game: You probaly want to adjust the wait time somewhat downwards. It is specified in seconds by the T-Parameter in KeyWait, e.g. if you want a quarter of a second wait time:

Code: Select all

KeyWait, 1, T0.25
Just make sure it is long enought for the game to register it.

Post Reply

Return to “Gaming Help (v1)”