Controlling an external program

30 vues (au cours des 30 derniers jours)
Brandon
Brandon le 19 Avr 2016
Modifié(e) : Image Analyst le 19 Avr 2016
Matlab noob here looking to understand how to write a matlab script to automatically control another program. Basically I would like to write a matlab code that will open another program and then execute a series of commands in that program that will eventually open a .txt file. Next, I need that .txt file copied to another location. I have very little matlab experience from taking a class at my university, but we didn’t touch on advanced functions like the one I’ve described above. I’ve been searching gui related discussions, but none seem to touch on what I would like to do. This is as far as I’ve gotten: !"C:\Program Files (x86)\HEIDENHAIN\TNCremo\TNCremo.exe" file_browse_button_handle = 'Establish connection'; cb = get(file_browse_button_handle, 'Callback'); cb(file_browse_button_handle, []);
It opens the program, but trying to manipulate the program is where I’m stuck. Any help would be greatly appreciated. Even if you could just point me in the direction of the right threads to read or exactly what I need to search for. Thanks in advance, Brandon

Réponses (1)

Image Analyst
Image Analyst le 19 Avr 2016
Modifié(e) : Image Analyst le 19 Avr 2016
There are 3 options that I know of
  1. Use ActiveX. If using Windows, and using a program that is ActiveX aware, like Microsoft Office applications, then you can use ActiveX to control the program from within MATLAB. I have a demo attached where I do that with Excel.
  2. Use Java Robot. Basically control the mouse cursor and tell it where to go and what to click on, and control the keyboard to send keystrokes. Demo attached.
  3. Use an SDK. If your other app has a software development kit, then you can communicate with its DLLs using the loadlibrary() function of MATLAB.

Community Treasure Hunt

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

Start Hunting!

Translated by