Need to disable ALT+F4's closing application functionality

Ask gaming related questions (AHK v1.1 and older)
tiltedtim
Posts: 13
Joined: 15 Sep 2022, 08:25

Need to disable ALT+F4's closing application functionality

Post by tiltedtim » 15 Sep 2022, 09:00

Hi all,

I'd like to disable ALT+F4's ability to close World of Warcraft but I still want ALT+F4 to be usable as a keybind in-game.
I've been looking through a lot of posts and I don't think I've come across a solution to my issue. That being said I don't have a script to start off with since I've tried many iterations of disabling !F4 with no success. Any help would be appreciated!

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

Re: Need to disable ALT+F4's closing application functionality

Post by mikeyww » 15 Sep 2022, 21:41

Welcome to this AutoHotkey forum!

Code: Select all

!F4::MsgBox, 48, Nope, Nope!

gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: Need to disable ALT+F4's closing application functionality

Post by gregster » 15 Sep 2022, 21:50

tiltedtim wrote:
15 Sep 2022, 09:00
I've tried many iterations of disabling !F4 with no success.
That sounds like a permissions issue.
https://www.autohotkey.com/docs/FAQ.htm#uac wrote:By default, User Account Control (UAC) protects "elevated" programs (that is, programs which are running as admin) from being automated by non-elevated programs, since that would allow them to bypass security restrictions. Hotkeys are also blocked, so for instance, a non-elevated program cannot spy on input intended for an elevated program.

tiltedtim
Posts: 13
Joined: 15 Sep 2022, 08:25

Re: Need to disable ALT+F4's closing application functionality

Post by tiltedtim » 16 Sep 2022, 21:48

gregster wrote:
15 Sep 2022, 21:50
tiltedtim wrote:
15 Sep 2022, 09:00
I've tried many iterations of disabling !F4 with no success.
That sounds like a permissions issue.
https://www.autohotkey.com/docs/FAQ.htm#uac wrote:By default, User Account Control (UAC) protects "elevated" programs (that is, programs which are running as admin) from being automated by non-elevated programs, since that would allow them to bypass security restrictions. Hotkeys are also blocked, so for instance, a non-elevated program cannot spy on input intended for an elevated program.
I've tried running AHK as admin as well as running the script as admin but with no luck. Is there more that I could do to elevate permissions? Maybe to temporarily alter registry to disable the application-closing functionality of ALT+F4?
I'm trying this simple script from a previous thread but it's disabling the key bind all together. ie I can press F4 to use an ability, I can press ALT+F1 to use an ability, but ALT+F4 isn't registering as a key press at all.

tiltedtim
Posts: 13
Joined: 15 Sep 2022, 08:25

Re: Need to disable ALT+F4's closing application functionality

Post by tiltedtim » 16 Sep 2022, 22:34

Simple script that I forgot to add
!F4::Return

tiltedtim
Posts: 13
Joined: 15 Sep 2022, 08:25

Re: Need to disable ALT+F4's closing application functionality

Post by tiltedtim » 25 Sep 2022, 00:03

Is there a way to turn !F4::Return into disabling the close-program function without disabling the full keybind?

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

Re: Need to disable ALT+F4's closing application functionality

Post by mikeyww » 25 Sep 2022, 05:08

1. What is the close-program function?
2. What does "without disabling the full keybind" mean?

tiltedtim
Posts: 13
Joined: 15 Sep 2022, 08:25

Re: Need to disable ALT+F4's closing application functionality

Post by tiltedtim » 26 Sep 2022, 08:46

@mikeyww 1. Close-program function: When press Alt+F4 it closes the active program/window.
2. I'm using the keybinds Alt+F1-12 in a game, World of Warcraft specifically. I don't want Alt+F4 to close my game but I still want to use Alt+F4 as a keybind in game. Is it possible?

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

Re: Need to disable ALT+F4's closing application functionality

Post by mikeyww » 26 Sep 2022, 09:27

Yes. You can create a hotkey for Alt+F4. An example is in my first post.

tiltedtim
Posts: 13
Joined: 15 Sep 2022, 08:25

Re: Need to disable ALT+F4's closing application functionality

Post by tiltedtim » 26 Sep 2022, 11:01

I understand that I can create a hotkey for Alt+F4. My question is, is it possible to stop Alt+F4 from closing the active program/window WITHOUT disabling the keystroke all together? If so, what would that script look like?

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

Re: Need to disable ALT+F4's closing application functionality

Post by mikeyww » 26 Sep 2022, 12:02

I do not understand the question. What should happen when the key combination is pressed? You would use the answer for your new hotkey.

tiltedtim
Posts: 13
Joined: 15 Sep 2022, 08:25

Re: Need to disable ALT+F4's closing application functionality

Post by tiltedtim » 26 Sep 2022, 13:37

When I press Alt+F4, I want the key combination to be executed as normal(as if I'm pressing any other key combination like Shift+F2) but I don't want it to close the game.

tiltedtim
Posts: 13
Joined: 15 Sep 2022, 08:25

Re: Need to disable ALT+F4's closing application functionality

Post by tiltedtim » 26 Sep 2022, 13:41

Simply put, when the script is active I don't want Alt+F4 to close applications.

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

Re: Need to disable ALT+F4's closing application functionality

Post by mikeyww » 26 Sep 2022, 14:24

I am puzzled. Your game would probably have a maximum of one way to handle Alt+F4, even if it uses that way to do different things in different contexts. With AHK, you have the choice of letting your game do what it usually does, or doing something different via AHK. If pressing the keys usually closes your game, then that would be the normal action, and you could use AHK to alter it as you like.

tiltedtim
Posts: 13
Joined: 15 Sep 2022, 08:25

Re: Need to disable ALT+F4's closing application functionality

Post by tiltedtim » 28 Sep 2022, 15:48

Could a script toggle the application-closing function within windows, via registry edits? If so, could someone write it for me?

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

Re: Need to disable ALT+F4's closing application functionality

Post by mikeyww » 28 Sep 2022, 16:49

You can just use a hotkey to do that. We are going around in circles.

tiltedtim
Posts: 13
Joined: 15 Sep 2022, 08:25

Re: Need to disable ALT+F4's closing application functionality

Post by tiltedtim » 28 Sep 2022, 21:38

Ok, what would that hotkey code look like? I'm hoping someone could write it for me

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

Re: Need to disable ALT+F4's closing application functionality

Post by mikeyww » 29 Sep 2022, 09:22

Hmm... I can see that I'm not being helpful, so will sign off here. Others may have some suggestions for you. Best of luck.

User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: Need to disable ALT+F4's closing application functionality

Post by YoucefHam » 01 Oct 2022, 11:36

tiltedtim wrote:
15 Sep 2022, 09:00
Hi all,

I'd like to disable ALT+F4's ability to close World of Warcraft but I still want ALT+F4 to be usable as a keybind in-game.
I've been looking through a lot of posts and I don't think I've come across a solution to my issue. That being said I don't have a script to start off with since I've tried many iterations of disabling !F4 with no success. Any help would be appreciated!
Hi, try this

Code: Select all

Alt_Pressed := false

*LAlt::
Alt_Pressed := true
KeyWait, LAlt
Alt_Pressed := false
return

#if Alt_Pressed

$F4::return

#if
:wave: There is always more than one way to solve a problem. ;)

tiltedtim
Posts: 13
Joined: 15 Sep 2022, 08:25

Re: Need to disable ALT+F4's closing application functionality

Post by tiltedtim » 02 Oct 2022, 00:23

I had faith in that one but no luck. It acts the same as !F4::return. Unfortunately, I don't think AutoHotkey is the solution to this problem, and I need to look into disabling the force-quit function within windows registry.

Post Reply

Return to “Gaming Help (v1)”