Need Help with possible script/toggle?

Ask gaming related questions
RJMayhem
Posts: 3
Joined: 28 Aug 2023, 20:12

Need Help with possible script/toggle?

01 Apr 2024, 09:38

Hello

I don't know much about AHK I mainly use prebuilt scripts. I'm not sure it's possible but what I'm looking for is a script that would let me press a button let's say Y that when pressed it would give you the Y button but when pressed again if already pressed it would then give U then restart with Y. I'm looking to toggle a item on off in a Starfield. Y equips the item & U unequips the item.

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

Re: Need Help with possible script/toggle?

01 Apr 2024, 18:31

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v2.0

$y:: {
 Static f := 0
 SetKeyDelay 25, 25
 SendEvent f := f = 'y' ? 'u' : 'y'
}
Rohwedder
Posts: 7719
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need Help with possible script/toggle?

02 Apr 2024, 02:16

Hallo,
or array instead of ternary:

Code: Select all

#Requires AutoHotkey v2.0

$y:: {
 Static f := 0
 SetKeyDelay 25, 25
 SendEvent ["u","y"][1+f:=!f]
}
RJMayhem
Posts: 3
Joined: 28 Aug 2023, 20:12

Re: Need Help with possible script/toggle?

02 Apr 2024, 09:10

mikeyww wrote:
01 Apr 2024, 18:31
Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v2.0

$y:: {
 Static f := 0
 SetKeyDelay 25, 25
 SendEvent f := f = 'y' ? 'u' : 'y'
}
Rohwedder wrote:
02 Apr 2024, 02:16
Hallo,
or array instead of ternary:

Code: Select all

#Requires AutoHotkey v2.0

$y:: {
 Static f := 0
 SetKeyDelay 25, 25
 SendEvent ["u","y"][1+f:=!f]
}
Hello

Thank You! Question though both seem to work what's the difference between them?
User avatar
mikeyww
Posts: 27192
Joined: 09 Sep 2014, 18:38

Re: Need Help with possible script/toggle?

02 Apr 2024, 10:04

The code is the different part! The result is the same. :)

1: f is "y" or "u" (if not 0).

2: f is 0 or 1.
RJMayhem
Posts: 3
Joined: 28 Aug 2023, 20:12

Re: Need Help with possible script/toggle?

05 Apr 2024, 11:05

I didn't want to make a new topic so I'll ask here. Is there a way to have a script that when pressed it would press the Xbox controller button Left Trigger + T and then T again on release of the Xbox Controller Left Trigger?
User avatar
boiler
Posts: 17209
Joined: 21 Dec 2014, 02:44

Re: Need Help with possible script/toggle?

05 Apr 2024, 11:10

No, AHK does not have the capability of simulating controller button presses. There are ways to achieve this that are quite involved. See this thread.

In the future, please don't add on to your (or others') existing threads with a different topic. Please start a new thread.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 7 guests