Jump to content

Call which API to disable and restore keyboard or a mouse function


Recommended Posts

As my subject, how to disable/restore keyboard or a mouse function ? and I know using User32.dll a "blockinput" function can block all of inputs, but this is not my goal, since I use send key function, namely, program auto inputs characters to the other application (not labVIEW application, so discard event function can't achieve this goal, have to use API ) instead of manual, and I want to disable keyboard and mouse function to avoid people inputting before program is doing auto sendkey process. and "blockinput" function would block every inputs too, program sends key fail, anybody can help would be great appreciation ! :worship:

Link to comment
As my subject, how to disable/restore keyboard or a mouse function ? and I know using User32.dll a "blockinput" function can block all of inputs, but this is not my goal, since I use send key function, namely, program auto inputs characters to the other application (not labVIEW application, so discard event function can't achieve this goal, have to use API ) instead of manual, and I want to disable keyboard and mouse function to avoid people inputting before program is doing auto sendkey process. and "blockinput" function would block every inputs too, program sends key fail, anybody can help would be great appreciation ! :worship:

I am unsure of what you are asking. If I am correct, the LabVIEW app is sending information to the other application via the API send key functionality. The LabVIEW app is frontmost, thus capturing key/mouse input. At some point the LabVIEW app will be sending information over to the other app, and you want to avoid anything happening while this occurs. But since your method of communication is through sending keyboard data, you are stuck.

You can ignore keyboard and mouse events in your labview program by either discarding them with Filter? events are by treating them differently based on some flag set in your program.

You can also have your code for the sendkey called within an event structure, which by default locks the Front Panel from keyboard and mouse until the event is done being serviced. This may be what you are asking.

If you want to prevent the user from changing focus from your LabVIEW app to another app or Windows toolbar, etc. then I have nothing to offer.

David

Link to comment
I am unsure of what you are asking. If I am correct, the LabVIEW app is sending information to the other application via the API send key functionality. The LabVIEW app is frontmost,(no , labVIEW app can do this step with minimized window) thus capturing key/mouse input. At some point the LabVIEW app will be sending information over to the other app, and you want to avoid anything happening while this occurs. But since your method of communication is through sending keyboard data, you are stuck.

You can ignore keyboard and mouse events in your labview program by either discarding them with Filter? events are by treating them differently based on some flag set in your program.

You can also have your code for the sendkey called within an event structure, which by default locks the Front Panel from keyboard and mouse until the event is done being serviced. This may be what you are asking. (no, I can't lock the front panel, because, if you do this, how can you send the key to the other appliction ?)

If you want to prevent the user from changing focus from your LabVIEW app to another app or Windows toolbar, etc. then I have nothing to offer.

David

Thanks ! OK, for details, let me tell a sample

I want to program a function, it can help me to input user name and password, and this input field is from a web, cause this web that I am using frequently, and I don't want to input it manual, my goal is that open a labVIEW app(it can store my user name and password), and click a button, then program helps to input "user name and password, within program inputting time, for prevent people to move mouse or click keyboard, so I want to disable them " , am I clear ?

Link to comment
Thanks ! OK, for details, let me tell a sample

I want to program a function, it can help me to input user name and password, and this input field is from a web, cause this web that I am using frequently, and I don't want to input it manual, my goal is that open a labVIEW app(it can store my user name and password), and click a button, then program helps to input "user name and password, within program inputting time, for prevent people to move mouse or click keyboard, so I want to disable them " , am I clear ?

It seems that the time to write a user name and password would be very short. You may not have much of an issue there.

In summary, you CAN lock the LabVIEW panel because the code sending the name&password would be running in the event structure. You said these would be stored, so there would be no interaction on the panel. Look into event structures if you aren't familiar with them.

You cannot lock the user from clicking on things on the web browser (as far as I know) based on your limitations.

Link to comment
It seems that the time to write a user name and password would be very short. You may not have much of an issue there. ( :)man, that is for example, not details, I am facing much field wanting to do sendkey action actually)

In summary, you CAN lock the LabVIEW panel because the code sending the name&password would be running in the event structure. (OK, if some people click the mouse, or open the other application during the program doning sendkey process ? what would happen ? the key focus will be gone. or the active window would be changed.)

You said these would be stored, (my store-- means that I can store the password and user name or any other informations to *.ini or *.xml file, and as I open the "sendkey application" it can load the config, then takes the sendkey action )

so there would be no interaction on the panel. (yes, you are right) Look into event structures if you aren't familiar with them. (en....would you kindly help to make a simpel sample for me ? with this status ?!)

You cannot lock the user from clicking on things on the web browser (as far as I know) based on your limitations.

actually, I viewed a application can do my issues ago, I remember that software is downloaded from some website, as I doubled click it to install, that application prompts a dialog box to ask people input CD key, and I found at that time, keyboard and mouse were disabled, and can see the CD key was inputted automatically by its software, after finished input CD key, the mouse and keyboard's function were restored ,I don't know how it did.

Link to comment
actually, I viewed a application can do my issues ago, I remember that software is downloaded from some website, as I doubled click it to install, that application prompts a dialog box to ask people input CD key, and I found at that time, keyboard and mouse were disabled, and can see the CD key was inputted automatically by its software, after finished input CD key, the mouse and keyboard's function were restored ,I don't know how it did.

Capturing events from other applications is something only doable with Windows API programming and with some involved ones too, using callbacks and such. Search MSDN for filter hooks such as the SetWindowsHookEx function does. Basically you have to install a global filter hook for the events you want to block, implement the callback function that receives the redirected events and discards them depending on the passed parameters etc. Doing this for LabVIEW will absolutely positively mean that you have to write an intermediate DLL.

Rolf Kalbermatter

Link to comment
Capturing events from other applications is something only doable with Windows API programming and with some involved ones too, using callbacks and such. Search MSDN for filter hooks such as the SetWindowsHookEx function does. Basically you have to install a global filter hook for the events you want to block, implement the callback function that receives the redirected events and discards them depending on the passed parameters etc. Doing this for LabVIEW will absolutely positively mean that you have to write an intermediate DLL.

Rolf Kalbermatter

Thanks Rolf, yup, I have searched MSDN, but I haven't got any info about my goal :headbang:

you wrote "have to install a global filter hook for the events you want to block" is this handle only ? haven't any simple way to reach it ?

just call an or two APIs ?

Link to comment
  • 2 weeks later...
Thanks Rolf, yup, I have searched MSDN, but I haven't got any info about my goal :headbang:

you wrote "have to install a global filter hook for the events you want to block" is this handle only ? haven't any simple way to reach it ?

just call an or two APIs ?

The SetWindowsHookEx function takes as one of the paramaters a callback function. This is a function pointer and can only really be confortable done in C so you will have to write a DLL in C that does the hooking. The callback function will inspect the message passed to it and either modify some parameters, deny handling of the message altogether or allow handling of the message unaltered. The return value of your callback function determines if the message should be further handled or not.

It's a low level work area and if your callback function does the wrong thing you can get your Windows system in a rather hard to control state. (Ctrl-Alt-Del) may be your only friend then or the reset button.

Rolf Kalbermatter

Link to comment
The SetWindowsHookEx function takes as one of the paramaters a callback function. This is a function pointer and can only really be confortable done in C so you will have to write a DLL in C that does the hooking. The callback function will inspect the message passed to it and either modify some parameters, deny handling of the message altogether or allow handling of the message unaltered. The return value of your callback function determines if the message should be further handled or not.

It's a low level work area and if your callback function does the wrong thing you can get your Windows system in a rather hard to control state. (Ctrl-Alt-Del) may be your only friend then or the reset button.

Rolf Kalbermatter

Thanks Rolf Kalbermatter, but I am not familiar with C language of this controlling . So, anybody can help to make a DLL or a sample will be great appreciation.

Link to comment
Thanks Rolf Kalbermatter, but I am not familiar with C language of this controlling . So, anybody can help to make a DLL or a sample will be great appreciation.

Maybe that would be a chance to learn C? It's still THE engineering programming language and won't go away anywhere soon. Having some knowledge about C programming will always be an added bonus in almost any engineering profession where you even remotely need to get your hands on a computer.

I'm not volunteering to write this thing for you, sorry. It's going to be a time consuming exercise in any case and to get it work exactly as you envision it will probably get a hard exercise for someone else than yourself.

Rolf Kalbermatter

Link to comment
Maybe that would be a chance to learn C? It's still THE engineering programming language and won't go away anywhere soon. Having some knowledge about C programming will always be an added bonus in almost any engineering profession where you even remotely need to get your hands on a computer.

I'm not volunteering to write this thing for you, sorry. It's going to be a time consuming exercise in any case and to get it work exactly as you envision it will probably get a hard exercise for someone else than yourself.

Rolf Kalbermatter

rolfk, OK, I know, anyway, thanks for your issues. yup, they are reasonable.

Link to comment
  • 4 months later...
So how did you end up doing it? Please share your findings with us :thumbup: It's only through the sharing of our triumphs and failures that we learn for each other...

Hi,

I use "Block input" to disable keyboard and mouse function, and "Sendkey" to do the send key, I remember that I issued a topic here which is sendkey function no response, that is what my goal is.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.