a::Joy1then please note that AHK does not support this, and what you want is actually technically very complex, with numerous IFs and BUTs.
I am having to repeat myself a lot on this, so I am going to make one post where I lay it all out and explain what is possible, what is not possible, and what tools can help you.
First off, I will clarify some terms I will be using...
"XInput" or "XI" - This refers to any Xbox/XbOne pad. Specifically xbox. Playstation pads are different.
"DirectInput" or "DI" - This refers to any non-xbox joystick. Flight sticks, Playstation pads, steering wheels etc all fall into this category.
"Physical stick" - A real joystick or joypad that you are using to control the game. If you want to use the stick to play the game as normal, but alter how just one button behaves, then you are trying to alter how the game sees your physical stick.
"Virtual stick" - A fake (software) joystick created by the likes of vJoy.
A note on Playstation pads:
PS pads are basically DirectInput, but not ALL of their inputs work via DirectInput. Gyro, Touchpad and accelerometers are NOT supported when reading a PS pad via DirectInput.
Vanilla AHK (Without any addon code libraries or third party software) does not support sending as a stick, period.
Basically NOTHING supports sending as a "Physical" stick.
The only case that I am aware of in which you can alter how a game sees your physical stick is using x360CE with an XInput controller. However, this is effectively a hack, as it requires placing a fake XInput.dll in the game folder.
In all other cases, the way this is done is:
1) Create a virtual controller (eg using vJoy)
2) Remap all input from the physical to the virtual controller (With any desired changes in mappings etc)
3) Force the game to only take input from the virtual controller
Below is a more detailed description as how to achieve each step (Both using AHK and with other solutions)
1. Creating virtual controllers
2. Remapping input from the physical controller to the virtual controller
To create a virtual controller, you will need a bit of software which can create fake controllers and allow them to be controlled by our code. There are two main players:
Emulates DirectInput controllers. There is also a variant (Called "vXBox" or "vGen") that can create virtual XInput controllers.
I have a library for AHK that lets you control virtual DirectInput sticks using vJoy here: https://autohotkey.com/boards/viewtopic.php?t=5705
This library does not support vXBox/vGen, so no virtual XInput controllers using this library. I do not plan on updating it as vXBox is dead now we have ViGEm
Emulates various gamepads (XInput, Playstation etc). Does not emulate DirectInput yet.
There is currently no AHK library for driving ViGEm, but it is technically possible, and in fact quite easy if you used CLR and the C# interface to ViGEm.
I do plan on doing this at some point, but I am waiting for ViGEm to mature a little more.
So AHK scripts are currently a little limited for this part of the equation. Add into the fact that AHK's support for reading physical joysticks is littered with issues which will never be fixed (Support for only 6 axes, 32 buttons / Joystick button bindings do not work properly -
Joy1::areleases a as soon as you press Joy1, not when you release it) so as a newbie, I would advise forgetting about using AHK scripts for remapping joysticks if at all possible. It *is* possible to work around these issues in an AHK script, but it is not trivial.
However, there are a couple of applications that can save you having to do any coding at all:
https://autohotkey.com/boards/viewtopic ... 19&t=12249
A remapping application written in AutoHotkey. Yes, it can control virtual xbox controllers, I just did not rip out that code and make it stand-alone, so it only exists in UCR-AHK.
It is worth noting that the "Code Runner" plugin can run some AHK script in response to you pressing a button, so some things other than plain remaps might be possible using this.
UCR-C# (AKA UCR2)
A rewrite of UCR-AHK in C#. This supports ViGEm as well as vJoy.
3. Hiding physical controllers
This is the one that tends to be the problem.
For XInput controllers, there is no known software-only solution to hide the controller from the game (A Titan device can do it, but you need to buy one).
As previously mentioned, X360ce can alter how the game sees the controller, so this is your only real choice if you must use a physical XInput controller.
However, it is worth noting that if your game expects an xbox controller, there is no reason you actually need to be using one. You can use a Playstation controller (which we *can* hide) as your physical controller, and output as a virtual XInput controller.
For DirectInput controllers, we can use HidGuardian ("HG"). I have written a little utility in AHK called https://autohotkey.com/boards/viewtopic ... hiteKnight that can install HG for you and help you setting it up.
However, if using a DirectInput controller, many games let you select which controller to use, so you can just select the virtual one when in normal use. The main reason you need to hide is if you need to use the bind menu in the game - if the physical controller is not hidden, when you press a button it will bind to the physical controller not the virtual one.