Jump to content

BlockInputEx UDF!


MrCreatoR
 Share

Recommended Posts

  • 2 months later...

nice UDF!

I am trying to block input to everything but a particular window. I have tried using the following code with no success. is this possible with your UDF? or is $hWindows only intended to control blocking FOR a specific window?

#include <BlockInputEx.au3>

;================== hWindows usage Example ==================

HotKeySet("{ESC}", "_Quit")

Run(@WindowsDir & "\Notepad.exe", "", @SW_MAXIMIZE)
WinWait("[REGEXPCLASS:Notepad.*]")
$hNotepad_Wnd = WinGetHandle("[REGEXPCLASS:Notepad.*]")

ControlSetText($hNotepad_Wnd, "", "", _
    "Now try to input some keys in here..." & @CRLF & _
    "Well, that's the idea, you can't, don't you?" & @CRLF & @CRLF & ":)")

;Here we block *All* keyboard keys for every window but Notepad's window
_BlockInputEx(3, "[:ALPHA:]|[:NUMBER:]|{ENTER}|{ALT}|{TAB}|{BACKSPACE}", "", $hNotepad_Wnd)

While 1
    Sleep(10000)
    _Quit()
WEnd

Func _Quit()
    Exit
EndFunc

-Homes32

Edited by Homes32
Link to comment
Share on other sites

  • 3 months later...

I have a problem : when I use this on my script

_BlockInputEx(3, "[:ALPHA:]|[:NUMBER:]|{ENTER}|{BACKSPACE}","{LWIN}|{RWIN}|{DEL}|{LCTRL}|{RCTRL}|{ALT}|{TAB}|{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}")

Afterthat, these keys :LWIN, RWIN, DEL, LCTRL, RCTRL, ALT, TAB, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12 is blocked, although the script is ended!

Link to comment
Share on other sites

  • 2 months later...

UDF updated!

History version:

[v1.4 - 03.08.2010, 12:00]

+ AutoIt 3.3.6.1 support.

* Fixed an issue with held down "Alt + Ctrl" keys after the user was called "Alt + Ctrl + Del". It was causing a problems to use HotKeySet later.

* Fixed examples to be compatible with AutoIt 3.3.6.1.

* Minor "cosmetic" changes.

[v1.3 - 24.09.2009, 23:00]

+ Added _BlockInputEx Example (Pass Lock)

* Fixed few examples.

* Fixed spell mistakes in the UDF.

Please check the first post.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

For those ho downloaded the last version, please re-download, i made one small fix (related to «issue with held down "Alt + Ctrl" keys»). The version is the same.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

For those ho downloaded the last version, please re-download, i made one small fix (related to «issue with held down "Alt + Ctrl" keys»). The version is the same.

I try _BlockInputEx Example (Include usage).au3 but i can use 1, 2, 3 num key Posted Image

Is it for all keyboard, like french Azerty ?

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I try _BlockInputEx Example (Include usage).au3 but i can use 1, 2, 3 num key Posted Image

Is it for all keyboard, like french Azerty ?

So what is the problem? :blink: before you runing the examples, you might want to open the scripts and check the comments ;)

...

HotKeySet("1", "_Quit")
HotKeySet("2", "_Quit")
HotKeySet("3", "_Quit")

;Here we block only the following keyboard keys: 0x31 = "1", 0x32 = "2", 0x33 = "3" (try to press them ;) )
_BlockInputEx(1, "", "0x31|0x32|0x33")

...

scratch that, i thought you wrote that you can't use the keys...

All correct, the example includes only standard numbers, to include numpad keys we need to set different keys:

...

;Here we block only the following keyboard keys (try to press them ;) ):
; 0x31 = "1"
; 0x32 = "2"
; 0x33 = "3"
; 0x61 = "Numpad1"
; 0x62 = "Numpad2"
; 0x63 = "Numpad3"
;_BlockInputEx(1, "", "0x31|0x32|0x33|0x61|0x62|0x63")
_BlockInputEx(1, "", "1|2|3|{NUMPAD1}|{NUMPAD2}|{NUMPAD3}") ;The same as previous commented line

...
Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

scratch that, i thought you wrote that you can't use the keys...

All correct, the example includes only standard numbers, to include numpad keys we need to set different keys:

...

;Here we block only the following keyboard keys (try to press them ;) ):
; 0x31 = "1"
; 0x32 = "2"
; 0x33 = "3"
; 0x61 = "Numpad1"
; 0x62 = "Numpad2"
; 0x63 = "Numpad3"
;_BlockInputEx(1, "", "0x31|0x32|0x33|0x61|0x62|0x63")
_BlockInputEx(1, "", "1|2|3|{NUMPAD1}|{NUMPAD2}|{NUMPAD3}") ;The same as previous commented line

...

Ok it's work fine ! Posted Image

And sorry for the confusion...

AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

  • 1 month later...

Hello,

is it possible to allow input to one window only and rest all windows are blocked?

The example shows blocking only Notepad and rest all other windows have been allowed the input.

on second thoughts:

If windowFocus is Notepad then enable only specific keys (eg numeric keypad) and specific mouse movements (restricted in a specific area)

Else if Notepad is out of focus then disable all keys except AltTAB

regards

Deltarocked

Edited by deltarocked
Link to comment
Share on other sites

  • 2 weeks later...

Update...

ChangeLog:

[v1.5 - 11.10.2010, 22:20]

* Fixed an issue with re-enabled input after pressing Ctrl+Alt+Del.

* Now the $hWindows parameter can be used for mouse blocking.

----For that reason the $i_MouseHookGetAncestorHwnd variable was added to the UDF,

----if user sets it to 0, then the $hWindows is compared to currently hovered window handle, otherwise (1 - default) it's compared to ancestor of the hovered window/control.

Please check the first post. Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 2 weeks later...

Maybe I am stupid, but how to block ONLY ctrl+alt+del? I just cannot do it -.-

I've tried in both ways:

#include <BlockInputEx.au3>
    ;================== CLASSes usage Example ==================    
HotKeySet("{ESC}", "_Quit") ;This will trigger an exit    

_BlockInputEx(3,"", "{LCTRL}|{RCTRL}|{ALT}|{DEL}|^!+{DEL}")
;This is only for testing, so if anything go wrong, the script will exit after 10 seconds. 

AdlibRegister("_Quit", 10000)    
While 1     
Sleep(100)  
WEnd    

Func _Quit()    
Exit  
EndFunc

I am using Windows 7 x64

Edited by zwierzak
Link to comment
Share on other sites

  • 1 month later...

ChangeLog:

* Fixed an issue with re-enabled input after pressing Ctrl+Alt+Del.

MrCreator, any insight you can give into how you fixed the Ctrl+Alt+Del issue? I see the problem happening in Yashied's UDF, where the keyboard hook is completely lost after Ctrl-Alt-Del (at least in Windows 7), but it doesn't happen with your program.

Also, I believe there's an issue in your BlockInputEx.au3 code, line #195:

If $nCode < 0 Then Return _WinAPI_CallNextHookEx($ah_MouseKeyboard_WinHooks[4], $nCode, $wParam, $lParam)

You assign $ah_MouseKeyboard_WinHooks[4] to an inclusion string, so that call will fail. Elsewhere in that function you correctly use this:

_WinAPI_CallNextHookEx($ah_MouseKeyboard_WinHooks[2], $nCode, $wParam, $lParam)

Thanks for your help, and the cool UDF =)

Edited by Ascend4nt
Link to comment
Share on other sites

  • 3 months later...

ChangeLog:

[v1.6 - 04.04.2011, 22:30]

* Fixed (again, caused by fix with re-enabled input) an issue with held down "Alt + Ctrl" keys after the user was called "Alt + Ctrl + Del".

* Fixed an issue with wrong parameter passed to _WinAPI_CallNextHookEx. Thanks to Ascend4nt.

+ Added remarks to the UDF header.

+ Added "Example - Block TaskMan.au3".

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 2 months later...

Hi MrCreator,

Thanks for your great work. I'm having problem with {`} (Grave Accent). I'm using winXP SP3. Here's my code

_BlockInputEx(3, "[:ALPHA:]|[:NUMBER:]|[:ARROWS:]|{SPACE}|{ENTER}|{BACKSPACE}|{INSERT}|{DEL}|{HOME}|{END}|{PGUP}|{PGDN}|{ESC}|{CTRL}|{SHIFT}|{CAPSLOCK}|{NUMLOCK}|{NUMPADDIV}|{NUMPADMULT}|{NUMPADSUB}|{NUMPADADD}|{NUMPADDOT}|{GRAVEACCENT}")

I've tried both {`} and {GRAVEACCENT} (as seen in the code) but none of them work. The Grave Accent in my environment is important as windows used it as a hotkey for switching language keyboard input. The less of the keys are fine.

Suggestion/advise are most welcom. Thanks in advance

Regards

Prakob

Link to comment
Share on other sites

  • 4 months later...

Thanks for your great work. I'm having problem with {`} (Grave Accent). I'm using winXP SP3. Here's my code

I've tried both {`} and {GRAVEACCENT} (as seen in the code) but none of them work. The Grave Accent in my environment is important as windows used it as a hotkey for switching language keyboard input. The less of the keys are fine.

Suggestion/advise are most welcom. Thanks in advance

Regards

Prakob

According to the example in the first post, you'd just use this structure instead ... |[`]"

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

  • 1 month later...

Awesome script and very useful. Is there any way to get it to block USER mouse input but still enable script input via mousemove()?

i found a problem with this u cant have your script using mousemove when u have blocked the inputs.

Still not a feature? Can't seem to find anything in the examples.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...