Disable mouse and keyboard

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Disable mouse and keyboard

Post by SteenJakobsen » Wed May 19, 2010 4:33 am

Hi,

Is there a way to disable the mouse ande keyboard except for an key combination to stop the script..?

I would like to make shure that the user is uanble to interrupt the macro
by moving the mouse ot typing stuff :-)
Best Regards
Steen Jakobsen
DM Software A/S

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed May 19, 2010 7:21 am

Use the BlockInput command.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

JeffDaruecan
Newbie
Posts: 18
Joined: Thu Mar 25, 2010 11:00 am
Location: Vancouver

Post by JeffDaruecan » Wed May 19, 2010 4:06 pm

Using Blockinput>1 will make any keyboard and mouse input do nothing. However even the stop script command wont work.

If a script has blockinput>1 turned on the only way to prematurely stop it is to press control alt delete.

Even running an onevent routine at the start of the script wont work.
"Be aware that this prevents all user input apart from CTRL-ALT-DEL. If you need to stop a running script that has blocked input press CTRL-ALT-DEL and then stop the script."

Taken from the help file for blockinput


Just try to keep the scripts short and make sure every exit path includes blockinput>0 to give control back to the user after everything is said and done.

I'd suggest using the blockinput command as previously suggested but include a small write up so people know to press ctrl alt delete if they need to stop it from running manually

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Thu May 20, 2010 4:13 am

Thanks a lot :-)
Best Regards
Steen Jakobsen
DM Software A/S

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Sun May 23, 2010 10:06 am

Hi ,

I have implementet the BlockInput>1 command
And it works fine.

Is there a way op detect if the user has pressed ctrl-alt-delete
and then to call a SRT to terminate the script and do some cleanup..?

Currently I have an OnEvent key combination that does that but the key combination does of course not
work when BlockInput is active.
Best Regards
Steen Jakobsen
DM Software A/S

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon May 24, 2010 4:10 am

Is there a way op detect if the user has pressed ctrl-alt-delete
and then to call a SRT to terminate the script and do some cleanup..?
Here's a possibility. I've never been able to get an Onevent to detect Ctrl+Alt+Del so what I've done for XP is use Onevent to detect the Task Manager window.

I know that Win 2000 and Vista bring up a Window prior to Task MAnager. I looked up the name of the window and found it to possibly be "Windows Security" but I'm not sure. I also don't know if this is the same name in Win 7. Any way the XP part the following has been used by me in many scripts over the past few years and I know it works reliably

Code: Select all

BlockInput>1
OnEvent>Window_Open,Windows Task Manager,2,WTMpressed
OnEvent>Window_Open,Windows Security,2,WSpressed

SRT>WTMpressed
  SetFocus>Windows Task Manager
  Press esc
  MDL>Continue Without Input Blocked
  Exit>0
END>WTMpressed

SRT>WSpressed
  SetFocus>Windows Security
  Press esc
  MDL>Continue Without Input Blocked
  Exit>0
END>WSpressed

Label>Loop
Wait>0.01
Goto>Loop

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Mon May 24, 2010 10:10 am

Hi JRL ,

Thats a nice idea i'll use it.. Thanks :-)
Best Regards
Steen Jakobsen
DM Software A/S

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Mon May 24, 2010 8:42 pm

Hi JRL,

I can not make it work.
Can I ask you to try your code on your machine .. ? :-)

I'm using XP and nothing happens (I have verified the window title)

Thanks .. Steen
Best Regards
Steen Jakobsen
DM Software A/S

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon May 24, 2010 10:27 pm

Works fine for me. I've tried it on several machines and I've been using the technique for quite a while. Perhaps add an asterisk to the end of each of the window names.

Windows Task Manager*
I'm using XP and nothing happens
Define "nothing". If the script works properly you might see a blip after pressing ctrl+alt+del as Task Manager opens and closes, then a Macro Scheduler modal message should open. If the script doesn't work, after pressing ctrl+alt+del you should see Task Manager.

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Wed May 26, 2010 5:54 am

Hi JRL (and Marcus)

Well I can get it to detect when "Task Manager" is opened..
But not the "Window Security" window wich opens when the user press Ctrl-Alt-Del.. In danish : "Windows Sikkerhed"
Any clue.. ? (using XP SP3)


Marcus: if you are listening in ... :-) .. it wold be great to be able to detect Ctrl-Alt-Del in OnEvent and then jump to a SRT to terminate the script and perform any nessecary cleanup and so on.
As it is now I have to declare a diffreent key combination and inscruct the user to:

1. Press Ctrl-Alt-Del
2. Press ESC
3. Press My third key combination


The users experience would be so much better it the whole thing could be handled in one single OnEvent SRT triggered by Ctrl-Alt-Del.

Any feedback on this is most appreciated.
Best Regards
Steen Jakobsen
DM Software A/S

JeffDaruecan
Newbie
Posts: 18
Joined: Thu Mar 25, 2010 11:00 am
Location: Vancouver

Post by JeffDaruecan » Wed May 26, 2010 9:43 am

I don't think macro scheduler is able to detect the windows security window when it gets opened. When running the script JRL posted and having it not work I decided to try out a getactivewindow script to see if the window title was incorrect.

Code: Select all

wait>5
GetActiveWindow>window_title,X,Y
Message>%window_title%,%X%,%Y%
Run that and you will have 5 seconds to get the window open. Press control alt delete, wait 5 seconds then close it.
The script will have finished and the message will read ",0,0" Which I'm assuming means that there was no active window detected.

Unless I'm doing something wrong. Either way just thought I would post this to try and help others.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed May 26, 2010 9:55 am

Essentially, it's not possible to trap ctrl-alt-del:

http://stackoverflow.com/questions/2090 ... detects-it

Microsoft don't let apps see it.

In Win7 if you hit ctrl-alt-del the desktop goes away and you get a the logon window with options to lock, switch user, log off, change password or start task manager. I'm guessing this is the security console, which is running under a different context, and Macro Scheduler is never going to see it.

It _might_ be possible via a custom keyboard driver or winlogon replacement. But these are advanced things which have their own implications and should be left to the experienced Windows developer - and not things you can do with Macro Scheduler.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Wed May 26, 2010 6:36 pm

Hi Marcus,

Thanks for info :-)
Best Regards
Steen Jakobsen
DM Software A/S

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Disable mouse and keyboard

Post by JRL » Sun Aug 16, 2020 4:37 am

Marcus wrote:Essentially, it's not possible to trap ctrl-alt-del:
Macro Scheduler may not be able to "Trap" Ctrl + Alt + Del, but ten years later (and using Windows 10) I think I figured out how to "Detect" Ctrl + Alt + Del. Turns out that when the login or the logout screens are visible, GetPixelColor detects any chosen point on the desktop as the color "-1". And OnEvent> will detect The Ctrl + Alt key combination. So a solution is to loop in OnEvent> while ctrl + alt is pressed waiting for a pixel to turn to color -1.

Make sure the chosen point is on the desktop because choosing a point off the desktop with GetPixelColor> will always produce a -1 result.

This seems to reliably detect Ctrl + Alt + Del being pressed.

Code: Select all

OnEvent>key_down,VK17,5,srtCtrlAlt

Label>Loop
Wait>0.01
Goto>Loop

SRT>srtCtrlAlt
  GetPixelColor>1,1,vColor
  If>vColor=-1
    MDL>Ctrl+Alt+Del Pressed
    Exit>0
  EndIf
END>srtCtrlAlt

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts