Manfred_F's avatar
Manfred_F
Regular Contributor
9 years ago
Status:
New Idea

Add Button "OK to all" to TC error message

Quite frequently I get TC error Messages. In some cases, I get several dozends at a time. This occurs especially when vbscript objects created in a script Extension were left open after the test run and script extensions are reloaded. Then, the Class_Terminate procedure are executed, but at that time no Log and other global objects are available, so lots of errors occur. I'd like to be able to send "OK" to all of them at a single button click.

1 Comment

  • Hello,

     

    I can suggest using a workaround: I have created a simple PowerShell script that will close all TestComplete error messages automatically one by one. Please find this script below - save it to a file with the *.PS1 extension. Information on how to run a script can be found in the Running a PowerShell Script from Windows section of this blog article.

     

    $definition = @"    
          [DllImport("user32.dll")]
          static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    
          [DllImport("user32.dll")]
          public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
    
          const int WM_CLOSE = 0x0010;
    
          public static int getWnd(string wClass, string wName)
          {
            int hwnd = 0;
            int endTime = System.Environment.TickCount + 3000;
    
            while (hwnd == 0) {
              hwnd = (int)FindWindow(wClass, wName);
              if (hwnd > 0)
                return hwnd;
              if (System.Environment.TickCount > endTime)
                return 0;
            }
    
            return 0;
          }
    
          public static void Close(string wClass, string wName)
          {
             int hwnd = getWnd(wClass, wName);
             while (hwnd > 0) {
                SendMessage(hwnd, WM_CLOSE, 0, 0);
                System.Threading.Thread.Sleep(1000);
                hwnd = getWnd(wClass, wName);
             }
          }
    "@
    
    add-type -MemberDefinition $definition -Namespace my -Name WinApi
    
    [my.WinApi]::Close('TMessageForm', 'TestComplete')