View Single Post
Old 2nd February 2011, 22:27   #1
Junior Member
Join Date: Jan 2011
Posts: 17
Event dispatcher for Milkdrop2

Hello all. I am working on a project for timed lyrics appearance and images in Milkdrop2. I am writing separate code that manipulates Milkdrop2 through keystrokes rather than altering Milkdrop itself because (it seems?) the OpenSource code out there is all for version 1 and I don't know what I'd lose from Milkdrop2.

Also, rather than write a winamp plugin (learning curve and need to get done fast) I am just writing in VB.

On to point... the program I am working on is a stand alone VB that polls for open Winamp instances and Milkdrop2 windows as well. Then upon song change detection, a file swap takes places to update custom message and image .ini files to reflect that for the new song.

Finally, a specially formatted dispatcher file tells when during playback to send keystrokes to Milkdrop2 to make synched lyrics and/images appear. Not a totally original idea I know.

Things that work:
file swap is fast enough
updating to new ini files sending F7 works fine
splashing images by sending "K" key plus two numbers works fine
splashing text by sending "Y" key plus two numbers works fine

What fails:
Refreshing the title sequence by sending a single "T" to the window!

Global Const VK_0 = &H30
Global Const CHAR_0 = &H30
Global Const VK_K = &H4B
Global Const CHAR_K = &H6B 'lower k, DEC = 107
Global Const VK_T = &H54
Global Const CHAR_T = &H74 'lower t, DEC = 116
Global Const VK_Y = &H59
Global Const CHAR_Y = &H79 'lower y, DEC = 121
Global Const VK_F7 = &H76
Global Const WM_KEYDOWN = &H100
Global Const WM_KEYUP = &H101
Global Const WM_CHAR = &H102

Public Sub MilkdropKeys(CodeChar As String, MessNum As Integer)
Dim Offset1, Offset2 As Integer

Select Case (CodeChar)
Case "t": 'title
** apiSendMessage MilkdropHandle, WM_KEYDOWN, VK_T, &HF01 **
apiSendMessage MilkdropHandle, WM_CHAR, CHAR_T, &HF01
apiSendMessage MilkdropHandle, WM_KEYUP, VK_T, &HC00F01
Case "y": 'message
apiSendMessage MilkdropHandle, WM_KEYDOWN, VK_Y, &HF01
apiSendMessage MilkdropHandle, WM_CHAR, CHAR_Y, &HF01
apiSendMessage MilkdropHandle, WM_KEYUP, VK_Y, &HC00F01
Case "k": 'sprite
apiSendMessage MilkdropHandle, WM_KEYDOWN, VK_K, &HF01
apiSendMessage MilkdropHandle, WM_CHAR, CHAR_K, &HF01
apiSendMessage MilkdropHandle, WM_KEYUP, VK_K, &HC00F01
Case "7": 'Fn7 reload ini's
apiSendMessage MilkdropHandle, WM_KEYDOWN, VK_F7, &HF01
apiSendMessage MilkdropHandle, WM_KEYUP, VK_F7, &HC00F01
'Case "T": 'kill title - add later
'Case "Y": 'kill messages
'Case "K": 'kill sprite
End Select

If (CodeChar = "y") Or (CodeChar = "k") Then 'send a custom message or sprite to MilkDrop2
If (MessNum >= 0) And (Mess < 100) Then
Offset1 = Int(MessNum / 10)
Offset2 = MessNum - Offset1 * 10

apiSendMessage MilkdropHandle, WM_KEYDOWN, VK_0 + Offset1, &HF01
apiSendMessage MilkdropHandle, WM_CHAR, CHAR_0 + Offset1, &HF01
apiSendMessage MilkdropHandle, WM_KEYUP, VK_0 + Offset1, &HC00F01

apiSendMessage MilkdropHandle, WM_KEYDOWN, VK_0 + Offset2, &HF01
apiSendMessage MilkdropHandle, WM_CHAR, CHAR_0 + Offset2, &HF01
apiSendMessage MilkdropHandle, WM_KEYUP, VK_0 + Offset2, &HC00F01
End If
End If

End Sub

Any ideas would be awesome. Plan to share code here when complete.

Worth noting: the code definitely reaches the correct WM_ code for sending the "T" key. What's REALLY odd to me, is that the code reaches the correct lines (labelled ** above) at the right time with a debug pause point. If at that point I hit continue/run - still fails to show title. BUT, if I step through the code line by line, then the title pops up!
dickchuck is offline   Reply With Quote