How to invoke SendInput() Windows API. was Re: How do I paste into a different app?

runrev260805 at m-r-d.de runrev260805 at m-r-d.de
Thu Jan 7 06:02:47 EST 2010


Hi Bill,

i have done something similar.  You can create a vbs script and let Rev run this.

I am not very good at VBS, but the following lines show how to insert text into an app.

___________________
Set WshShell = WScript.CreateObject("WScript.Shell") 
WshShell.Run "winword.exe"
'the app is opened. If your app is already running, you do not need this line
WScript.Sleep 2000          
 'script stops for 2000 milliseconds to take sure, that the app is running before further proceeding.

WshShell.AppActivate "Dokument1 - Microsoft Word"    
'activates your already running app
'between the quotes you have to put the exact name of the app - as it is shown in the title bar of that app
' winword also shows the document name in the title bar

WScript.Sleep 100          
 'script stops for 100 milliseconds'

WshShell.SendKeys "This Text should be inserted"   
 'the text between the quotes is sent to the app

WScript.Sleep 100          
WshShell.SendKeys "{enter}"
'sends an enter to winword
WScript.Sleep 100          

WshShell.SendKeys "This Text should also be inserted"   
 'the text between the quotes is sent to the app

____________________

Maybe Ken Ray could jump in, as he knows much more about VB and VBS.

Regards,

Matthias





-------- Original Message --------
Subject: How to invoke SendInput() Windows API. was Re: How do I paste into a different app? (07-Jan-2010 6:42)
From:    Bill Vlahos <bvlahos at mac.com>
To:      runrev260805 at m-r-d.de

> 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.
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> 
> 
> 
> To: use-revolution at lists.runrev.com





More information about the use-livecode mailing list