Within a script, can I close or redirect a Windows File Explorer window opened with 'winopen'?
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jeff Miller
el 19 de Mayo de 2022
Respondida: Paul
el 21 de Mayo de 2022
I have a script that processes iteratively through a number of directories, spending a few hours per directory. It would be very convenient to be able to view the directory currently being processed at each moment while the script is running.
MATLAB's 'winopen' command can be used to open a file explorer window at the start of processing each new directory, which is helpful. But these windows proliferate if the script issues a new 'winopen' each time it starts processing a new directory. With a lot of such windows open, it is tough to see which directory is currently being processed.
Hence my question: Is there a way to either:
- close an existing Windows Explorer window on a directory when I am done processing that directory, or
- point the existing Windows Explorer window to the new directory when the script changes directories?
Or maybe there is some entirely different approach?
Thanks for any suggestions,
0 comentarios
Respuesta aceptada
Jan
el 19 de Mayo de 2022
You could open a tree view to the folder inside Matlab:
[mtree, container] = uitree('v0', 'Root','C:\') % Still working?
This wa supported in R2018b, but maybe newer Matlab versions limit this.
3 comentarios
Jan
el 20 de Mayo de 2022
In R2018b the shown code does allow to open subfolders.
The live-updates would need some additional effort, e.g. a FileSystemViewer or timer. You might be able to expand the code even to show the wanted details. But I agree, that a standard file system view window is most useful, because it is the look&feel, that a user expects.
I've experimented with:
runtime = java.lang.Runtime.getRuntime();
process = runtime.exec('EXPLORER.EXE /n,/e,"C:\"'); % non-blocking
pause(5)
process.destroy(); % force-kill the process (rc will be 1)
without success. Using !tasklist and !taskkill would be fragile and you could kill the wrong application.
You can use the WindowAPI to close a window with a specific name. But as soon as you click around in the Explorer window, the name changes.
So what about opening one Explorer window, which points to a virtual link created by SUBST and to modify this link dynamically? Ugly, so ugly, that I hesitate to try it.
Nicer: Create a GUI, which displays a button: "Open currently processed folder view". Then the user can close this view and opens it again dynamically. This is more user-friendly then brutally closing this Explorer window: imagine, the user has open such a window, gets an email concerning a specific file, navigates to this folder using the file explorer currently visible and - whoops, Matlab closes it. Evil.
So let the user use a Matlab GUI button to open the currently processed folder and let him close this window manually.
Más respuestas (1)
Paul
el 21 de Mayo de 2022
Maybe using an actxserver is a viable approach. I've used it for interacting with Power Point. It's not so bad once you get the hang of it and can find the good documentation on the methods, properties, objects, etc.
I did a quick search and found this link that seems to be on point and might be a good place to start. No idea what capabilities are actually available, but I'd be surprised if you can't make it do what you want.
0 comentarios
Ver también
Categorías
Más información sobre PID Controller Tuning en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!