在 MATLAB 中检测浏览器是否关闭
我正在MATLAB打开一个URL。只有在关闭浏览器窗口时,脚本才能继续。
如果浏览器仍然打开,我如何在MATLAB-Script中检测?
感谢您的帮助!
I am opening an URL in Matlab. The script shall only continue when the browser window has been closed.
How can I detect within a Matlab-Script if the browser is still open or not?
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您可以使用 Matlab 中的 IsRunning() 函数?我最近看到一个类似的问题:
https:// /mathworks.com/matlabcentral/answers/360246-check-if-the-programm-is-running-already
Perhaps you can use the IsRunning()-function in Matlab? I recently saw a similar question:
https://mathworks.com/matlabcentral/answers/360246-check-if-the-programm-is-running-already
据我所知,没有什么好的方法可以做到这一点。
据我所知,没有浏览器可以让其他程序知道它打开了哪些 URL(出于良好的隐私原因)。据我所知,没有浏览器提供网页从外部发出其已关闭信号的机制。网页如何与系统的其余部分交互也有很多限制(出于良好的安全原因)。
因此,您唯一真正的选择是让网页以 Matlab 可以访问并且您的代码预先知道的方式不断将内容写入磁盘。然后,您可以监视该内容,当它变得“足够陈旧”时,您可以得出结论,该页面可能已更改。这很复杂且容易出错,并且可能会让用户感到困惑。
您的情况的某些特定方面可能使此方法可行,但通常情况下并非如此。
更好的解决方案是设置一个按钮,供用户在完成网页后单击。
So far as I can see, there is no good way to do this.
No browser that I am aware of provides a way for other programs to know what URLs it has open (for good privacy reasons). And no browser that I am aware of provides a mechanism for a web page to externally signal that it has been closed. There are also a lot of limitations on how a web page can interact with the rest of the system (for good security reasons).
So your only real option is for the web page to continually write content to disk, in a way that is accessible to Matlab and that is known a priori by your code. You can then monitor that content, and when it gets "stale enough" you can conclude that the page was probably changed. This is complicated and error-prone, and will likely confuse users.
There might be some specific aspect of your situation that makes this workable, but in general it is not.
A better solution is just to have a button that the user clicks when they are done with the web page.