Jump to content

Recommended Posts

Posted (edited)

  perwhis said:

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
Posted

  Morteza said:

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!

  • 2 weeks later...
Posted

@Firefox

  Quote

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 :)

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

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

:)

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

  FireFox said:

@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

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

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

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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...