我正在尝试创建一个编码的 UI 属性来检查打开的 WMP 文件。
public BrowserWindow VideoWindow
{
get
{
if (this._videoWindow == null || !this._videoWindow.Exists)
{
this._videoWindow = new BrowserWindow();
this._videoWindow.SearchProperties["Name"] = "Windows Media Player";
this._videoWindow.SearchProperties["ControlType"] = "Window";
}
return this._videoWindow;
}
}
显然,这是行不通的。最初,该应用程序打开了一个视频网站的链接。所以这有效,但由于它与 BrowserWindow 有很大不同,我不确定该怎么做。如何使用 Coded UI 来“抓取”它?
最佳答案
windows media player 与您一直在处理的视频网站的唯一真正区别是 windows media player 将是 WpfWindow 而不是 BrowserWindow -
public WpfWindow VideoWindow
{
get
{
if (this._videoWindow == null || !this._videoWindow.Exists)
{
this._videoWindow = new WpfWindow();
this._videoWindow.SearchProperties["Name"] = "Windows Media Player";
this._videoWindow.WindowTitles.Add("Windows Media Player");
}
return this._videoWindow;
}
}
之后,您只需获取媒体播放器窗口内的控件(WpfControls 而不是 HtmlControls)来确定哪个文件已打开。
关于c# - 检查打开的 Windows Media Player 文件的编码 UI 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18666405/