LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Anybody knows how to do send key function ?

Hello all,
               Anybody know how to do send key function ?
demand is below,
as run the program, program can simulate keyboard type function, input charaters for the other appliction or program window, e.g.
run program, program window would be set to bottom (I can achieve this states), and input key word for the other window, operation is the same as keyboard and mouse input manually.
and which command can disable/restore keyboard and mouse function ?
can labVIEW achieve this ? thanks @!
 
 
 
0 Kudos
Message 1 of 9
(7,994 Views)
This vi uses the user32.dll function "keyboard_event" to send the characters in a string.  I've never used it so I hope it works.
 
- tbob

Inventor of the WORM Global
Message 2 of 9
(7,980 Views)
tbob,
          thank you for your powerful help, it works (I have tried "Tab" function).
BTW ,how can I disable/restore keyboard and mouse function ?
0 Kudos
Message 3 of 9
(7,971 Views)
I don't know if there is a way to disable keyboard and mouse, but you could create an event structure and add event cases for keyboard and mouse functions using the filter events, Key Down? and Mouse Down?.  These are found under <This VI> event selection.  For both cases, wire a True constant to the Discard terminal on the right side of the event structure.  That way, any key pressed or mouse click will be discarded.  You may have to also add the Key Repeat? event.
In order to enable again, instead of wiring the True constant, you would have to create a True/False condition (like a Disable button), and wire the output of this condition into the event structure to be wired to each Discard terminal.  Remember, a True condition will Disable the keyboard and mouse.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 9
(7,956 Views)
tbob,
         I found the SendKey.Vi has some bugs, example, input "abcd" to sendkey for "notepad", I found the characters is 1234,
Sendkey "ABCD" the characters is "abcd", send "n" the key is ".(a point)" . I found "string to byte (type cast) transfer is correct, but user32.dll's response.....
________________________________________________________


Try to make everything Automatic
0 Kudos
Message 5 of 9
(7,929 Views)
Just how are you sending the keys to Notepad?  Sendkeys will cause the keycodes of the keys to be sent, just as if you pressed them on the keyboard.  "abcd" keycodes are hex 61, 62, 63, 64.  Perhaps this is showing up in Notepad as 1,2,3,4.  Whatever function you send the keys to must be able to take the keycodes and translate into characters.
- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 9
(7,893 Views)

I know this is an old post. And I totally understand how to send keys via the user32.dll; however I was wondering if anybody every figured out how to send the keys ( ) / \ -  none of them seem to work.

0 Kudos
Message 7 of 9
(3,327 Views)

But how we can use this method to make an on screen keyboard ?

0 Kudos
Message 8 of 9
(1,990 Views)

Are you referring to launching a keyboard similar to Windows OSK "On screen keyboard"?  For example type OSK in your search bar or command prompt in your Windows operating system and an OSK will open.  To get LabView to launch it simply do as shown in the attachment. Call Library Function Nodes are used becuase of changes with Windows 10.  One prior Windows operating system versions you could have just used the system exec.vi by itself for this.  Once the OSK is displayed it will send the keys clicked for you thus there is no need to use the Send Key function. 

Run osk.png

 

 

0 Kudos
Message 9 of 9
(1,970 Views)