Solved

Virtual Keyboard

Posted on 1998-07-30
13
1,949 Views
Last Modified: 2013-12-04
I need to find out how I can implement a virtual keyboard that returns standard keyboard events whenever a key is pressed. This means that I can use the virtual keyboard to type any documents in Winword or Excel, thereby acting just like a physical keyboard. It would be even better if there is such a product in the market which I can buy off the shelf.
0
Comment
Question by:wmlim060298
  • 6
  • 5
  • 2
13 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1411498
If you vant to progrem it, you should use the keybd_event() function.
Can't tell you about off-the-shelf availablity though.
0
 
LVL 6

Accepted Solution

by:
snoegler earned 50 total points
ID: 1411499
My company wanted me recently to write a tool which redirects rs232 serial input to the
standard keyboard input, i.e. every character received by the rs232 will be converted to a
keypress which all standard win95 applications accept.
If you are interested in this you can download it either on the companys homepage (http://www.dietrich-pos.com) - which is in german - or at my own homepage at
http://absd.hypermart.net (the page is right now under construction, but download things
work already).
0
 

Author Comment

by:wmlim060298
ID: 1411500
I forgot to mention that I need to implement this virtual keyboard in the Win NT 4.0 environment.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 11

Expert Comment

by:alexo
ID: 1411501
keybd_event() works fine under NT4
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1411502
If you like to download it directly: http://absd.hypermart.net/serialkb.exe (case sensitive)
It has been tested under NT and it should work.
( i am doing this with keybd_event , as alexo suggested)
0
 

Author Comment

by:wmlim060298
ID: 1411503
snoegler,
Thanks ! I have downloaded it. However, I do not know how to use it, do you have the readme file?
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1411504
It has a context menu entry 'Configuration' where you can enter your serial communications port
and the transmission parameters.
'Autorun SerialKB Translator' will automatically load the program as a tray bar icon on each
startup. I hope that helps you, i am not sure if this is what you want???
0
 

Author Comment

by:wmlim060298
ID: 1411505
I actually have a touchcreen where I need to draw the keyboard onto the screen where when a user touches the "key A", then I should be able to send a keyboard event to inform the application for example Winword that I have typed "A", just like I typed "A" on the physical keyboard. Does the file which I downloaded "serialkb.exe" serve this purpose?
It will definitely make things easier if there is such a product readily available.
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1411506
Sorry this is a big misunderstanding.
If you want to do what you mentioned, i would suggest you to
a) reject my answer
b) Browse www.shareware.com for a product which does what you want ( as far as i know
    there exist various, so it should not be hard to find)

If you really want to program a tool like the one you need the keybd_event() function, which alexo mentioned also is the way to go. Look in your online help for more information
0
 

Author Comment

by:wmlim060298
ID: 1411507
I actually have a touchcreen where I need to draw the keyboard onto the screen where when a user touches the "key A", then I should be able to send a keyboard event to inform the application for example Winword that I have typed "A", just like I typed "A" on the physical keyboard. Does the file which I downloaded "serialkb.exe" serve this purpose?
It will definitely make things easier if there is such a product readily available.
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1411508
"serialkb" does only convert serial communications data into keystrokes, but that is definitely
not what you want - i misunderstood you.
I think you should consult altavista or shareware.com if you're searching a tool which does this
for you. I do not have enough time to do this - do it yourself :)
If you like to code it yourself, just use this keybd_event() function as alexo mentioned.
It is really simple: keybd_event( 'A', 0, 0, 0); will generate an 'A'.
( for some applications you need to specify the scan code - which is the second parameter
and would be '30' for the character 'A').
I hope this helps a bit
0
 

Author Comment

by:wmlim060298
ID: 1411509
snoegler,
Thanks! I have downloaded a shareware on virtual keyboard. However, I found that I had to specify which type of application I want the text to appear in and then nothing happens after I had selected it.

What is a scan code? When do I have to specify scan code since you mentioned that I only need to specify scan code for some applications. Does keybd_event('A',0,0,0) return an 'A' and any editor be it notepad, Winword, Wordpad, etc can understand it because it is a standard?
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1411510
I noticed errors when using keybd_event on DOS-Boxes. But you can easily find out the scan
code (i forgot to mention that) by using the function MapVirtualKey.
Just take a look into the Online help - but if you don't have an explanation there:

UINT MapVirtualKey(UINT uCode,UINT uMapType)

For your purpose, just pass the virtual key code( which is the same as the ASCII code for
standard characters like 0-9, A-Z and so on) as 'uCode' and set uMapType to zero.
The return value is the scan code.
I am not sure if this is important to windows, but if a key gets released its scan code
is 0x80(128) shifted. I.e. the scan code '30'(A) is the press code, '158' is the release code.

Now you can use the return value - which is the scan code - as the arg for keybd_event.
To send a complete keystroke ( for example an 'A'):

keybd_event('A',MapVirtualKey('A',0),0,0);
keybd_event('A',MapVirtualKey('A',0)+128,KEYEVENTF_KEYUP,0);
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to update Firmware and Bios in Dell Equalogic PS6000 Arrays and Hard Disks firmware update.
Are you looking to recover an email message or a contact you just deleted mistakenly? Or you are searching for a contact that you erased from your MS Outlook ‘Contacts’ folder and now realized that it was important.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question