Jump to content

Recommended Posts

  • 1 month later...

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
Link to post
Share on other sites
  • 3 weeks later...

Added to the wiki :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
Link to post
Share on other sites
On 7/30/2019 at 1:32 PM, Nine said:

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

That was what I was looking for. Thanks a lot!

On 10/4/2019 at 2:01 PM, Nine said:

I'll thing about a new name...

How about ;)
BlockInputEx9
BlockInputExBy9

...

Link to post
Share on other sites
  • 2 weeks later...
28 minutes ago, Norm73 said:

As soon as I use #RequireAdmin, I no longer have access to the external drive.

Nine’s solution _BlockInput(), unlike the standard BlockInput(), does not require #RequireAdmin.

However, during the block, Send() and MouseDown() do not work.

Instead, you need to use ControlSend() and ControlClick().  

These functions take at least a window handle as a parameter, and direct the keystroke/click to that window.

I haven’t had a problem using and them, even with third party windows, and they’re far more predictable, especially when you are worried about simultaneous user interaction, which I’m guessing you are.

Why don’t you try it out and if it doesn’t work correctly, post the code.

Edited by JockoDundee

Code hard, but don’t hard code...

Link to post
Share on other sites

Hello JockoDundee

I know that it is all best to do this via ControlSend.

Suffer my program where I do the emulation is not that simple and the handles are constantly changing.

I have taken note of this and am trying to do all of this via ControlSend.

Thank you very much!

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