locked
Findwindow does NOT find "#32770 (Dialog)" class window

    Question

  • ----USed code below. If searching for the Calc example, find it no problem and can sendkeys to it ok. However, having gotten the window class and caption with the Spy++ tool and trying it for another window, the montecristo.exe window is not found. The Spy++ tool 'highlights' the montecristo window so I know I have the right one..

    Spy++ indicates the class is #32770 for the Error window that pops up that I wish to try and Senkeys to so it is cosed.

    But the montecristoe window is never found! Neither is there a PID running to access it by at this point in time.

    Please help. .Net 2.0, VB 2005 Express used with Win Xp and/or Win 2K - same results.

    Regards,

    pault

     

    'Dim hFWMCErr As IntPtr = FindWindow(sClass, sCaption)

    ' Dim hFWMCErr As IntPtr = FindWindow("Button", "OK")

    ' Dim hFWMCErr As IntPtr = FindWindow("#32770 (Dialog)", "montecristo.exe - Application Error")

    ' Dim hFWMCErr As IntPtr = FindWindow("SciCalc", "Calculator")

    Dim hFWMCErr As IntPtr = FindWindow("SciCalc", "Calculator")

    If hFWMCErr = IntPtr.Zero Then ' Verify that we have a running process.

    sMyMsg = "Stop Window not found: Class=" & sClass & ". Caption=" & _

    sCaption & "." & sMsg & vbCrLf

    If bPTDebug And bDesktopDebug Then MsgBox(sMyMsg)

    sLogRec = AddLogRec(sMyMsg, True)

    Else

    SearchForWindowAndSendKeys = True

    sMyMsg = "Stop Window found: Class=" & sClass & ". Caption=" & _

    sCaption & ". Doing sendkeys=" & sSendTheseKeys & sMsg & vbCrLf

    If bPTDebug And bDesktopDebug Then MsgBox(sMyMsg)

    sLogRec = AddLogRec(sMyMsg, True)

    ' Make it the foreground application and hopefully send it some keys

    SetForegroundWindow(hFWMCErr)

    SendKeys.SendWait(sSendTheseKeys)

    End If

    ----------- Used:' Get a handle to an application window.

    Declare Auto Function FindWindow Lib "USER32.DLL" ( _ByVal lpClassName As String, _ByVal lpWindowName As String) As IntPtr

    ' Activate an application window.Declare Auto Function SetForegroundWindow Lib "USER32.DLL" _(ByVal hWnd As IntPtr) As Boolean

    Tuesday, October 03, 2006 4:36 PM

Answers

  • Hi!

    I had the same problems,but i did solved, with googling, reading, and thinking :)
    I tried to find the windowclass "#32770 (Dialog)", that told by Spy++, than i searched and found some articles, where they used only "#32770" without "(Dialog)", so i tried it.
    And now it find the window i look for :)
    So use only "#32770", thats all.
    Saturday, November 25, 2006 6:24 AM

All replies

  • I think you can just use VBnull in the class part and just

    go with the 2nd parameter (name).

    Tuesday, October 03, 2006 8:40 PM
  • Hi!

    I had the same problems,but i did solved, with googling, reading, and thinking :)
    I tried to find the windowclass "#32770 (Dialog)", that told by Spy++, than i searched and found some articles, where they used only "#32770" without "(Dialog)", so i tried it.
    And now it find the window i look for :)
    So use only "#32770", thats all.
    Saturday, November 25, 2006 6:24 AM
  • Using only #32770 was the way to do it. Thanks for the suggestion.

     What the meanning of #32770 is, of course, is unclear but that is the key value to use.

    Paul T / N3UD,

    Friday, January 19, 2007 2:05 AM
  • I 've found sth on the MSDN
    It may help u to understand the #32770
    http://msdn.microsoft.com/en-us/library/ms633574(VS.85).aspx

    ClassDescription
    ComboLBox The class for the list box contained in a combo box.
    DDEMLEvent Windows NT/Windows 2000/Windows XP: The class for Dynamic Data Exchange Management Library (DDEML) events.
    Message Windows 2000/Windows XP: The class for a message-only window.
    #32768 The class for a menu.
    #32769 The class for the desktop window.
    #32770 The class for a dialog box.
    #32771 The class for the task switch window.
    #32772 Windows NT/Windows 2000/Windows XP: The class for icon titles.


    Wednesday, May 13, 2009 8:21 AM
  • It really works, thanks. I use method FindeWindow("#32770", null) but I have only one dialog window
    Monday, June 20, 2011 2:27 PM