1

After my scripts exit the WPF application under test ,very often i find the ghost application icons left behind in the Notification area.It just disappears when i do a mouseover manually.If this action is automated, it throws an error saying "object doesn't exist"(because the icon disppears when TC does the hoverover action). Is there any better way of tackling this issue? Iam using TC9 with jscript.

Thanks for your help!

user2993178
  • 97
  • 1
  • 12

1 Answers1

0

You can use the Windows API SendMessage function to send the WM_MOUSEMOVE message to the notification area objects. I took code from the answers to this question and adapted it to 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);
  }
}
Community
  • 1
  • 1
Helen
  • 87,344
  • 17
  • 243
  • 314