【发布时间】:2014-06-06 15:33:57
【问题描述】:
在我的脚本退出正在测试的 WPF 应用程序后,我经常发现通知区域中留下了幽灵应用程序图标。当我手动执行鼠标悬停时,它就会消失。如果此操作是自动的,则会引发错误“对象不存在”(因为 TC 执行悬停操作时图标消失)。 有没有更好的方法来解决这个问题?我正在使用 TC9 和 jscript。
感谢您的帮助!
【问题讨论】:
标签: testcomplete
在我的脚本退出正在测试的 WPF 应用程序后,我经常发现通知区域中留下了幽灵应用程序图标。当我手动执行鼠标悬停时,它就会消失。如果此操作是自动的,则会引发错误“对象不存在”(因为 TC 执行悬停操作时图标消失)。 有没有更好的方法来解决这个问题?我正在使用 TC9 和 jscript。
感谢您的帮助!
【问题讨论】:
标签: testcomplete
您可以使用 Windows API SendMessage 函数将WM_MOUSEMOVE 消息发送到通知区域对象。我从this question 的答案中提取代码并将其改编为TestComplete:
// JScript
function RefreshNotificationArea()
{
var WM_MOUSEMOVE = 0x0200;
var explorer = Sys.Process("explorer");
var toolbars = [
explorer.Window("Shell_TrayWnd").Window("TrayNotifyWnd").Window("SysPager").Window("ToolbarWindow32"),
explorer.Window("NotifyIconOverflowWindow").Window("ToolbarWindow32") // toolbar with hidden icons
];
for (var i = 0; i < toolbars.length; i++)
{
var toolbar = toolbars[i];
for (var x = 0; x < toolbar.Width; x += 5)
for (var y = 0; y < toolbar.Height; y += 5)
Win32API.SendMessage(toolbar.Handle, WM_MOUSEMOVE, 0, (y << 16) + x);
}
}
【讨论】: