Windows® enviroment window control from matlab (activate window and enter commands)

Is it possible to activate and control a (non Matlab) Windows® (7) cmd window from Matlab?
I now manually click on an opened Windows® command window, type a start command and press enter. I would like to automate this from within a Matlab environment.
Is this possible? And if yes, can somebody give me some pointers?
Joost

 採用された回答

Jan
Jan 2011 年 12 月 22 日

1 投票

その他の回答 (2 件)

C.J. Harris
C.J. Harris 2011 年 12 月 22 日
I don't have Windows 7 to test this on, but this method works for Windows XP. To run a system command just append the command with an exclaimation mark (!). Example:
!calc.exe
You can also evaluate a command in the dos prompt using the 'dos' command. Example:
dos('calc.exe')

2 件のコメント

Joost
Joost 2011 年 12 月 22 日
Thank you for your reply.
Unfortunately, the command window which I would like to control is already opened, running in a specific (fortran based) environment mode.
Therefore, it seems essential to first 'activate' this window (like you manually do by clicking on it) followed by entering the commands.
Is there a way to link/control programs running in Windows?
C.J. Harris
C.J. Harris 2011 年 12 月 22 日
Not as far as I know. Once you start the command window manually Matlab no longer has any access to it. There might be ways around it, but that would (probably) require an additional piece of software controlling program focus and issuing commands.

サインインしてコメントする。

Friedrich
Friedrich 2011 年 12 月 22 日

0 投票

Hi,
I think MATLAB don't has anything which can do this. One way could be writing a mex file which uses the WINDOWS API to get access to other windows, e.g. through the EnumWindows function:
Once you have the window handle you could be able to add some text in it. But not sure which command can help here.
Windows also have the createPipe command which allows you to control I/O:

カテゴリ

ヘルプ センター および File ExchangeFortran with MATLAB についてさらに検索

質問済み:

2011 年 12 月 22 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by