views:

17

answers:

0

This is my code.. for some reason it is not working

 Public Class Form1

    Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32

    Private Const WM_KEYDOWN = &H100
    Private Const WM_KEYUP = &H101
    Private Const VK_SPACE = &H20
    Private Const VK_CONTROL = &H11
    Private Const VK_LEFT = &H25
    Private Const VK_UP = &H26
    Private Const VK_RIGHT = &H27
    Private Const VK_DOWN = &H28

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick


        Dim p As Process
        Dim title As String
        Dim handle As IntPtr

        For Each p In Process.GetProcessesByName("winamp")

            title = p.MainWindowTitle
            handle = p.MainWindowHandle

            If InStr(title, "Britney") Then

                SendMessage(handle, WM_KEYDOWN, VK_SPACE, 0&)
                SendMessage(handle, WM_KEYUP, VK_SPACE, 0&)

                SendMessage(handle, WM_KEYDOWN, VK_CONTROL, 0)
                SendMessage(handle, WM_KEYDOWN, VK_DOWN, 0)
                SendMessage(handle, WM_KEYUP, VK_CONTROL, 0)
                SendMessage(handle, WM_KEYUP, VK_DOWN, 0)

                SendMessage(handle, WM_KEYDOWN, VK_CONTROL, 0)
                SendMessage(handle, WM_KEYDOWN, VK_DOWN, 0)
                SendMessage(handle, WM_KEYUP, VK_CONTROL, 0)
                SendMessage(handle, WM_KEYUP, VK_DOWN, 0)

                SendMessage(handle, WM_KEYDOWN, VK_CONTROL, 0)
                SendMessage(handle, WM_KEYDOWN, VK_DOWN, 0)
                SendMessage(handle, WM_KEYUP, VK_CONTROL, 0)
                SendMessage(handle, WM_KEYUP, VK_DOWN, 0)


            End If

        Next



    End Sub
End Class