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
Old 12th April 2011, 00:15   #2
Junior Member
Join Date: Apr 2011
Posts: 1
That does seem pretty odd! Do you know if any other keys have the same problem of not working right??

I found your message as I'm looking for something similar to what you're making. I'm trying to find a way, vbscript or something, to allow me to randomly send K+## keys to MilkDrop2 so that I can just leave Milkdrop running at it'd add images for me ;-)

If you'd like me to test any code to see if I get the same problems of you, I'm more than happy to help!
Minxster is offline   Reply With Quote
Old 18th April 2011, 07:48   #3
Junior Member
Join Date: Feb 2011
Location: Australia
Posts: 40
Maybe try AutoHotKey. I'm currently using it to send the K## commands directly to the MilkDrop window (regardless of which window is in focus).

It's quite a powerful piece of software, I just had a quick look at some of the documentation and I'd say you would be able to script something that sends your commands in order or random order and at random or specific time intervals.
LlamaLlamaLamp is offline   Reply With Quote
Old 1st July 2013, 14:56   #4
Junior Member
Join Date: Jan 2011
Posts: 17
bailed on this approach after Souce released

see my other link for copy of recompiled MilkDrop version and scripting file format.
dickchuck is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Visualizations > MilkDrop > MilkDrop Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump