Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 12 FEB 2008 10:12:33AM Dale Jessop wrote:

Hi,

has anyone any idea how to use this function to send simulated keystrokes ?

Any help would be appreciated.


At 12 FEB 2008 12:13PM [url=http://www.srpcs.com]SRP[/url]'s Kevin Fournier wrote:

Dale,

According to Microsoft, SendInput is the "preferred" way to simulate keystrokes or mouse input. However, as you've alluded to already, it's a pain to use – especially in OI. If keyboard input is your goal, then I recommend using the simpler keybd_event API.

Instructions on using the API can be found here. That thread will show you how to setup the KeyboardEvent method. The example also shows you how to simulate a very specific action, but the implementation is the same for any keystroke. All you need now is the proper virtual key codes, which are listed here.

As an example, let's simulate the user pressing the Enter key. First, define the equate for the enter key and the keyup flag:

Equ [/color]VK_RETURN$      [/color]to [/color]0x0D 
[/color]Equ [/color]KEYEVENT_KEYUP$ [/color]to [/color]2[/color][/color][/size]         
               

Next, simulate the user pressing and releasing the Enter key:

KeyboardEvent(VK_RETURN$, 0[/color], [/color]0[/color], [/color]0[/color]) 
KeyboardEvent(VK_RETURN$, [/color]0[/color], KEYEVENT_KEYUP$, [/color]0[/color])[/color][/color][/size]         
               

It's important that you simulate both the press and release. Forgetting to release the keystroke simulates the user holding the key down, which you may not want. Note that there are also virtual key codes for the mouse buttons, so you can also simulate those via this API as well.

I hope this gets you started in the right direction. Happy keystroking.

kfournier@srpcs.com

SRP Computer Solutions, Inc.


At 13 FEB 2008 04:12AM Dale Jessop wrote:

Hi Kevin,

Thanks for the info, it worked a treat!


This Link is also broken…

Instructions on using the API can be found here. That thread will show you how to setup the KeyboardEvent method.

http://www.revelation.com/__85256DB80017688B.nsf/0/02995316E039917885257217006BF452?OpenDocument

I followed the instructions by Richard, and I believe I have it working now. Thank Don and Richard!

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/b32192841398d816852573ed00538bf6.txt
  • Last modified: 2024/01/04 20:57
  • by 127.0.0.1