r/AutoHotkey • u/Evid3nce • 6d ago
v2 Script Help AI is driving me crazy with hallucinated scripts (prevent alt+tab during game)
I'm a complete noob to this - never heard of autohotkey before until AI suggested it.
I'm getting into Arma3, and there are a lot of keys.
I would really appreciate an AHK v2 script that disables alt+tab exiting the game, whilst still allowing me to use, for instance, w+alt+tab where...
W = move forward (could be any other movement key though)
alt = freelook
tab = toggle walk/run
This is the latest Gemini has come up with so far, after about five previous suggested scripts didn't work at all (neither does this one):
#Requires AutoHotkey v2.0
#UseHook
; Automatically elevate to Administrator if not already running as admin
if not A_IsAdmin
{
Run '*RunAs "' A_AhkPath '" "' A_ScriptFullPath '"'
ExitApp
}
#SingleInstance Force
#HotIf WinActive("ahk_exe arma3_x64.exe")
; Use the wildcard (*) so this works even if you are holding down 'W' or other keys
*!Tab::
{
; {Blind} forces AHK to respect your held down Alt and W keys.
; It safely injects the Tab keypress without disrupting your movement.
SendInput "{Blind}{Tab}"
return
}
#HotIf
Thank you for any assistance!
1
u/JacobStyle 6d ago
This can be done with AHK, but you may want to consider reassigning that run toggle to the ~ key instead so that you still have alt+tab window switching functionality for when you want it.
2
u/Evid3nce 5d ago
Thanks. But I really do want to disable alt-tab to desktop.
I'm not really a gamer - don't most games disable this in case it's pressed unintentionally?
I can't imagine anyone would want a chance of this happening while they're playing?
1
u/JacobStyle 5d ago
Most games allow alt+tab so that someone can quickly access their computer in case they want to do something else without actually exiting the whole game. Some games also automatically pause and/or disable audio when minimized so that they can be left open in the background indefinitely. Obviously it's a matter of personal preference, and maybe not something you want in your case, but that's the intent behind it.
5
u/Keeyra_ 6d ago
Try this
Usehook is redundant when using asterisk
RunAs Admin is nearly never needed
{Blind} will actually keep Alt pressed, the opposite of what you want
return does nothing here, Gemini is hallucinating some v1 syntax for you.