Author Topic: Block Input  (Read 9084 times)

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Block Input
« on: June 08, 2017, 04:45:54 PM »
Would it be possible to add functionality to block input from the keyboard or mouse (or both) similar to how AutoHotkey handles BlockInput On/Off? VA seems to be able to prevent trigger key and mouse presses from being passed through, so why not extend that to functions for:
  • Block/Unblock all keyboard input or select keys
  • Block/Unblock all mouse input or select buttons
  • Block/Unblock all controller input or select buttons
What would really make this shine is if VA could continue to send its virtual keypresses or other input actions (like Quick Input) while physical keyboard/mouse/controller input is being blocked. This would allow VA to carry out its input tasks and prevent the user from accidentally disrupting the actions due to their physical input.


EDIT by Pfeil: Implemented.
« Last Edit: April 18, 2020, 12:44:04 PM by Pfeil »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2831
Re: Block Input
« Reply #1 on: June 08, 2017, 06:39:22 PM »
Interesting idea... I'll keep it in mind.  You can kind of do that now by creating a series of commands that intercept input and don't do anything... put them all in a profile and include that profile.

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: Block Input
« Reply #2 on: June 09, 2017, 08:27:31 AM »
That would be A LOT of commands to block all the different mouse clicks and keystrokes to accomplish a Block Input. Plus there would need to be a way to enable this blocking only when desired. Adding built-in functionality to block/unblock various kinds of input as part of the command actions would be a fantastic addition to VA.

After some searching and I did find a way to completely block all keyboard and mouse input via a VB.net inline function (code source here and more details here). Default reference assemblies are used.

Code: [Select]
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Data
Imports System.Drawing
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.Linq
Imports System.Xml.Linq
Imports System.Threading.Tasks

'~~ Source = http://forums.codeguru.com/showthread.php?411062-How-to-lock-or-disable-keyboard-input-using-VB-net

Public Class VAInline
   
    '~~ declare the BlockInput function from Windows API
    Public Declare Function apiBlockInput Lib "user32" Alias "BlockInput" (ByVal fBlock As Integer) As Integer

    Public Sub Main()
        '~~ block keyboard and mouse input
        apiBlockInput(1)
        '~~ pause for 3000 miliseconds
        System.Threading.Thread.Sleep(3000)
        '~~ unblock keyboard and mouse input
        apiBlockInput(0)

    End Sub

End Class

I think AutoHotKey employs a related methodology. The catch though is that in addition to blocking physical keypresses and mouse clicks all virtual key press & mouse click commands as well as Quick Input from VA are also blocked. VA mouse movement commands do still appear to work though.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2831
Re: Block Input
« Reply #3 on: June 09, 2017, 10:50:40 AM »
Sorry for the previous curt reply, as I'm pinned down for time and am having a hard time doing what needs to be done and not explaining fully why or why not a feature request is feasible. 

I'm not stuck on whether or not it *can* be done, as it would require about three lines of code using what's already in VA.  The issue is whether it *should* be done, as my take on 'globally'-effective functions is that it's always great right up until you don't want it to be.  Where this squirrels off is when ALL input is blocked and then the user is effectively hosed... they can't use the keyboard or the mouse to do anything and will probably need to just power down.  So then it becomes a customizable feature on what keys/mouse buttons are blocked and not blocked.  That's a lot of UI for new request that's only been asked for once, so, in lieu of saying, 'This will take a long time IF the demand is there', the suggestion was offered.  The onus is on the user, and yes, it will require a command for each and every key/mouse button you want to block, but it can be done now.

Also, you can create an Autohotkey script and call it from VA.


Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: Block Input
« Reply #4 on: June 11, 2017, 09:43:43 AM »
I definitely understand your concern about locking users out via Block Input. I think the Windows API breaks the block when the user presses Ctrl+Alt+Del (AHK works this way too), so at least there's that possible safety net. And yes I'm sure it would take some UI work to make select keys/clicks/buttons blocked unless there was a way to adapt existing UI elements. Though I'd wager that the majority of users that want to employ the block functionality would want to do it across an entire input (all keyboard, all mouse, etc) and would only be using it when VA processing takes more than 0.5-1 seconds.

In my opinion the block functionality would be particularly valuable if it blocks physical input but VA could still pass virtual input. Yes this could be done with AHK's out of the box, but it would be so awesome to do this natively with VA without having to perform partial coding in both VA and AHK. Food for thought :)

Trelos

  • Guest
Re: Block Input
« Reply #5 on: August 25, 2019, 12:45:07 AM »
Was this feature ever implemented? Having the ability to suppress inputs would be extremely helpful to me right now. As is, I would need to completely let go of the mouse in order to accurately execute a good number of the commands that I'm currently building. My mouse DPI is set to 12,000, so doing so is extremely jarring and takes an excessive amount of time to mentally recalibrate.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: Block Input
« Reply #6 on: August 25, 2019, 08:53:45 AM »
Yes, this was implemented over a year a go, in VoiceAttack v1.7.1

Search the documentation for "Block/Unblock" (press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF reader).

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Block Input
« Reply #7 on: April 26, 2023, 05:38:31 PM »
This relates to a recent post of mine when trying to block keypresses with VA, yet still have VA send those same keys from within its own command (Virtual Keys?).

If this hasn't yet been put in, I really wish it was.

If indeed there's a way to have in work in the way above, would ask for a confirmation on how that can be done.

Thanks much and sorry to Necro.

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Block Input
« Reply #8 on: April 26, 2023, 06:36:19 PM »
More specifically, this is what I'm thinking:  See attached..