Page 1 of 1 1
Topic Options
#85545 - 2002-04-26 05:05 PM BlockInput (...or, how to disable mouse/keyboard)
Chris S. Offline
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 Offline
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
#85547 - 2002-04-28 07:40 PM Re: BlockInput (...or, how to disable mouse/keyboard)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Shawn,
You're in good terms with the "big Guy" right? Maybe you could borrow his ear and get this added to the next version of KiX.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#85548 - 2002-04-28 07:51 PM Re: BlockInput (...or, how to disable mouse/keyboard)
Shawn Administrator Offline
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 [Wink] hehee ).

-Shawn

Top
#85549 - 2002-04-28 08:02 PM Re: BlockInput (...or, how to disable mouse/keyboard)
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Its too bad that the RUNDLL thingy didn't work. Then we could have made a UDF for it. Someone else might want to give it try, but I think the way it works is that the block is only effective for the current thread, and because RUNDLL is a program, the block goes away as soon as the first RUNDLL finishes ... I was trying stuff like this:

SHELL "%COMSPEC% /C RUNDLL32.EXE USER32.DLL,BlockInput 1"

?@ERROR

SHELL "%COMSPEC% /C RUNDLL32.EXE USER32.DLL,BlockInput 0"

But like I said, no worky. Also tried all kinds of variations of SHELL and RUN with no joy.

-Shawn

Top
#85550 - 2002-04-28 11:01 PM Re: BlockInput (...or, how to disable mouse/keyboard)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Know what ya mean about locking oneself out. [Wink]
Back in the days of DOS we had a few tricks. One I recall was redirecting input away from CON with the MODE command.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#85551 - 2002-04-29 12:29 AM Re: BlockInput (...or, how to disable mouse/keyboard)
kholm Offline
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.
[Wink] 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. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Thanks all, for your input! [Smile]

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
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (adamlevine) and 165 anonymous users online.
Newest Members
katherinknul, phamthuy, xuantu075, skygreen2031, amelindarķe
17629 Registered Users

Generated in 0.07 seconds in which 0.03 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org