Jump to content
Sign in to follow this  
Nine

UDF BlockInputEX

Recommended Posts

This function can be use to block all inputs coming from mouse and keyboard, without having an UAC warning displayed.

Example :

#include <Constants.au3>
#include "BlockInputEX.au3"

Opt ("MustDeclareVars", 1)

_BlockInput ($BI_DISABLE)     ; block input
ConsoleWrite (@error & @CRLF)
_BlockInput ($BI_DISABLE)     ; @error is set since already disable
ConsoleWrite (@error & @CRLF)
Sleep (10000)
_BlockInput ($BI_ENABLE )     ; enable input
ConsoleWrite (@error & @CRLF)
_BlockInput ($BI_ENABLE )     ; @error is set since already enable
ConsoleWrite (@error & @CRLF)

 

BlockInputEX.au3

Share this post


Link to post
Share on other sites

Great work on this Nine!

 

Just because I'm super lazy and I just needed this to resolve a ControlSend issue, I created this from your code.

It's used just like you would ControlSend, but it blocks and unblocks keyboard and mouse during the process.

 

; #FUNCTION# ====================================================================================================================
; Name...........: _ControlSendSecure
; Description ...: Block all mouse and keyboard inputs, Sends Text to the control, then Unblocks all mouse and keyboard inputs
; Syntax.........: _ControlSendSecure()
; Parameters ....:
; Return values .: Success - Returns 1
;                  Failure - Returns 0
; Author ........: BigDaddyO, based off Nines _BlockInputEx
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _ControlSendSecure($s_Title, $s_Text, $s_ControlID, $s_Value, $bFlag = 0)
    $g_hStub_KeyProc = DllCallbackRegister("_BlockInput_MouseKeyProc", "long", "int;wparam;lparam")
    $g_hStub_MouseProc = DllCallbackRegister("_BlockInput_MouseKeyProc", "long", "int;wparam;lparam")
    Local $hMod = _WinAPI_GetModuleHandle(0)
    $g_hHook1 = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod)
    $g_hHook2 = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($g_hStub_MouseProc), $hMod)

    $iRet = ControlSend($s_Title, $s_Text, $s_ControlID, $s_Value, $bFlag)

    _WinAPI_UnhookWindowsHookEx($g_hHook1)
    _WinAPI_UnhookWindowsHookEx($g_hHook2)
    DllCallbackFree($g_hStub_KeyProc)
    DllCallbackFree($g_hStub_MouseProc)
    
    Return $iRet
EndFunc

 

Edited by BigDaddyO

hmm... I guess I have to have a signature...

Share this post


Link to post
Share on other sites

lol, when udf is simple enough, you  can do anything with it.Great it worked for you.

Share this post


Link to post
Share on other sites

@mikell, thanks, I didn't know.  I'll thing about a new name...

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...