Results 1 to 4 of 4

Thread: FindWindowEx (I've Lost Sleep over This)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Upstate NY
    Posts
    210
    well i haven't lost sleep but it's driven me crazy. Okay here's some code (I'm using the program "Calculator" for an example):
    Code:
    dim a&
    dimb&
    a& = FindWindowEx(0&, 0&, "SciCalc", vbNullString)
    b& = FindWindowEx(a&, 0&, "button", vbNullString)
    in that code, how do i tell what button's handle will be in b&?
    < o >

  2. #2
    Guest
    It will be the 1st button, but why not just specify what button you want? It will be a lot easier.

    For example, use this to find the division button. (I marked my changes in red)
    Code:
    b& = FindWindowEx(a&, 0&, "button", "/")

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    If for some reason, that doesn't work, this code, given the handle returned in your code, will return the caption of the handle.
    Declare Function SendMessageByNum& Lib "user32" Alias "SendMessageA" (ByVal _
    Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
    Declare Function SendMessageByString& Lib "user32" Alias "SendMessageA" (ByVal _
    Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)

    Public Const WM_GETTEXT = &HD
    Public Const WM_GETTEXTLENGTH = &HE

    Function GetTextFromWindow(WindowHandle As Long) As String
    Dim buffer As String, Length As Long
    Length& = SendMessageByNum(WindowHandle&, WM_GETTEXTLENGTH, 0&, 0&)
    buffer$ = String(Length&, 0&)
    Call SendMessageByString(WindowHandle&, WM_GETTEXT, Length& + 1, buffer$)
    GetTextFromWindow$ = buffer$
    End Function
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  4. #4
    Guest
    If done properly, passing the final argument of FindwindowEx shouldn't cause a problem.

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