Solved

Virtual Keyboard

Posted on 1998-07-30
13
1,941 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
 
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
Save on storage to protect fatherhood memories

You're the dad who has everything. This Father's Day, make sure your family memories are protected. My Passport Ultra has automatic backup and password protection to keep your cherished photos and videos safe. With up to 3TB, you have plenty of room to hold the adventures ahead.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

VM backups can be lost due to a number of reasons: accidental backup deletion, backup file corruption, disk failure, lost or stolen hardware, malicious attack, or due to some other undesired and unpredicted event. Thus, having more than one copy of …
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now