How to invoke SendInput() Windows API. was Re: How do I paste into a different app?
Bill Vlahos
bvlahos at mac.com
Wed Jan 6 23:47:14 EST 2010
It looks like Microsoft has deprecated the keybd_event API and suggests using SendInput() instead.
Below is a sample of what needs to be sent. This is a C++ example. How do I send this from Rev in Windows? It looks similar to what I do with AppleScript on the Mac? While the send...as applescript commands are documented in Rev's dictionary I don't see anything similar for Windows APIs.
INPUT inp[2];
memset(inp,0,sizeof(INPUT));
inp[0].type = INPUT_KEYBOARD;
inp[0].ki.dwFlags = KEYEVENTF_UNICODE; // to avoid shift, and so on
inp[1] = inp[0];
inp[1].ki.dwFlags |= KEYEVENTF_KEYUP;
for (LPCTSTR p=str; *p; p++) {
inp[0].ki.wScan = inp[1].ki.wScan = *p;
SendInput(2, inp, sizeof(INPUT));
}
Here are some relevant links:
http://msdn.microsoft.com/en-us/magazine/cc163867.aspx
http://www.codeguru.com/forum/showthread.php?t=377393
http://msdn.microsoft.com/en-us/library/ms646310(VS.85).aspx
On Dec 31, 2009, at 7:27 AM, Bill Vlahos wrote:
> I figured it out and have it working on the Mac with AppleScript. I'm not using a paste function but the AppleScript "keystroke" function. It looks like the Windows API "keybd_event" can do the same type of thing.
Bill Vlahos
_________________
InfoWallet (http://www.infowallet.com) helps me remember the important details of my life.
More information about the use-livecode
mailing list