Modify

Opened 11 years ago

Closed 11 years ago

#622 closed Feature Request (Rejected)

_BlockInputExc

Reported by: Ken82m Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: BlockInput Block Input Exception Cc:

Description

This is written by another forum user, RASIM.

Here's the thread:
http://www.autoitscript.com/forum/index.php?showtopic=82650

And the code:

#include <WinAPI.au3>

HotKeySet("{F3}", "_UnBlock")

Global $pStub_KeyProc = DllCallbackRegister("_KeyProc", "int", "int;ptr;ptr")
Global $pStub_MouseProc = DllCallbackRegister ("_Mouse_Handler", "int", "int;ptr;ptr")

MsgBox(0, "", 'Now we block mouse and all keyboard keys except a "F3"')

Global $hHookKeyboard = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($pStub_KeyProc), _WinAPI_GetModuleHandle(0), 0)
Global $hHookMouse = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($pStub_MouseProc), _WinAPI_GetModuleHandle(0), 0)

While 1
    Sleep(100)
WEnd

Func _UnBlock()
    DllCallbackFree($pStub_KeyProc)
    DllCallbackFree($pStub_MouseProc)
    _WinAPI_UnhookWindowsHookEx($hHookKeyboard)
    _WinAPI_UnhookWindowsHookEx($hHookMouse)
    MsgBox(0, "_UnBlock", "Input unblocked")
    Exit
EndFunc

Func _KeyProc($nCode, $wParam, $lParam)
    If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam)
    
    Local $KBDLLHOOKSTRUCT = DllStructCreate("dword vkCode;dword scanCode;dword flags;dword time;ptr dwExtraInfo", $lParam)
    Local $vkCode = DllStructGetData($KBDLLHOOKSTRUCT, "vkCode")
    
    If $vkCode <> 0x72 Then Return 1
    
    _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam)
EndFunc

Func _Mouse_Handler($nCode, $wParam, $lParam)
    If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookMouse, $nCode, $wParam, $lParam)
    
    Return 1
EndFunc

I would love to see this added as parms to blockinput or a user defined function. It allows you to do a BlockInput but make exceptions for certain keys.

Whether to block the mouse or keyboard could also be made an option eaily.

-Kenny

Attachments (0)

Change History (2)

comment:1 Changed 11 years ago by TicketCleanup

  • Version 3.2.13.9 deleted

Automatic ticket cleanup.

comment:2 Changed 11 years ago by Valik

  • Resolution set to Rejected
  • Status changed from new to closed

This is just a little piece of example code. It's a long way from what it needs to be in order to even be considered for inclusion. Come back again when you have a function with documentation.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.