Re: [Rd] Using Windows API functions in R

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 26 Jan 2007 - 09:59:05 GMT

On Fri, 26 Jan 2007, ????? ??????? wrote:

> Somehow autofilter doesn't allow this message to be posted,
> will try another time.
>
> -----Original Message-----
> From: Yuri Volchik <volchik2000@list.ru>
> To: r-devel@r-project.org
> Date: Thu, 25 Jan 2007 22:27:13 +0000
> Subject: Using Windows API functions in R
>
>>
>> Hi to all.
>>
>> In programming one application i have to "press" button to have
>> application started, which i would like to do automatically from R.
>> To do that i want to use library "user32" function "SendInput"
>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/sendinput.asp
>>
>> So far i managed to write the following
>>
>> system(shQuote("C:/Program Files/1.exe"),wait=F)
>> system32 <- file.path(Sys.getenv("windir"),"system32")
>> user32 <- file.path(system32,"user32.dll")
>> dyn.load(user32)
>> .C("SendInput",..)

You cannot make use of WINAPI calls from .C (or otherwise in R): it is set up for _cdecl calls only.

You will need to write some wrapper C code.

>> And now i'm at loss how to represent the data structure needed for
>> correct call to that function, may be somebody could help me with
>> this?

You cannot create C structures using .C, only a few basic array types. See ?".C" . Since you need wrapper code, you can create the structures needed there.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri Jan 26 21:12:55 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 26 Jan 2007 - 13:31:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.