From: das_chris on
Hello all!

Some Background:
I am studying mechanical engineering. For a project task, I have to
set up a cycle of 4 programmes interacting into each others (Pro
Engineer (CAD), Star Design (transforming shapes into meshes), Star CD
(Fluid dynamics calculations), ModeFrontier (optimisation programme) -
for those who are interested).
Between the programmes, information has to be passed on in form of
files.
As this cycle is a iterative process, it is being repeated several
hundred times. Therefore, I thought of writing a [b]Batch-File[/b],
which starts the different programmes and executes the action that has
to be done in each of the programmes.

Now my question:
Is it possible, to control a programme, using a batch file? e.g.
opening word, loading an explicit file, running a macro and saving the
file, using the *.txt format?

If not - which is what I actually assume - can this be archieved by
using another more powerful programming language?

To go even further, can i adress options in the menu bar? which leads
to "is a windows-based program fully controlable by another, self-
written program?


I hope, everybody understood what i meant and perhaps somebody can
even give me some hints or even answers.

Thank you very much for your time,
best regards
Christian

Student of mechanical engineering, Germany
From: Alf P. Steinbach on
* das_chris:
> Hello all!
>
> Some Background:
> I am studying mechanical engineering. For a project task, I have to
> set up a cycle of 4 programmes interacting into each others (Pro
> Engineer (CAD), Star Design (transforming shapes into meshes), Star CD
> (Fluid dynamics calculations), ModeFrontier (optimisation programme) -
> for those who are interested).
> Between the programmes, information has to be passed on in form of
> files.
> As this cycle is a iterative process, it is being repeated several
> hundred times. Therefore, I thought of writing a [b]Batch-File[/b],
> which starts the different programmes and executes the action that has
> to be done in each of the programmes.
>
> Now my question:
> Is it possible, to control a programme, using a batch file?

Depends on the program. If the program provides ways to specify what should be
done via command line arguments, then yes. Otherwise (in general) no.


> e.g.
> opening word, loading an explicit file, running a macro and saving the
> file, using the *.txt format?

No.


> If not - which is what I actually assume - can this be archieved by
> using another more powerful programming language?

Depends on the program. If the program supports automation, then yes. For Word
and above scenario, yes. E.g. JScript and VBScript, both bundled with Windows,
can do this.


> To go even further, can i adress options in the menu bar? which leads
> to "is a windows-based program fully controlable by another, self-
> written program?

Depends on the program. :-)


> I hope, everybody understood what i meant and perhaps somebody can
> even give me some hints or even answers.

In the worst case you can always go down to the level of sending keystrokes to
the program (look up documentation of WScript and associated objects, there's a
SendKey method somewhere). But that's a bit risky. E.g., the user should
better keep hands off keyboard while this going on.


Cheers, & hth.,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
From: CBFalconer on
das_chris wrote:
>
.... snip ...
>
> Now my question:
> Is it possible, to control a programme, using a batch file? e.g.
> opening word, loading an explicit file, running a macro and saving
> the file, using the *.txt format?

Of course. It depends on the power of the batch language. Here is
one for MSDOS (dated Dec 2002), using 4dos as the command
processor, that writes an HTML file with selected directory data:

@echo off
:: mkindex2.htm by Mike Bessy, revised by C.B. Falconer
:: see "news://jpsoft.media3.net/138154%40jpsoft.support"
*setlocal
*unalias *
::on error goto done
on break goto done
goto start

:: convert system datestamp in %ft to ISO in %ymd
:isodate
set ymd=%@year[%ft]
iff %ymd LT 80 then
set ymd=%@eval[%ymd+2000]
elseiff &ymd LT 100 then
set ymd=%@eval[%ymd+1900]
else
set ymd=%@right[4, 0%ymd]
endiff
set ymd=%ymd-%@right[2, 0%@month[%ft]]-%@right[2, 0%@day[%ft]]
return

:start
set based=~cbfalconer/
set f="index.htm"
set suppress=/[!*.ion index*.htm *.ba*]
iff not ".%1." == ".." then
set based=%@strip[%=", %1]
set suppress=/[!index.htm %2&]
endiff
set d="%@full[.]"
echo %=nUsage: %0 [Title prefix] [files to suppress]
echo %=n%@upper[%0]: Hit Ctrl-C to abort or press any key to
pause %@if[exist %f,re,]build %f from %d.
cdd %d
>!%f
text >> %f
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<meta name="GENERATOR" content="mkindex2.btm [4dos]">
<TITLE>
endtext

echo %based%%@filename[%d] directory >> %f

text >> %f
</TITLE></HEAD><BODY><CENTER><H1>
endtext

echo %based%%@filename[%d] >> %f

text >> %f
</H1><P><A HREF="../index.htm">Back to parent directory</A>
<P>
<TABLE ALIGN=CENTER BORDERCOLOR="#0000FF" BORDER="5" WIDTH="98%">
<TR>
<TD BGCOLOR="WHITE"><CENTER><B>Name</B></CENTER></TD>
<TD BGCOLOR="WHITE"><CENTER><B>Date</B></CENTER></TD>
<TD BGCOLOR="WHITE"><CENTER><B>Size</B></CENTER></TD>
<TD BGCOLOR="WHITE"><CENTER><B>Description</B></CENTER></TD>
</TR>
endtext

set n=0
dir %suppress /h /b | for %ii in (@con) (
echo %=<TR%=> >> %f
echo %=<TD%=>%=<A HREF="%ii"%=>%ii%=</A%=>%=</TD%=> >> %f
set ft=%@filedate["%ii"]
gosub isodate
echo %=<TD ALIGN=CENTER%=>%ymd%=</TD%=> >> %f
echo %=<TD
ALIGN=RIGHT%=>%@format[5,%@filesize["%ii",K]]K%=</TD%=> >> %f
echo %=<TD%=>%@descript["%ii"]&nbsp;%=</TD%=> >>%f
echo %=</TR%=> >> %f
set n=%@inc[%n]
)
echo %=</TABLE%=> >>%f
set ft=%_date
gosub isodate
echo %=<P%=>[%n files indexed on %ymd at %_time >> %f

text >> %f
by <BIG><A HREF="http://jpsoft.com/"> 4DOS!</A></BIG> ]
<P>
<A HREF="../index.htm">Back to parent directory</A>
</CENTER></BODY></HTML>
endtext

echo %n files indexed on %ymd at %_time

:done

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.

** Posted from http://www.teranews.com **
From: das_chris on
On 21 Apr., 12:44, "Alf P. Steinbach" <al...(a)start.no> wrote:
> *das_chris:
>
>
>
> > Hello all!
>
> > Some Background:
> > I am studying mechanical engineering. For a project task, I have to
> > set up a cycle of 4 programmes interacting into each others (Pro
> > Engineer (CAD), Star Design (transforming shapes into meshes), Star CD
> > (Fluid dynamics calculations), ModeFrontier (optimisation programme) -
> > for those who are interested).
> > Between the programmes, information has to be passed on in form of
> > files.
> > As this cycle is a iterative process, it is being repeated several
> > hundred times. Therefore, I thought of writing a [b]Batch-File[/b],
> > which starts the different programmes and executes the action that has
> > to be done in each of the programmes.
>
> > Now my question:
> > Is it possible, to control a programme, using a batch file?
>
> Depends on the program. If the program provides ways to specify what should be
> done via command line arguments, then yes. Otherwise (in general) no.
>
> > e.g.
> > opening word, loading an explicit file, running a macro and saving the
> > file, using the *.txt format?
>
> No.
>
> > If not - which is what I actually assume - can this be archieved by
> > using another more powerful programming language?
>
> Depends on the program. If the program supports automation, then yes. For Word
> and above scenario, yes. E.g. JScript and VBScript, both bundled with Windows,
> can do this.
>
> > To go even further, can i adress options in the menu bar? which leads
> > to "is a windows-based program fully controlable by another, self-
> > written program?
>
> Depends on the program. :-)
>
> > I hope, everybody understood what i meant and perhaps somebody can
> > even give me some hints or even answers.
>
> In the worst case you can always go down to the level of sending keystrokes to
> the program (look up documentation of WScript and associated objects, there's a
> SendKey method somewhere). But that's a bit risky. E.g., the user should
> better keep hands off keyboard while this going on.
>
> Cheers, & hth.,
>
> - Alf
>
> --
> A: Because it messes up the order in which people normally read text.
> Q: Why is it such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing on usenet and in e-mail?


Hi Alf

Thank you very much for your ideas. Unfortunately I have no Idea, how
these programs are being run. I think the smartest way to contiue
would be to check with the manufacturers of these softwares whether
there are ways to control their programmes by using a simple batch-
file. Perhaps they do have some interface or control- software. Who
knows.
But from the present point of view, I rather tend to propose this
keystroke option to my professor. I konw that it's not the safest way
of handling that problem, but as the calculations will run for several
hours, I could just simply disconnect the mouse and the keyboard after
starting the calculation....
As I said before. This might not be a smart solution, but if it works
out in the end, then thats just what i need. I'm mechanical and not
software engineer.

So, thanks a lot for your help. Really appreciate it!

Christian
From: das_chris on
On 22 Apr., 03:18, CBFalconer <cbfalco...(a)yahoo.com> wrote:
> das_chris wrote:
>
> ... snip ...
>
> > Now my question:
> > Is it possible, to control a programme, using a batch file? e.g.
> > opening word, loading an explicit file, running a macro and saving
> > the file, using the *.txt format?
>
> Of course. It depends on the power of the batch language. Here is
> one for MSDOS (dated Dec 2002), using 4dos as the command
> processor, that writes an HTML file with selected directory data:
>
> @echo off
> :: mkindex2.htm by Mike Bessy, revised by C.B. Falconer
> :: see "news://jpsoft.media3.net/138154%40jpsoft.support"
> *setlocal
> *unalias *
> ::on error goto done
> on break goto done
> goto start
>
> :: convert system datestamp in %ft to ISO in %ymd
> :isodate
> set ymd=%@year[%ft]
> iff %ymd LT 80 then
> set ymd=%@eval[%ymd+2000]
> elseiff &ymd LT 100 then
> set ymd=%@eval[%ymd+1900]
> else
> set ymd=%@right[4, 0%ymd]
> endiff
> set ymd=%ymd-%@right[2, 0%@month[%ft]]-%@right[2, 0%@day[%ft]]
> return
>
> :start
> set based=~cbfalconer/
> set f="index.htm"
> set suppress=/[!*.ion index*.htm *.ba*]
> iff not ".%1." == ".." then
> set based=%@strip[%=", %1]
> set suppress=/[!index.htm %2&]
> endiff
> set d="%@full[.]"
> echo %=nUsage: %0 [Title prefix] [files to suppress]
> echo %=n%@upper[%0]: Hit Ctrl-C to abort or press any key to
> pause %@if[exist %f,re,]build %f from %d.
> cdd %d
> >!%f
> text >> %f
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <HTML>
> <HEAD>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> <meta name="GENERATOR" content="mkindex2.btm [4dos]">
> <TITLE>
> endtext
>
> echo %based%%@filename[%d] directory >> %f
>
> text >> %f
> </TITLE></HEAD><BODY><CENTER><H1>
> endtext
>
> echo %based%%@filename[%d] >> %f
>
> text >> %f
> </H1><P><A HREF="../index.htm">Back to parent directory</A>
> <P>
> <TABLE ALIGN=CENTER BORDERCOLOR="#0000FF" BORDER="5" WIDTH="98%">
> <TR>
> <TD BGCOLOR="WHITE"><CENTER><B>Name</B></CENTER></TD>
> <TD BGCOLOR="WHITE"><CENTER><B>Date</B></CENTER></TD>
> <TD BGCOLOR="WHITE"><CENTER><B>Size</B></CENTER></TD>
> <TD BGCOLOR="WHITE"><CENTER><B>Description</B></CENTER></TD>
> </TR>
> endtext
>
> set n=0
> dir %suppress /h /b | for %ii in (@con) (
> echo %=<TR%=> >> %f
> echo %=<TD%=>%=<A HREF="%ii"%=>%ii%=</A%=>%=</TD%=> >> %f
> set ft=%@filedate["%ii"]
> gosub isodate
> echo %=<TD ALIGN=CENTER%=>%ymd%=</TD%=> >> %f
> echo %=<TD
> ALIGN=RIGHT%=>%@format[5,%@filesize["%ii",K]]K%=</TD%=> >> %f
> echo %=<TD%=>%@descript["%ii"] %=</TD%=> >>%f
> echo %=</TR%=> >> %f
> set n=%@inc[%n]
> )
> echo %=</TABLE%=> >>%f
> set ft=%_date
> gosub isodate
> echo %=<P%=>[%n files indexed on %ymd at %_time >> %f
>
> text >> %f
> by <BIG><A HREF="http://jpsoft.com/"> 4DOS!</A></BIG> ]
> <P>
> <A HREF="../index.htm">Back to parent directory</A>
> </CENTER></BODY></HTML>
> endtext
>
> echo %n files indexed on %ymd at %_time
>
> :done
>
> --
> [mail]: Chuck F (cbfalconer at maineline dot net)
> [page]: <http://cbfalconer.home.att.net>
> Try the download section.
>
> ** Posted fromhttp://www.teranews.com**

Hi Chuck

Thank you for your Info. I tried to run the source code you wrote down
by inserting it into a textfile and saving it as a *.bat file. For
some commands it said that it wouldnt know them. I am also by far not
that much into programming as to be able to understand the source text
you sent. I can identify some passages, but lots of it is just
hieroglyphics to me. Thats my fault, not yours.
Thanks anyways

Christian