title: How to call BlockInput in VBS
body: <p>I have found on this <a href="http://www.sqaforums.com/showflat.php?Cat=0&amp;Number=304924&amp;page=&amp;fpart=&amp;vc=1" rel="nofollow noreferrer">site</a> code for VBS to block user input. To simplify, code is:</p>
  <pre><code>Sub StopKeyMouse()
      Set Def_DLL = DLL.DefineDLL(&quot;USER32&quot;)
      Def_Proc = Def_DLL.DefineProc(&quot;BlockInput&quot;, vt_b1, vt_b1) 
      Set Lib = DLL.Load(&quot;USER32.DLL&quot;, &quot;USER32&quot;)
      Lib.BlockInput(True)
  End Sub
  
  Sub ResumeKeyMouse()
    Set Def_DLL = DLL.DefineDLL(&quot;USER32&quot;)
    Def_Proc = Def_DLL.DefineProc(&quot;BlockInput&quot;, vt_b1, vt_b1) 
    Set Lib = DLL.Load(&quot;USER32.DLL&quot;, &quot;USER32&quot;)
    Lib.BlockInput(False)
  End Sub
  
  Sub Test()
      StopKeyMouse()
  
      WScript.Sleep 1000
      
      ResumeKeyMouse()
  End Sub
  
  Test()
  </code></pre>
  <p>When I run it, I get the error <code>Object required: 'DLL'</code>. Since the post is from 2004, I assume that VBS interaction with User32.dll has been changed.</p>
  <p>I am missing a line with <code>CreateObject</code>, something like <code>Set DLL = CreateObject(&quot;User32.dll&quot;)</code>.</p>
  <p>Does anybody know what is correct code for script to work?</p>
  <p>I have also found that it was possible to use</p>
  <pre><code>Set oAutoIt = CreateObject(&quot;AutoItX.Control&quot;)   
  oAutoIt.BlockInput &quot;on&quot;  
  </code></pre>
  <p>But this is obsolete.</p>
  <p>Is it possible to call <a href="https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-blockinput?redirectedfrom=MSDN" rel="nofollow noreferrer">BlockInput</a> from VBS?</p>
  <p>Thank you for any help.</p>