Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Virtual Keyboard

Posted on 1998-07-30
13
Medium Priority
?
1,971 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 100 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

730 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