Code:
; disable alt-f4 for wow - jason@godsey.net / binutils
; To end this script, right click quit on icon is systray or ctrl+alt+f4
; **********************************
; EDIT THIS STRING to make changes to the list of titles to ignore Alt+F4
; **********************************
Global $DisableAltF4List = "World of Warcraft; SciTE4AutoIt3; UltraEdit";
Global $Debug = true; ; Set to false if you don't want the splash screen popups when Alt+F4 is caught
; ***** The rest of the script should be ok to simply ignore
Opt("WinTitleMatchMode",4)
Opt("WinSearchChildren",1)
HotKeySet("!{F4}", "DisableAltF4");
HotKeySet("^!{F4}", "QuitDisableAltF4");
Func _SendMessage($hWnd, $msg, $wParam = 0, $lParam = 0, $r = 0, $t1 = "int", $t2 = "int")
Local $ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", $msg, $t1, $wParam, $t2, $lParam);
If @error Then Return SetError(@error, @extended, "");
If $r >= 0 And $r <= 4 Then Return $ret[$r];
Return $ret;
EndFunc
Func OnLoadDisableAltF4()
SplashTextOn("Disable Alt+F4", @CRLF & "Disable Alt+F4 by binutils Loaded" & @CRLF & @CRLF & "Press Ctrl+Alt+F4 to Exit this script." & @CRLF & @CRLF & "Current List of Window Titles to ignore Alt+F4" & @CRLF & @CRLF & "(edit this script to change)" & @CRLF & @CRLF & $DisableAltF4List );
Sleep(2500);
SplashOff();
EndFunc
Func QuitDisableAltF4()
SplashTextOn("Disable Alt+F4", @CRLF & "Disable Alt+F4" & @CRLF & @CRLF & "Exiting");
Sleep(1000);
SplashOff();
Exit
EndFunc
Func DisableAltF4()
Global $DisableAltF4List;
$Current = WinGetHandle("[active]");
Local $i;
Local $Pass = true; ; Default to passing unless we match a title givein in the DisableAltF4List
Local $DisableList = StringSplit($DisableAltF4List, ";");
If IsArray($DisableList) Then
For $i = 1 to UBound($DisableList) - 1
; MsgBox(0, "Test", "Testing " & WinGetTitle($Current) & " against " & $DisableList[$i]);
If (StringRegExp(WinGetTitle($Current), StringStripWS($DisableList[$i], 3), 0)) Then
$Pass = false;
EndIf
Next
EndIf
If ($Pass == true) Then
; We didn't match any titles so pass the kill message along to the application
_SendMessage($Current, 0x10, 0, 0); ; Windows WM_CLOSE 0x10 message
If ($Debug == true) Then
SplashTextOn("Disable Alt+F4", "Intercepted Alt+F4" & @CRLF & @CRLF & WinGetTitle($Current) & @CRLF & @CRLF & "Killed");
WinActivate($Current);
Sleep(200);
SplashOff();
EndIf
Else
If ($Debug == true) Then
SplashTextOn("Disable Alt+F4", "Intercepted Alt+F4" & @CRLF & @CRLF & WinGetTitle($Current) & @CRLF & @CRLF & "Ignoring");
WinActivate($Current);
Sleep(200);
SplashOff();
EndIf
EndIf
Return;
EndFunc
OnLoadDisableAltF4();
While (1=1)
Sleep(500);
WEnd