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:
Private Sub Command1_Click() Call getWinampWindow MsgBox NowPlayingStr End Sub
And here is my Module code (Feel free to re-use this code if needbe, its fully fnctioning)
VB Code:
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Dim lHandle As Long Dim NowPlayingStr As String Function getWinampWindow() lHandle = FindWindow("Winamp v1.x", vbNullString) If lHandle > 0 Then Dim lRet As Long Dim sTitle As String * 256 Dim sCaption As String lRet = GetWindowText(lHandle, sTitle, Len(sTitle)) sCaption = Left(sTitle, InStr(1, sTitle, vbNullChar, vbTextCompare) - 10) Do If IsNumeric(Left(sCaption, 1)) = True Or Left(sCaption, 1) = "." Or Left(sCaption, 1) = " " Then sCaption = Right(sCaption, Len(sCaption) - 1) Else Exit Do End If Loop Do If IsNumeric(Right(sCaption, 1)) = True Or Right(sCaption, 1) = ")" Or Right(sCaption, 1) = " " Or Right(sCaption, 1) = ":" Then sCaption = Left(sCaption, Len(sCaption) - 1) ElseIf Right(sCaption, 1) = "(" Then sCaption = Left(sCaption, Len(sCaption) - 1) Exit Do Else Exit Do End If Loop NowPlayingStr = sCaption Else NowPlayingStr = "Winamp 6 Not Found" End If End Function
Any suggestions as to how to get this to work ?
EDIT : Final Code in Last post




Reply With Quote