Autohotkey not working with NVIDIA Ansel

Ask gaming related questions (AHK v1.1 and older)
Quadnick
Posts: 29
Joined: 10 Mar 2021, 20:14

Autohotkey not working with NVIDIA Ansel

Post by Quadnick » 03 Feb 2023, 23:54

I'm a disabled with disabilities, so normal tasks are difficult for me. Normal tasks like holding down left or right mouse button to control the camera in NVIDIA's Ansel tool. Autohotkey usually has my back in situations like this, but no matter what I do, none of my scripts work when Ansel is open, whether normal or administrator.

My needs are simple, I just want to rebind the WASD movement keys to RCtrlBNM, and make left button and right button toggle.

Code: Select all

numpad6:: 
GetKeyState, state, lbutton  
if state = U 
 Send {lbutton Down}  
else  
Send {lbutton Up}  
return

rctrl::w
b::a
n::s
m::d
This is my normal go-to to achieve this, and it works fine in Hitman 3, but is not affective once I open Ansel. Any help would be greatly appreciated.

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

Re: Autohotkey not working with NVIDIA Ansel

Post by mikeyww » 04 Feb 2023, 00:01

Some programs block scripting or have keyboard conflicts with AHK, depending on their design. Instead of testing five hotkeys, try a one-line script that contains a single hotkey. Instead of remapping and sending keys, display a simple MsgBox when the hotkey is triggered. That tells you whether the hotkey is triggered when your target program is active. If you cannot trigger a simple MsgBox, then the other hotkeys probably will also not work. A MsgBox is typically an effective test because it does not rely on other events that might, in turn, depend on how the target window or program is designed to respond.

Quadnick
Posts: 29
Joined: 10 Mar 2021, 20:14

Re: Autohotkey not working with NVIDIA Ansel

Post by Quadnick » 04 Feb 2023, 00:39

I want to start out by saying that I am not proficient when it comes to creating scripts for Autohotkey. I found a couple of scripts that suited my needs many years ago and have been using them without issue ever since. Just wanted to add that bit of pretext before the next part in case what I did was stupid, or not what you meant.

I opened the Autohotkey help file and searched for message box, chose a suitable one, and made this script:

Code: Select all

b::
MsgBox, 4, , Would you like to continue?, 5  ; 5-second timeout.
IfMsgBox, No
    Return  ; User pressed the "No" button.
IfMsgBox, Timeout
    Return ; i.e. Assume "No" if it timed out.
Pressing B made it appear, and it functioned as it should. But while using it in-game, it would alt-tab me to the desktop and show the message box. Then while using it with Ansel open, it once again alt-tabbed me, but the Ansel control panel was flickering off and on on the left side of the screen. I could press alt-tab to tab through my open windows, but that was about it. Nothing else, including my mouse, was working. Ctrl+alt+deleting task manager open fixed it.

So, the script technically worked with Ansel open, but not very well. Also, I tried using just numpad6::lbutton, but that had no effect in Ansel.

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

Re: Autohotkey not working with NVIDIA Ansel

Post by mikeyww » 04 Feb 2023, 06:19

You could run the following with no additional code, and no other scripts running.

Code: Select all

#Requires AutoHotkey v1.1.33
b::MsgBox 64, Test, Test!
1. Test in Notepad.
2. Test in your target program.

If #1 works and #2 fails, then the issue likely relates to how your target program is responding. Since Ansel is, I think, some kind of graphical overlay that does screenshots, it might be "overtaking" everything with screen and keyboard, potentially with low-level techniques along the way. You can test with UI Access in case that helps.

https://www.autohotkey.com/docs/v1/FAQ.htm#uac

Since Ansel uses its own hotkeys, there could be a basic software conflict. You can also try a different hotkey, such as F3, that neither program seems to use.

From the look of it, Ansel is simply a screenshot program that lets you make some graphical adjustments. If needed, you can likely accomplish the same thing by making your display adjustments first, and then using any of the dozens of available screenshot programs, or AutoHotkey itself, to capture the screen.

Those are my only ideas. Others here may have more.

Quadnick
Posts: 29
Joined: 10 Mar 2021, 20:14

Re: Autohotkey not working with NVIDIA Ansel

Post by Quadnick » 04 Feb 2023, 16:07

Okay sweet. Following your ideas led me to a workaround.

I ran your message box while in-game and it alt-tabbed me, like the previous one. So not wanting to have my PC lock up again when I tried using it in Ansel, I put the game in windowed mode. The message popped up while in Ansel. I couldn't click "OK", but it did work. So then I tried F3::LButton, and that worked too. On a hunch, I tried my original script, and that also worked. So having the game on fullscreen or exclusive fullscreen is the problem. So as a workaround, I can just put the game in windowed mode when I want to use it. It's still not ideal, because catching a screenshot is highly reactionary, I can't alt+enter while Ansel is open, and I don't want to play windowed mode all the time. Knowing fullscreen is the problem, is there something I can add to my script that will help make it work while in fullscreen?

This is my script for Hitman 3

Code: Select all

*f7::toggle1  := !toggle1
#If (toggle1 = 1)

;AUTO WALK
~*lctrl:: 
GetKeyState, state, rctrl  
if state = U 
 Send {rctrl Down} 
else 
Send {rctrl Up}  
return 

;Ansel Control
*f8::toggle2  := !toggle2
#If (toggle2 = 1)

~*numpad6:: 
GetKeyState, state, lbutton  
if state = U 
 Send {lbutton Down}  
else  
Send {lbutton Up}  
return 

rctrl::w
.::s
Also, Ansel is an advanced screenshotting tool that has features nothing else can match, that I know of, such as adding in-depth filters, AI resolution upscaling, and the ability to fly around the entire map and view your character in third person.
Image

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

Re: Autohotkey not working with NVIDIA Ansel

Post by mikeyww » 04 Feb 2023, 17:04

I'm not sure. Others here may know.

Quadnick
Posts: 29
Joined: 10 Mar 2021, 20:14

Re: Autohotkey not working with NVIDIA Ansel

Post by Quadnick » 04 Feb 2023, 18:48

No worries. Thanks for your help thus far.

Quadnick
Posts: 29
Joined: 10 Mar 2021, 20:14

Re: Autohotkey not working with NVIDIA Ansel

Post by Quadnick » 05 Feb 2023, 18:02

Update: The workaround is even less viable now I realize. For some reason, pressing the hotkey to open Ansel pauses the game when it's in windowed mode. Ansel opens before the game is fully paused, but it makes the image almost black and white, because that's how the pause menu looks. I think it's happening because "pause on focus loss" is enabled, but there's no way to disable it in the settings, and I can't find any configuration files to edit. This is all way more of a pain than it should be.

Post Reply

Return to “Gaming Help (v1)”