Solved

Virtual Keyboard

Posted on 1998-07-30
13
1,967 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

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 …
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

623 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