[RESOLVED] How to disable mouse and keyboard for 10 seconds
Hi,
I'm working on a splash screen which lasts about 10 seconds. I want to disable mouse and keyboard functions during this time (splash screen) and define a hotkey of Alt+Ctrl+2 to force the splash screen to stop (this hotkey is just used for killing the process).
What code in the windows form section can handle this task?
Last edited by fa2020; Jul 30th, 2020 at 10:31 PM.
Re: How to disable mouse and keyboard for 10 seconds
Originally Posted by fa2020
Hi,
I'm working on a splash screen which lasts about 10 seconds. I want to disable mouse and keyboard functions during this time (splash screen) and define a hotkey of Alt+Ctrl+2 to force the splash screen to stop (this hotkey is just used for killing the process).
What code in the windows form section can handle this task?
Declare Function BlockInput Lib "User32" (ByVal fBlockIt As Boolean) As Boolean
use in code : BlockInput(True)
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
Re: How to disable mouse and keyboard for 10 seconds
Originally Posted by fa2020
Unfortunately, I couldn't find any code for disabling mouse and keyboard globally.
Can anyone please guide me?
That is probably because disabling the mouse and keyboard globally is a bad idea anyway, I would certainly be wary of running any application that disable mouse and keyboard to my entire system.
Re: How to disable mouse and keyboard for 10 seconds
Why would you want to do this? Clearly, there's a problem, since you have a hotkey combination that won't work if the keyboard is disabled. Also, you guarantee that everybody will hate your program. I have two monitors on one computer and three on another. Do I really want a program that will stop me from doing anything on any monitor while it loads? No, I really do not.
So, aside from pissing off any users, what are you trying to prevent with this?
Re: How to disable mouse and keyboard for 10 seconds
I provided a test of my program. I used Visual Studio wallpaper as form background just for test. I wrote the code you provided for disabling mouse and keyboard globally, but nothing happens. Please look at VS 2019 file which I uploaded above.
Re: How to disable mouse and keyboard for 10 seconds
But, I can still hover my mouse over the splash screen when I run it. Please have a look on my example file.
My goal is to disable Task Manager from killing the app. I want to disable Ctrl+Alt+Del function and not allow task manager to kill my app.
Last edited by fa2020; Jul 31st, 2020 at 12:11 AM.
Re: How to disable mouse and keyboard for 10 seconds
Originally Posted by .paul.
I don't remember the key combination, but there is a hotkey that ends BlockInput
Yes Ctrl+Alt+Del unblocks
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
Re: How to disable mouse and keyboard for 10 seconds
Originally Posted by .paul.
Mousemove isn't user input. Your goal is not something we can or would help with. It could be used maliciously...
It reminds me that's a few weeks ago we had exactly that at work. On of my colleague had a trouble with a subcontractor web page that pops up a false web page windows alert (you know the one with a nice phone number ) and blocked the keyboard and the mouse click . We manage to unblock the situation by unpluging the keyboard and repluging it... (by the way we had to warn the subcontractor that its web page has been infected)
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
Re: How to disable mouse and keyboard for 10 seconds
Originally Posted by fa2020
But, I just want to learn something. I'm in the first steps of VB.NET programming. I don't want to bother anyone.
Interesting, my first steps into VB.net had been programming games...
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
An obscure body in the SK system. The inhabitants call it Earth
Posts
7,902
Re: [RESOLVED] How to disable mouse and keyboard for 10 seconds
Agree with the above. What you're asking to do is basically a violation of best practice for apps and would be wide open to abuse. Microsoft have gone out of there way to make sure you can't do what you're suggesting doing.
Why do you want to prevent your app from being closed while the splash screen is opening? There may be a better way of achieving your goal.
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd