Jump to content

Disabling Alt+Tab


iHonda
 Share

Recommended Posts

I searched the forum for this as well as the help file. and i also know that a hotkey would disable the keys however I need to do it only while a GUI is active so setting a hotkey wouldnt work because you cant unset a hotkey at least not that I can tell. any help would be welcome.

Peace,

iHonda

A great place to start Autoit 1-2-3

Link to comment
Share on other sites

I searched the forum for this as well as the help file. and i also know that a hotkey would disable the keys however I need to do it only while a GUI is active so setting a hotkey wouldnt work because you cant unset a hotkey at least not that I can tell. any help would be welcome.

Peace,

iHonda

To "unset" a hotkey, call HotKeySet() without passing a function name:

#include <GuiConstantsEx.au3>
$test = GUICreate("test")

$btnDisable = GUICtrlCreateButton("Disable ALT-TAB", 50, 50)
$btnEnable = GUICtrlCreateButton("Enable ALT-TAB", 50, 150)
GUICtrlSetState(-1, $GUI_DISABLE)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case - 3
            Exit
        Case $btnDisable
            HotKeySet("!{TAB}", "_DoNothing")
            GUICtrlSetState($btnEnable, $GUI_ENABLE)
            GUICtrlSetState($btnDisable, $GUI_DISABLE)
        Case $btnEnable
            HotKeySet("!{TAB}")
            GUICtrlSetState($btnDisable, $GUI_ENABLE)
            GUICtrlSetState($btnEnable, $GUI_DISABLE)

    EndSwitch
WEnd

Func _DoNothing()
    Return
EndFunc
Link to comment
Share on other sites

@NerdFencer

Your method does not work for me.

@ResNullius

Good old and easy method. But does not work in the any full-screen game. :)

This is my solution:

#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>

HotKeySet("{Pause}", "_Exit")

Global Const $VK_TAB = 0x09

$hHookProc = DllCallbackRegister("_KeyboardProc", "long", "int;wparam;lparam")

$hHookKeyboard = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hHookProc), _WinAPI_GetModuleHandle(0), 0)

While 1
    Sleep(100)
WEnd

Func _KeyboardProc($nCode, $wParam, $lParam)
    If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam)
    
    Switch $wParam
        Case $WM_KEYDOWN, $WM_SYSKEYDOWN, $WM_KEYUP, $WM_SYSKEYUP
            Local $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
            Local $vKode = DllStructGetData($tKEYHOOKS, "vkCode")
            Local $iFlags = DllStructGetData($tKEYHOOKS, "flags")
            
            Switch $vKode
                Case $VK_TAB
                    If BitAND($iFlags, $LLKHF_ALTDOWN) Then
                        Return -1
                    Else
                        Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam)
                    EndIf
            EndSwitch
    EndSwitch
    
    Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam)
EndFunc   ;==>_KeyboardProc

Func _Exit()
    DllCallbackFree($hHookProc)
    _WinAPI_UnhookWindowsHookEx($hHookKeyboard)
    Exit
EndFunc

Looks not easy, but works correct :lmao:

Edit: grammar spelling.

Edited by rasim
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...