本文介绍了Matlab:仅在尚未打开OS资源管理器窗口时打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下行从matlab中在Windows资源管理器中打开一个文件夹:

I'm opening a folder in Windows explorer from within matlab with the following line :

system('explorer.exe /select,./my_folder/my_file.tif');

即使Matlab当前文件夹"的相对路径带有"./",它也能很好地工作.请注意,它还会选择指定的文件,这正是我想要的.

It works well, even with the relative path for Matlab "current folder" with "./". Note that it also selects the specified file, which is what I want.

但是,仅在尚未打开相同路径的情况下,我才想打开此窗口.现在,我得到了同一窗口的多个副本,这很烦人.你知道这样做的方法吗?

However, I would like to open this window only if the same path isn't already open. Right now, I get several copies of the same window and it's annoying. Do you know any way to do this ?

谢谢

Ghislain

(Windows 8,Matlab R2011b 64位)

(Windows 8, Matlab R2011b 64bits)

推荐答案

免责声明

这是部分答案.我不知道如何从这里继续,但是无论如何它可能会有所帮助.您的问题对我来说很有趣,并且如果在接口(Matlab/Explorer)之间进行的更改更容易,它将使数据分析变得更加容易!

This is a partial answer. I don't know how to go on from here, but maybe it helps anyways. Your question is quite interesting to me, and it would make data-analysis a lot easier if changing between interfaces (Matlab/Explorer) were easier!

某些历史记录

DDE是一项古老的技术(16位Windows,是的!),它使Windows应用程序能够相互通信. DDE已从Windows XP开始淘汰,但它只是拒绝死亡.

DDE is an ancient technology (16-bit Windows, yeah!) that enables Windows applications to talk to each other. DDE has been deperecated from Windows XP on, but it simply refuses to die.

DDE使用寿命长的一个原因是Windows资源管理器仍然大量使用DDE.例如,当您双击一个文件时,资源管理器会向Excel发送一个DDE命令,告诉它在当前Excel窗口中打开该文件.

One reason for DDE's longevity is that Windows Explorer still uses DDE a lot. For example, when you double-click a file, the Explorer sends a DDE command to Excel, telling it to open that file in the current Excel window.

DDE如何为您提供帮助

Matlab的DDE支持已被正式弃用.如果不是因为Explorer通过DDE消息与Matlab对话,它可能会完全消失!

Matlab's DDE support is officially deprecated. Maybe it would have disappeared completely, were it not for the fact that Explorer talks to Matlab via DDE messages!

您可以通过将有关主题"appproperties"的启动DDE通道告知应用程序文件夹"来逆转此过程:

You can reverse this process by telling initiating a DDE channel to the application "folders" about the topic "appproperties":

channel = ddeinit('folders', 'appproperties')

文件夹"应用程序似乎是Windows 3程序管理器"progman"的同义词.您可以通过执行命令告诉资源管理器(文件夹")查看文件夹

The "folders" application appears to be a synonym for "progman", the good ol' Windows 3 program manager. You can tell Explorer ("folders") to view a folder by executing

ddeexec(channel, '[ViewFolder("%l", c:\windows, 5)]')

如果资源管理器已经指向该文件夹,则不会打开任何新窗口.不幸的是,我无法告诉您更多有关该命令的信息.我不知道那个%l在做什么,或者那5个.我唯一知道的是ViewFolder可以被ExploreFolder替换,在这种情况下,您总是打开一个新窗口,并且该窗口始终在左窗格中显示文件夹树结构.

If Explorer already points to that folder, no new window is opened. Unfortunately, I cannot tell you much more about that command. I don't know what that %l is doing there, or the 5 for that matter. The only thing I know is that ViewFolder can be replaced by ExploreFolder, in which case you always open a new window, and that window always shows the folder tree structure on the left pane.

更多信息

与DDE相关的最重要的函数是ddeinit,ddeexec和ddeterm.它们的文档埋在那些函数的.m文件中.您只需执行即可查看.m文件

The most important DDE-related functions are ddeinit, ddeexec, and ddeterm. Their documentation is buried inside the .m files of those functions. You can view the .m files by simply executing

edit ddeinit

Yair Altman有有关Matlab DDE功能的更多信息.资源管理器理解了哪些DDE命令,这让我回避了.我从在这里中找到的内容整理了示例.

Yair Altman has some more info on Matlab's DDE capabilities. What DDE commands are understdood by Explorer evades me. I assembled my example from what I found here.

这篇关于Matlab:仅在尚未打开OS资源管理器窗口时打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 06:25