Using Blockinput with WScript or .NET

1 回表示 (過去 30 日間)
A J BAnks
A J BAnks 2015 年 8 月 27 日
コメント済み: Guillaume 2015 年 8 月 27 日
Hey guys,
as I am accessing a programm which does not support ActiveX I need to do it with Windows Script. I want to block user input during the time the script is running.
In the microsoft documents there is a function called Blockinput. (See here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646290%28v=vs.85%29.aspx)
How can I access this function properly with Matlab?
Thanks for your help, I try this for almost a year and I need help now!

回答 (2 件)

Guillaume
Guillaume 2015 年 8 月 27 日
BlockInput is a win32 api function. You can neither access it with ActiveX nor windows script. You would either have to wrap the call in a mex file, or figure out how to generate a proto file to use loadlibrary to load user32.dll (where BlockInput resides).
However, if I came across a program that blocked all user inputs, I'd uninstall it in a heartbeat. This is not good user interface design. Preventing the user from doing what they want is never a good idea. There is no reason why you'd need to block all user input from matlab.
In any case, it sounds like blocking user input is just a workaround for another problem you're having. If that is the case, then ask for help solving that other problem rather than help implementing an ugly workaround.

A J BAnks
A J BAnks 2015 年 8 月 27 日
Thank you very much for your response. Yes, you're right blocking user input is not a good thing. The point of my question is that there is no other way to use this specific software but with windows script. To make this happen properly one has to block user input for like 2-3 seconds. Of course the function blockinput Provides an abort. Anyways, I appreciate input to make it happen.
By the way load library won't work here for reasons I can't properly understand.
Cheers, Matt
  1 件のコメント
Guillaume
Guillaume 2015 年 8 月 27 日
Please use the comment on this answer box instead of the answer this question box.
So is your question about calling a windows script? or about blocking user input? And what is that strange windows script that fails if the user presses a key or move the mouse?
"load library won't work here for reasons I can't properly understand". Well, unless you tell us more, we certainly won't understand the reason either.
If I really wanted to block user input for a few seconds, I'd simply write a simple command line program in C or C#, compile into an executable, and invoke said executable from matlab. The program would just consist of a call to BlockInput and a timer that terminates the program after x seconds.

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by