Results 1 to 6 of 6

Thread: API help of Finding a window and showing it

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Posts
    24

    Question

    I need help Finding a window i don't know the hWnd for and making it the window that i will sendkeys too. i have no question about sendkeys but cannot figure out how to find it or showing it at all. Thanks for the help

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You can use the FindWindowEx API to find the window by Class or Caption and the ShowWindow() API to make a Window the current Window, i.e.
    Code:
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Const SW_NORMAL = 1
    
    Private Sub Command1_Click()
        Dim lHwnd As Long
        
        lHwnd = FindWindowEx(0, 0, vbNullString, ByVal "Notepad - Untitled")
        If lHwnd Then Call ShowWindow(lHwnd, SW_NORMAL)
    End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Posts
    24

    Okay did that

    how would i make it so it looked and showed the window Asheron's Call
    ?

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Just change the Notepad - Untitled to Asheron's Call

  5. #5
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Question FindWindow vs FindWindowEx

    Hi! Aaron, What the diff between FindWindowEx and FindWindow? Perhaps you can explain a bit over here?

    I found that FindWindow is less parameter as compare to the FindWindowEx that you've applied.

    Code:
    Option Explicit
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long
    
    Dim hwnd As Long
    hwnd = FindWindow(0&, "Notepad - Untitled")

  6. #6
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Although I am not quite clear myself, FindWindowEx can search in child windows also(supposedly in the case of mdi parent and child windows) whereas FindWindow doesnot cover child windows.

    Amitabh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width