Results 1 to 7 of 7

Thread: Module Help...[resolved]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Resolved Module Help...[resolved]

    Hey, thanks for stopping by, i have a slight problem with my module, i cannot get my forms to get the resulting string from it, how would i go about doing it ?

    Here is my Forms code -

    VB Code:
    1. Private Sub Command1_Click()
    2. Call getWinampWindow
    3. MsgBox NowPlayingStr
    4. End Sub

    And here is my Module code (Feel free to re-use this code if needbe, its fully fnctioning)
    VB Code:
    1. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    2. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    3. Dim lHandle As Long
    4. Dim NowPlayingStr As String
    5.  
    6. Function getWinampWindow()
    7. lHandle = FindWindow("Winamp v1.x", vbNullString)
    8. If lHandle > 0 Then
    9.     Dim lRet As Long
    10.     Dim sTitle As String * 256
    11.     Dim sCaption As String
    12.     lRet = GetWindowText(lHandle, sTitle, Len(sTitle))
    13.     sCaption = Left(sTitle, InStr(1, sTitle, vbNullChar, vbTextCompare) - 10)
    14.     Do
    15.         If IsNumeric(Left(sCaption, 1)) = True Or Left(sCaption, 1) = "." Or Left(sCaption, 1) = " " Then
    16.         sCaption = Right(sCaption, Len(sCaption) - 1)
    17.         Else
    18.         Exit Do
    19.         End If
    20.     Loop
    21.     Do
    22.         If IsNumeric(Right(sCaption, 1)) = True Or Right(sCaption, 1) = ")" Or Right(sCaption, 1) = " " Or Right(sCaption, 1) = ":" Then
    23.         sCaption = Left(sCaption, Len(sCaption) - 1)
    24.         ElseIf Right(sCaption, 1) = "(" Then
    25.         sCaption = Left(sCaption, Len(sCaption) - 1)
    26.         Exit Do
    27.         Else
    28.         Exit Do
    29.         End If
    30.     Loop
    31.     NowPlayingStr = sCaption
    32. Else
    33.     NowPlayingStr = "Winamp 6 Not Found"
    34. End If
    35. End Function

    Any suggestions as to how to get this to work ?

    EDIT : Final Code in Last post
    Last edited by thegreatone; Apr 27th, 2005 at 12:44 PM.
    Zeegnahtuer?

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