Search

Everything stated on this site is, of course, MY opinion / statement / thought, unless specifically stated otherwise. You knew that.

Blog Index
The journal that this archive was targeting has been deleted. Please update your configuration.
Navigation
« Certifications | Main | Dixie Chicks - music »
Wednesday
Mar192003

WinAPI to mimic keystrokes

There are times when there seems to be no easy way to accomplish something programmatically - the only way to do the task at hand is via the keyboard. I recently shared this tip with someone at work, so figured I'd post it here: using the WinAPI to send keystrokes to the PC.

In this example, the API will be used to send keystrokes to deselect selected documents in a view and then refresh the view. This would be the same as manually hitting <Alt-E-D> to deselect and then hitting <F9> to refresh (there are, of course, many things you could do by sending keystrokes). The critical piece here is to know the hex code for whatever keystrokes need to be sent to the PC. There are a number of places on the web to find this. Here's a site of ASCII codes, and here's a site that includes the codes for some of the function keys. You want the hex value for the key, not the decimal value.

OK, so here's a LotusScript example. The 'magic' part of the code (the declaration of the API call) I believe I pulled from NotesNet quite a while back. And the html rendition of the code was, of course, rendered using Julian's ls2html routine.

Of course, it's your responsibility to ALWAYS carefully test anything before using it production!

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.