Popular Post Nine 1,632 Posted July 30, 2019 Popular Post Share Posted July 30, 2019 (edited) This function can be use to block all inputs coming from mouse and keyboard, without having an UAC warning displayed. Version 2021-02-06 * Allows blocking either Mouse or Keyboard independently * Removed @error if already disable / enable * Checks for rightful parameters Basic Example : #include "BlockInputEX.au3" Opt("MustDeclareVars", 1) _BlockInput($BI_DISABLE) ; block input ConsoleWrite("Block all inputs" & @LF) _BlockInput($BI_DISABLE) ; useless since already disable Sleep(10000) _BlockInput($BI_ENABLE) ; enable input ConsoleWrite("Enable all inputs" & @LF) _BlockInput($BI_ENABLE) ; useless set since already enable Sleep(5000) _BlockInput($BI_DISABLE, $BI_MOUSE) ; block input mouse only ConsoleWrite("Block mouse only" & @LF) Sleep(10000) _BlockInput($BI_DISABLE, $BI_KEYBOARD); block input keyboard also ConsoleWrite("Block keyboard" & @LF) Sleep(10000) _BlockInput($BI_ENABLE, Default) ; enable all input ConsoleWrite("Reenable all inputs" & @LF) How to release a Block Example : #include <Constants.au3> #include <Misc.au3> #include "BlockInputEX.au3" Opt("MustDeclareVars", 1) _BlockInput($BI_DISABLE) Local $hTimer = TimerInit() While TimerDiff($hTimer) < 15000 If _IsPressed("10") And _IsPressed("11") And _IsPressed("12") Then ; pressing Ctrl-Shift-Alt release the block immediately Exit _BlockInput($BI_ENABLE) EndIf WEnd _BlockInput($BI_ENABLE) BlockInputEX.au3 Edited May 19, 2021 by Nine Norm73, Musashi, ad777 and 2 others 1 4 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
BigDaddyO 81 Posted September 16, 2019 Share Posted September 16, 2019 (edited) 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 September 16, 2019 by BigDaddyO SkysLastChance, Professor_Bernd and mLipok 1 2 Link to post Share on other sites
Nine 1,632 Posted September 16, 2019 Author Share Posted September 16, 2019 lol, when udf is simple enough, you can do anything with it.Great it worked for you. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
mikell 1,146 Posted October 4, 2019 Share Posted October 4, 2019 @Nine Nice UDF , you could give it an other name though because this one was already used Link to post Share on other sites
Nine 1,632 Posted October 4, 2019 Author Share Posted October 4, 2019 @mikell, thanks, I didn't know. I'll thing about a new name... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
Nine 1,632 Posted February 6, 2021 Author Share Posted February 6, 2021 New version available ps. too lazy to change name... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
water 2,720 Posted February 6, 2021 Share Posted February 6, 2021 Added to the wiki Nine 1 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to post Share on other sites
Nine 1,632 Posted May 19, 2021 Author Share Posted May 19, 2021 Added example how to release a block all input without restarting the computer (in case a problem occurs while the computer is blocked). “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
Professor_Bernd 58 Posted May 19, 2021 Share Posted May 19, 2021 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
JockoDundee 634 Posted May 22, 2021 Share Posted May 22, 2021 On 5/19/2021 at 10:38 AM, Professor_Bernd said: How about BlockInputEx9 BlockInputExBy9 How about 🤔 NeinInputEx Professor_Bernd 1 Code hard, but don’t hard code... Link to post Share on other sites
Norm73 7 Posted May 31, 2021 Share Posted May 31, 2021 Hello everyone, everything works as it says above. Is it possible that it will work that way?User input is blocked and AutoIt can simulate mouse and keyboard. Link to post Share on other sites
Nine 1,632 Posted May 31, 2021 Author Share Posted May 31, 2021 Yes you can by using ControlClick and ControlSend. MouseClick and Send will not work. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
Norm73 7 Posted May 31, 2021 Share Posted May 31, 2021 (edited) Too bad ☹️ The standard BlockInput function also works for me. But the function needs #RequireAdmin and that is exactly what causes me little problems. Edited May 31, 2021 by Norm73 Link to post Share on other sites
Nine 1,632 Posted May 31, 2021 Author Share Posted May 31, 2021 1 hour ago, Norm73 said: Too bad What is the problem with Control* functions ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
Norm73 7 Posted June 1, 2021 Share Posted June 1, 2021 As soon as I use #RequireAdmin, I no longer have access to the external drive. Link to post Share on other sites
JockoDundee 634 Posted June 1, 2021 Share Posted June 1, 2021 (edited) 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 June 1, 2021 by JockoDundee Norm73 1 Code hard, but don’t hard code... Link to post Share on other sites
Norm73 7 Posted June 1, 2021 Share Posted June 1, 2021 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now