Forum Discussion

Gadzilla's avatar
Gadzilla
Contributor
15 years ago

Problem with calling function from user32.dll

Hi,



I am trying to create script which will check whether some process have hung window. I have found "IsHungAppWindow" Win32Api function (http://msdn.microsoft.com/en-us/library/ms633526(VS.85).aspx) that is suitable for my purposes, but I have problems with its calling from my script.



Attempt to call this function via Win32API TestComplete's program object leads to error: "Object doesn't support this property or method".



  var oWnd = Sys.WaitProcess("MyProccess").WaitWindow("MyWindow");

        if(oWnd.Exists)

  {

  var bIsHungWnd = Win32API.IsHungAppWindow(oWnd.Handle);  // Here I got error message.

  ...

  }



Also I have found information that "IsHungAppWindow" function defined in "user32.dll". So I am trying to call this function via DLL TestComplete's program object in the following way:



var oWnd = Sys.WaitProcess("MyProccess").WaitWindow("MyWindow");

if(oWnd.Exists)


  {

  var Def_Environment = DLL.DefineEnvironment(true);


                var Def_DLL = Def_Environment.DefineDLL("USER32");


  Def_DLL.DefineProc("IsAppWndHung", vt_i4, vt_bool);


  Def_DLL.DefineAlias("IsHungAppWindow", "IsAppWndHung");


                var Lib = Def_Environment.Load("C:\\Windows\\System32\\USER32.dll");


        

  var bIsHungWnd = Lib.IsHungAppWindow(oWnd.Handle);  // Here I got error "Object doesn't support this property or method"

  ...

  }




 Could someone help me to solve the problem with using "IsHungAppWindow" Win32 api function, or please just point me to the wrong place in my script.



Thanks in advance,

John.

7 Replies

  • Hi,



    The MSDN article states that this function is not intended for general use, and it may be altered or unavailable in subsequent versions of Windows, so I've checked the user32.dll library on a Windows 7 PC and failed to find such an exported function.
  • Hi Jared!



    Thanks for your quick response.



    Do you have some suggestion how can I check some window (not process) for responding? I have tried to find window with "*Not Responding*" caption buy using FindAllChildren function of the process, but this function return nothing even in case when window with such caption displayed on the screen.



    Any suggestion will be helpful.



    Thanks.
  • Hi Jared!



    I have added parent process of the window (window, on which test complete hung, when this window hung) to the list of Freeze Diagnostics properties of my test project, but this does not help. One of the child window still hung during scripts run and TestComplete hung with this window at attempt to send some event (might be click event) to this window.



    Do you have other suggestion on how I can recognize whether some WINDOW (NOT parent PROCESS) stops responding?



    Thanks in advance!
  • Hi,



    Do you have other suggestion on how I can recognize whether some WINDOW (NOT parent PROCESS) stops responding?


    I'm not sure whether this task can be accomplished. I'd recommend that you ask the MSDN community about this.
  • Thanks Jared for your answer! I will try to find some solution.



    Might be you can answer one more question. 



    I have created some jscript, which I run with WScript. In this script I use TestComplete's COM (integration object) to retrieve main window object of my tested application and to check caption of this window. I run this script automatically when I start test cases execution from TestComplete (e.g. I have added run of this external script to the "OnStartTestCase" event) So when my test cases starts in TestComplete, this external script also starts throw command line and it checks whether main window of my tested application contains "Not Responding" string in the window caption.



    The problem is that my external script alway return only real caption of my window at runtime even in case this window contains "Not Responding" string (e.g. external script return caption of the window without "Not Responding"). TestComplete see caption of the hung window correctly in case I stop scripts execution, and navigate to my hung window in Object tree.



    Could you please tell me why this happens and how can I catch window with "Not Responding" caption at runtime?


  • Hi,



    The recommended way of handling hangings of tested applications is described in the "Handling Application Freezes" section of the "Diagnosing Application Freezes" help topic. If such an approach does not work for your application, we'd like to analyze it. Can you send us a sample? If you want to get personalized assistance, you can submit an individual support case.