Jump to content

BlockInput except for HotkeySet or specific keys? [Solved/Recommended Function]


Recommended Posts

1) Excuse my ignorance, but is there a way to disable ctrl-alt-del? I'm a newbe and don't know how to make dll-calls, but on this site http://www.andreavb.com/tip020011.html(...)

As you can see in your mentioned script, disabling of Ctrl+Alt+Del is possible just in Win95/98. As far as I know, you cannot disable Ctrl+Alt+Del under NT family Windows (2000, XP, Vista, etc). You can just close the TaskManager automatically immediately after opening.

Edited by Morteza
Link to post
Share on other sites

As you can see in your mentioned script, disabling of Ctrl+Alt+Del is possible just in Win95/98. As far as I know, you cannot disable Ctrl+Alt+Del under NT family Windows (2000, XP, Vista, etc). You can just close the TaskManager automatically immediately after opening.

It is possible to disable ctrl+alt+del.

However this is not something that should be discussed nor implemented in AutoIt.

Broken link? PM me and I'll send you the file!

Link to post
Share on other sites
  • 2 weeks later...

@Firefox

Ive tested it and found one beug if you enter only one key for block :

Global $ah_Hooks = _BlockInputEx(1, -1, "0x1B");Computer lag with only one key
...
What you mean by "lag"? I think your understanding of how the function works is wrong - The third paraneter is an exclude list, these keys will NOT be blocked, it will block all keys except these on the list :)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to post
Share on other sites

@MrCreator

This reply was posted a long time ago, now its solved; just answer to my pm please :)

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

 

Link to post
Share on other sites

Here is another version, with «Includes» support:

#include <WinAPI.au3>

HotKeySet("{ESC}", "_Quit")
HotKeySet("{F1}", "_Quit")
HotKeySet("{F2}", "_Quit")
HotKeySet("{F3}", "_Quit")
HotKeySet("{F4}", "_Quit")

;Here we block only keys 1, 2, 3, 4 and 5 (try to press them ;) )
Global $ah_Hooks = _BlockInputEx(1, 1, _
    "0x1B|0x70|0x71|0x72|0x73", _ ;0x1B={ESC},0x70="{F1}",0x71="{F2}",0x72="{F3}",0x73="{F4}"
    "0x31|0x32|0x33|0x34|0x35") ;0x31=1,0x32=2,0x33=3,0x34=4,0x35=5 (Remove this or leave as blank, and the $sExclude will be counted)

AdlibEnable("_Quit", 5000) ;This is only for testing, so if anything go wrong, the script will exit after 5 seconds.

While 1
    Sleep(100)
WEnd

; $iBlockMode Option:
;                    -1 - Block All
;                    0  - Block only mouse
;                    1  - Block only keyboard
; $sExclude Option:
;                    Keys to exclude when blocking - All keys will be blocked, except the keys in $sExclude list.
; $sInclude Option:
;                    Keys to include when blocking - only these keys will be blocked, in this case $sExclude ignored completely.
Func _BlockInputEx($ah_Block_Hooks=0, $iBlockMode=-1, $sExclude="", $sInclude="")
    Select
        Case IsArray($ah_Block_Hooks)
            If $ah_Block_Hooks[2] > 0 Then DllCallbackFree($ah_Block_Hooks[2])
            If $ah_Block_Hooks[3] > 0 Then DllCallbackFree($ah_Block_Hooks[3])
            
            If $ah_Block_Hooks[4] > 0 Then _WinAPI_UnhookWindowsHookEx($ah_Block_Hooks[4])
            If $ah_Block_Hooks[5] > 0 Then _WinAPI_UnhookWindowsHookEx($ah_Block_Hooks[5])
            
            $ah_Block_Hooks[2] = 0
            $ah_Block_Hooks[3] = 0
            $ah_Block_Hooks[4] = 0
            $ah_Block_Hooks[5] = 0
            
            Return 1
        Case IsNumber($ah_Block_Hooks) And $ah_Block_Hooks > 0
            Local $pStub_KeyProc = 0, $pStub_MouseProc = 0, $hHookKeyboard = 0, $hHookMouse = 0
            
            If $iBlockMode = -1 Or $iBlockMode = 0 Then
                $pStub_MouseProc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr")
                $hHookMouse = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($pStub_MouseProc), _
                    _WinAPI_GetModuleHandle(0), 0)
            EndIf
            
            If $iBlockMode = -1 Or $iBlockMode = 1 Then
                $pStub_KeyProc = DllCallbackRegister("_Key_Proc", "int", "int;ptr;ptr")
                $hHookKeyboard = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($pStub_KeyProc), _
                    _WinAPI_GetModuleHandle(0), 0)
            EndIf
            
            Local $aRet[6] = ["|" & $sInclude & "|", "|" & $sExclude & "|", _
                $pStub_KeyProc, $pStub_MouseProc, $hHookKeyboard, $hHookMouse]
            
            Return $aRet
        Case Else
            Return SetError(1, 0, 0)
    EndSelect
EndFunc

Func _Key_Proc($nCode, $wParam, $lParam)
    If $nCode < 0 Then Return _WinAPI_CallNextHookEx($ah_Hooks[4], $nCode, $wParam, $lParam)
    
    Local $KBDLLHOOKSTRUCT = DllStructCreate("dword vkCode;dword scanCode;dword flags;dword time;ptr dwExtraInfo", $lParam)
    Local $vkCode = "0x" & Hex(DllStructGetData($KBDLLHOOKSTRUCT, "vkCode"), 2)
    
    If $ah_Hooks[0] <> "||" Then
        If StringInStr($ah_Hooks[0], "|" & $vkCode & "|") Then Return 1 ;Block!
    Else
        If Not StringInStr($ah_Hooks[1], "|" & $vkCode & "|") Then Return 1 ;Block!
    EndIf
    
    _WinAPI_CallNextHookEx($ah_Hooks[4], $nCode, $wParam, $lParam)
EndFunc

Func _Mouse_Proc($nCode, $wParam, $lParam)
    If $nCode < 0 Then Return _WinAPI_CallNextHookEx($ah_Hooks[5], $nCode, $wParam, $lParam)
    
    Return 1
EndFunc

Func _Quit()
    _BlockInputEx($ah_Hooks)
    
    Exit
EndFunc

:)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to post
Share on other sites

@MrCreator

This reply was posted a long time ago, now its solved; just answer to my pm please :think:

Cheers, FireFox.

One month it's a long time ago? :)

P.S

What can i do if the subscription is deleted after only 3 days when there is no answers in the topic? :lmao:

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to post
Share on other sites

@MrCreator

:lmao: thanks for your fixed function, I will add it to my 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

 

Link to post
Share on other sites

I posted another, better version of BlockInputEx UDF in the Examples forum: _BlockInputEx UDF!

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...