Results 1 to 8 of 8

Thread: Another roadblock! help!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    26

    Another roadblock! help!

    I've hit another roadblock in the development of my AIM addon....When a user goes to edit the profile of AIM, i need my timer to find the window and close it! but it wont work! I cant search for the hwnd class...and the caption changes so i cant search for that either.
    The caption of the profile is:

    <Insert Screenname Here> - Create a Profile - More Info


    How in the hell can i find that window!?!?


    thanks!

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Another roadblock! help!

    There is code in the codebank and in the FAQ here in the API section, to find a window by only part of the caption of a window. Have a look


    Has someone helped you? Then you can Rate their helpful post.

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171


    Has someone helped you? Then you can Rate their helpful post.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    26

    Re: Another roadblock! help!

    thansk a BUNCH! ill check em out.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    26

    Re: Another roadblock! help!

    im looking at the module at the function asks for the window?....how do i use the function lol..sorry.

  6. #6
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Another roadblock! help!

    Which one?


    Has someone helped you? Then you can Rate their helpful post.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    26

    Re: Another roadblock! help!

    VB Code:
    1. Option Explicit
    2. Private Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
    3. Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    4. Public Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
    5. Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    6. Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    7. Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    8. Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    9. Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
    10. Public 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
    11. Public Const WM_GETTEXT = &HD
    12. Public Const WM_GETTEXTLENGTH = &HE
    13. Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    14. Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    15. Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    16. Global lngRhWnd As Long ' global to store handle
    17. Global strWindowTitle As String ' global to store title
    18. Global strClassname As String ' global to store class
    19.  
    20.  
    21. 'searches through all windows for the partial caption "- Conversation"
    22. 'it will return the hwnd and caption :D
    23. Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
    24.     Dim sSave As String, Ret As Long
    25.     Ret = GetWindowTextLength(hwnd)
    26.     sSave = Space(Ret)
    27.     GetWindowText hwnd, sSave, Ret + 1
    28.     If InStr(sSave, "- Create a Profile - More Info") Then
    29.     lngRhWnd = Str$(hwnd)
    30.     strClassname = GetClass(lngRhWnd)
    31.     strWindowTitle = GetWinTitle(lngRhWnd)
    32.     MsgBox "ok"
    33.     End If
    34.     EnumWindowsProc = True
    35. End Function
    36.  
    37. Public Function GetTheWindow(Optional strClassname As String) As Long
    38.     Dim retval As Boolean
    39.     retval = EnumWindows(AddressOf EnumWindowsProc, 0)
    40.     strClassname = GetClass(lngRhWnd)
    41.     GetTheWindow = lngRhWnd
    42. End Function
    43.  
    44. Private Function GetClass(hwnd As Long)
    45. Dim sSave As String, intLenRet As Integer
    46. sSave = Space(256)
    47. intLenRet = GetClassName(hwnd, sSave, 256)
    48. GetClass = Left$(sSave, intLenRet)
    49. End Function
    50.  
    51. Private Function GetWinTitle(hwnd As Long) As String
    52. GetWinTitle = GetText(hwnd)
    53. End Function
    54.  
    55. Public Function GetText(WinHandle As Long) As String
    56. Dim abc As String, TxtLength As Long
    57. TxtLength& = SendMessage(WinHandle&, WM_GETTEXTLENGTH, 0&, 0&)
    58. abc$ = String(TxtLength&, 0&)
    59. Call SendMessageByString(WinHandle&, WM_GETTEXT, TxtLength& + 1, abc$)
    60. GetText$ = abc$
    61. End Function


    that one, the first function....

  8. #8
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Another roadblock! help!

    Use the GetTheWindow function. Something like this :

    VB Code:
    1. MsgBox "hwnd of window : " & GetTheWindow
    2.     MsgBox "classname of window : " & strClassname
    3.     MsgBox "window title : " & strWindowTitle


    Has someone helped you? Then you can Rate their helpful post.

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