From: Richard Owlett on
My OS is WinXP.

I've had many occasions to use Microsoft Word's VBA to control other
Windows programs. It can be a kludge, but it got the job done.

Is there a Tcl equivalent to

Pgmhandle = Shell("G:\gnuplot\bin\wgnuplot.exe", 1)
AppActivate Pgmhandle
SendKeys " plot 'C:dataset1.dat' using 1:3" + Chr$(13) + Chr$(10), 1
' do something
SendKeys " plot 'C:dataset2.dat' using 2:3" + Chr$(13) + Chr$(10), 1
From: Robert Heller on
At Wed, 10 Dec 2008 13:51:32 -0600 Richard Owlett <rowlett(a)atlascomm.net> wrote:

>
> My OS is WinXP.
>
> I've had many occasions to use Microsoft Word's VBA to control other
> Windows programs. It can be a kludge, but it got the job done.
>
> Is there a Tcl equivalent to
>
> Pgmhandle = Shell("G:\gnuplot\bin\wgnuplot.exe", 1)
> AppActivate Pgmhandle
> SendKeys " plot 'C:dataset1.dat' using 1:3" + Chr$(13) + Chr$(10), 1
> ' do something
> SendKeys " plot 'C:dataset2.dat' using 2:3" + Chr$(13) + Chr$(10), 1
>

In the case of gnuplot, you really just want to write to its stdin, so
you can do:

# Fork process, with is stdin connected to a pipe (ala popen).
# The open file handle is connected to the pipe.
set plotfp [open "|G:/gnuplot/bin/wgnuplot.exe" w]
# Write commands to the pipe...
puts $plotfp " plot 'C:dataset1.dat' using 1:3"
puts $plotfp " plot 'C:dataset2.dat' using 2:3"
# Close the pipe.
close $plotfp;# sends an EOF

(Ideally, you want to put a catch around the open and maybe use
fileevent as well.)


--
Robert Heller -- Get the Deepwoods Software FireFox Toolbar!
Deepwoods Software -- Linux Installation and Administration
http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
heller(a)deepsoft.com -- Contract Programming: C/C++, Tcl/Tk

From: Bryan Oakley on
On Dec 10, 1:51 pm, Richard Owlett <rowl...(a)atlascomm.net> wrote:
> My OS is WinXP.
>
> I've had many occasions to use Microsoft Word's VBA to control other
> Windows programs. It can be a kludge, but it got the job done.
>
> Is there a Tcl equivalent to
>
> Pgmhandle = Shell("G:\gnuplot\bin\wgnuplot.exe", 1)
> AppActivate Pgmhandle
> SendKeys " plot 'C:dataset1.dat' using 1:3" + Chr$(13) + Chr$(10), 1
> ' do something
> SendKeys " plot 'C:dataset2.dat' using 2:3" + Chr$(13) + Chr$(10), 1

Tcl does not have a send_keys equivalent. However, the twapi package
has one, along with interfaces to a large portion of the rest of the
windows api.

http://wiki.tcl.tk/9886

From: Richard Owlett on
Robert Heller wrote:
> At Wed, 10 Dec 2008 13:51:32 -0600 Richard Owlett <rowlett(a)atlascomm.net> wrote:
>
>
>>My OS is WinXP.
>>
>>I've had many occasions to use Microsoft Word's VBA to control other
>>Windows programs. It can be a kludge, but it got the job done.
>>
>>Is there a Tcl equivalent to
>>
>>Pgmhandle = Shell("G:\gnuplot\bin\wgnuplot.exe", 1)
>>AppActivate Pgmhandle
>>SendKeys " plot 'C:dataset1.dat' using 1:3" + Chr$(13) + Chr$(10), 1
>> ' do something
>>SendKeys " plot 'C:dataset2.dat' using 2:3" + Chr$(13) + Chr$(10), 1
>>
>
>
> In the case of gnuplot, you really just want to write to its stdin, so
> you can do:
>
> # Fork process, with is stdin connected to a pipe (ala popen).
> # The open file handle is connected to the pipe.
> set plotfp [open "|G:/gnuplot/bin/wgnuplot.exe" w]
> # Write commands to the pipe...
> puts $plotfp " plot 'C:dataset1.dat' using 1:3"
> puts $plotfp " plot 'C:dataset2.dat' using 2:3"
> # Close the pipe.
> close $plotfp;# sends an EOF
>
> (Ideally, you want to put a catch around the open and maybe use
> fileevent as well.)
>
>

I had understood that Windows(tm) did not implement pipes in
conventional sense. Used to use them in good old 8-bit CPM days.

Will try your code.

From: Richard Owlett on
Bryan Oakley wrote:

> On Dec 10, 1:51 pm, Richard Owlett <rowl...(a)atlascomm.net> wrote:
>
>>My OS is WinXP.
>>
>>I've had many occasions to use Microsoft Word's VBA to control other
>>Windows programs. It can be a kludge, but it got the job done.
>>
>>Is there a Tcl equivalent to
>>
>>Pgmhandle = Shell("G:\gnuplot\bin\wgnuplot.exe", 1)
>>AppActivate Pgmhandle
>>SendKeys " plot 'C:dataset1.dat' using 1:3" + Chr$(13) + Chr$(10), 1
>> ' do something
>>SendKeys " plot 'C:dataset2.dat' using 2:3" + Chr$(13) + Chr$(10), 1
>
>
> Tcl does not have a send_keys equivalent. However, the twapi package
> has one, along with interfaces to a large portion of the rest of the
> windows api.
>
> http://wiki.tcl.tk/9886
>

I looked at that at one time. Don't remember what problem I had. Maybe I
just needed more experience. I'll take another look.