#85545 - 2002-04-26 05:05 PM
BlockInput (...or, how to disable mouse/keyboard)
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
I am VB illiterate, so I have no idea how to translate this into Kix. HELP!
code:
Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Sub Form_Activate() DoEvents BlockInput True 'wait 10 seconds before unblocking it Sleep 10000 'unblock the mouse and keyboard input BlockInput False End Sub
[ 26 April 2002, 17:06: Message edited by: Chris S. ]
|
Top
|
|
|
|
#85546 - 2002-04-28 05:27 PM
Re: BlockInput (...or, how to disable mouse/keyboard)
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Chris,
I just wrapped this API in a command-line utility called block.exe, email me at stassie@sympatico.ca if you would like to get a copy:
You run it like this:
c:\> block "dir c:\windows"
The idea being that the command-line (or kix script) gets spawned-off and run with input disabled. I tried using things like RUNDLL but it doesn't work. There are freeware ActiveX wrappers for this API as well, let me know if your interested in I'll track down the links:
Here's the C code if you want to roll your own:
code:
#include <windows.h> #include <stdio.h> #include <winable.h>
int main (int argc, char **argv) { if (argc < 2) { printf("usage: block cmdline\n"); return 1; } BlockInput(1); system(argv[1]); BlockInput(0); return 0; }
-Shawn [ 28 April 2002, 19:32: Message edited by: Shawn ]
|
Top
|
|
|
|
#85548 - 2002-04-28 07:51 PM
Re: BlockInput (...or, how to disable mouse/keyboard)
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Les,
Consider it done - I just fired-off a note to Ruud about this. I don't have anymore pull than anybody else around here - but I think this would make an EXCELLENT addition to the kixtart scripting langauge. Very dangerous function though - have to handle with care - I haven't locked myself out of my system yet ( today hehee ).
-Shawn
|
Top
|
|
|
|
#85551 - 2002-04-29 12:29 AM
Re: BlockInput (...or, how to disable mouse/keyboard)
|
kholm
Korg Regular
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
The freeware tool AutoIt has a BlockInput command
On WinNT sp. 6 and Win2k+ mouse and keyboard is locked AutoIt is still able to send keystrokes to the aplication
On Win98+ mouse and keyboard is locked
As an example, if you have a silent install: Setup.exe -s
You can make this small AutoIt script:
BlockInput, on Run, Setup.exe -s BlockInput, off
AutoIt can compile the script to an .exe-file, the exe-file will have a size of about 40k
AutoIt can be found here: AutoIt Homepage
AutoIt also have a COM (ActiveX) interface: AutoItX.dll If you register this you can use this KiX code (To make this usefull you sholud let your logonscript register it for you)
$oAutoIt = CreateObject("AutoItX.Control") $oAutoIt.BlockInput("on") Shell '%COMSPEC% Start /Wait Setup.exe -s' $oAutoIt.BlockInput("off")
As an extra bonus AutoIt can control the mouse (Move/Leftclick/rightclick and more)
-Erik
Ps. If you use AutoIt, you get locked in again when the script ends, if you make a never ending story (Bad loop) You are locked out.
Be careful if you add this as a Run-Key in WinNT (Not Tested) In the tested operating systems: Win9x,WinME,Win2k and WinXP you can start in failsafe mode and renove the Run-Key from the registry if it loops. Just joking In my oppinion Win2k+ looks like Win9x with WInNT secutity (And plug'n'play)
|
Top
|
|
|
|
#85552 - 2002-04-29 02:47 PM
Re: BlockInput (...or, how to disable mouse/keyboard)
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Thanks all, for your input!
I think I'll go with the AutoIt solution as that allows more control within Kix scripts itself. The funny thing is that I was requesting this solution because AutoIt could do it and I thought we'd be able to do it with Kix as well (if we could figure out how to access the API layer).
I had completely forgotten about AutoItX. I use AutoIt quite extensively to script automated installations, but have never used AutoItX.
{EDIT}
I just looked at the AutoIt homepage and noticed that a new version was released in Feb. It includes a pure DLL version of AutoIT! This should make it easier to incorporate many of AutoIt's useful functions within Kix. [ 29 April 2002, 15:00: Message edited by: Chris S. ]
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 557 anonymous users online.
|
|
|