Sign in to follow this  
Followers 0
iHonda

Disabling Alt+Tab

7 posts in this topic

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

@NerdFencer

Thanks for your example with the registry :)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

@NerdFencer thanks for the input but on some machines that requires a restart to take effect

@ResNullius Thanks for the info i didnt know it would work that way.


A great place to start Autoit 1-2-3

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@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

Share this post


Link to post
Share on other sites

@rasim

:lmao: can be done easier with BlockInputEx udf :)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0