kontaminator
Desconectado
Mensajes: 37
Tuve que cambiar de mail. Agregenme
|
Creo que es mas fácil de esta manera:
En un Módulo
Option Base 1
'Funciones para poder usar el Winamp Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As Long) As Long Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal WndID As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal WndID As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Declare Function CopyDataSendMessage Lib "user32" Alias "SendMessageA" (ByVal WndID As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As COPYDATASTRUCT) As Long Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Type COPYDATASTRUCT dwData As Long cbData As Long lpData As Long End Type
Public hWndWinamp As Long Public RetVal As Long
'Windows Constantes Public Const WM_COMMAND = &H111 Public Const WM_COPYDATA = &H4A Public Const WM_USER = &H400
'Winamp Constantes Public Const waClose As Long = 40001 Public Const waPlay As Long = 40045 Public Const waStop As Long = 40047 Public Const waPause As Long = 40046 Public Const waPreviousTrack As Long = 40044 Public Const waNextTrack As Long = 40048 Public Const waForward5Sec As Long = 40148 Public Const waRewind5Sec As Long = 40144 Public Const waRaiseVolume As Long = 40058 Public Const waLowerVolume As Long = 40059
Public Const waShuffle As Long = 252 Public Const waGetStatus As Long = 104 Public Const waGetPosLen As Long = 105 Public Const waSetPos As Long = 106 Public Const waSetVolume As Long = 122
'Winamp Constates del estado ejecucción Public Const waPlaying As Long = 1 Public Const waPaused As Long = 3 Public Const waStopped As Long = 0 Public Const waPlayStatusError As Long = -1 'Iniciar Winamp Public Sub StartWinamp(waclass As String) Dim dirWA As String dirWA = "C:\Archivos de programa\Winamp\winamp.exe /CLASS=" & Chr(34) & waclass & Chr(34) Shell dirWA, vbMinimizedNoFocus ‘ abre el Winamp minimizado End Sub 'Salir Winamp Public Sub CloseWinamp(waclass As String) hWndWinamp = FindWindow(waclass, 0) If hWndWinamp = 0 Then Exit Sub End If RetVal = SendMessage(hWndWinamp, WM_COMMAND, waClose, 0) End Sub
'Ejecuta la canción Public Sub PlayTrack(waclass As String, Optional PostMess As Boolean = True) hWndWinamp = FindWindow(waclass, 0) If hWndWinamp = 0 Then Exit Sub End If If PostMess Then PostIt waPlay Else SendIt waPlay End If End Sub 'Detiene la canción Public Sub StopTrack(waclass As String, Optional PostMess As Boolean = True) hWndWinamp = FindWindow(waclass, 0) If hWndWinamp = 0 Then Exit Sub End If If PostMess Then PostIt waStop Else SendIt waStop End If End Sub 'Pausa la canción Public Sub PauseTrack(waclass As String, Optional PostMess As Boolean = True) hWndWinamp = FindWindow(waclass, 0) If hWndWinamp = 0 Then Exit Sub End If If PostMess Then PostIt waPause Else SendIt waPause End If End Sub 'Canción anterior Public Sub PreviousTrack(waclass As String, Optional PostMess As Boolean = True) hWndWinamp = FindWindow(waclass, 0) If hWndWinamp = 0 Then Exit Sub End If If PostMess Then PostIt waPreviousTrack Else SendIt waPreviousTrack End If End Sub 'Canción siguiente Public Sub NextTrack(waclass As String, Optional PostMess As Boolean = True) hWndWinamp = FindWindow(waclass, 0) If hWndWinamp = 0 Then Exit Sub End If If PostMess Then PostIt waNextTrack Else SendIt waNextTrack End If End Sub 'Avanza 5 segundos la canción Public Sub Forward5Sec(waclass As String, Optional PostMess As Boolean = True) hWndWinamp = FindWindow(waclass, 0) If hWndWinamp = 0 Then Exit Sub End If If PostMess Then PostIt waForward5Sec Else SendIt waForward5Sec End If End Sub 'Retrocede 5 segundos la canción Public Sub Rewind5Sec(waclass As String, Optional PostMess As Boolean = True) hWndWinamp = FindWindow(waclass, 0) If hWndWinamp = 0 Then Exit Sub End If If PostMess Then PostIt waRewind5Sec Else SendIt waRewind5Sec End If End Sub
'Obtiene el estado del Winamp Public Function GetStatus(waclass As String) As Long hWndWinamp = FindWindow(waclass, 0) If hWndWinamp = 0 Then Exit Function End If GetStatus = SendMessage(hWndWinamp, WM_USER, 0, waGetStatus) End Function 'Funciones para los mensajes Private Sub PostIt(Action As Long) Dim n As Date n = Now Do RetVal = PostMessage(hWndWinamp, WM_COMMAND, Action, 0) Debug.Print "post", Now - n, 5 / 86400 If RetVal = 0 Then If Now - n > 5 / 86400 Then MsgBox "Couldn't queue message for 5 seconds: " & Action Exit Do End If End If Loop Until RetVal <> 0 End Sub Private Sub SendIt(Action As Long) RetVal = SendMessage(hWndWinamp, WM_COMMAND, Action, 0) End Sub
y esto en el form: If Text1.Text = "abrir_win" Then StartWinamp WAClase ' abre el winamp If Text1.Text = "cerrar_win" Then CloseWinamp WAClase 'cierra el winamp If Text1.Text = "atras_win" Then PreviousTrack WAClase 'tema anterior winamp If Text1.Text = "play_win" Then PlayTrack WAClase 'reproduce el winamp If Text1.Text = "pause_win" Then PauseTrack WAClase 'pause ene l winamp If Text1.Text = "stop_win" Then StopTrack WAClase 'detiene el tema en el winamp If Text1.Text = "adelante_win" Then NextTrack WAClase 'el tema sig del winamp If Text1.Text = "RW_win" Then Rewind5Sec WAClase ' retrocede 5 seg winamp If Text1.Text = "FF_win" Then Forward5Sec WAClase 'adelanta 5 seg winamp
End Sub
Nota2: Todo está en visual basic
|