|
-
Oct 20th, 2006, 04:36 PM
#1
Thread Starter
Fanatic Member
-
Oct 20th, 2006, 06:11 PM
#2
Re: 'Talk' with Windows Media Player *please help*
Go to the MS site and search for "Windows Media Player SDK". It has a few samples in it. (It's more complex than you think!)
-
Oct 20th, 2006, 06:21 PM
#3
Re: 'Talk' with Windows Media Player *please help*
You might be off by using the SendKeys function.
But first you would need to find the WMP hwnd and then so it has the focus and have it simulate the pressing of PLAY/STOP.
Try this link on SendKeys function.
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Oct 20th, 2006, 07:24 PM
#4
Thread Starter
Fanatic Member
Re: 'Talk' with Windows Media Player *please help*
 Originally Posted by schoolbusdriver
Go to the MS site and search for "Windows Media Player SDK". It has a few samples in it. (It's more complex than you think!)
Thanx, looks promising, but haven't gotten around to installing it yet!
Visit here to learn to make the VB interface fit you!.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison 
"The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge
-
Oct 28th, 2006, 01:46 PM
#5
Thread Starter
Fanatic Member
Re: 'Talk' with Windows Media Player *please help*
Ok, this installer is just totally effed over! It hasn't once out of about 5 attempts successfully made it even to the halfway point without errors. I've tried the sendkeys idea, but my problem is sending the keys, since the program will be as good as minimized, and sendkeys can't access a minimized window, even with AppActivate. It just don't work! It just crashes, since WMP is in the system tray. Anyone know how I can do this??? Pls!
Last edited by ididntdoit; Oct 28th, 2006 at 01:54 PM.
Visit here to learn to make the VB interface fit you!.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison 
"The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge
-
Oct 28th, 2006, 02:14 PM
#6
Addicted Member
Re: 'Talk' with Windows Media Player *please help*
What about sending messages to it , watch it with Microsoft Spy you may get the needed msg for this.
-
Oct 28th, 2006, 02:16 PM
#7
PowerPoster
Re: 'Talk' with Windows Media Player *please help*
Do you have to control the external WMP or can you have WMP in your own program as a plugin?
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Oct 28th, 2006, 04:56 PM
#8
Thread Starter
Fanatic Member
Re: 'Talk' with Windows Media Player *please help*
 Originally Posted by msayed2004
What about sending messages to it , watch it with Microsoft Spy you may get the needed msg for this.
This is getting somewhere! Good idea *reputates*
These were the given messages when I clicked the button I want to mimic, now how in the heck do I use them in VB?
WM LBUTTONUP fwKeys:0000 xPos:1519 yPos:878
WM_CAPTURECHANGED hwndNewCapture:00000000[wParam:00000000 lParam:00000000]
WM_CAPTURECHANGED lResult:00000000
WM_MENUSELECT uItem:0 fuFlags:FFFF(menu was closed) hmenu:00000000[wParam:FFFF0000 lParam:0000]
WM_MENUSELECT lResult:00000000
message:0x8064[User-defined:WM_USER+31844]lRsult:00000000
WM_NCACTIVATE fActive:False[wParam:00000000 lParam:00000000]
WM_NCACTIVATE fDeactivateOK:True[Result:00000001]
WM_ACTIVATE fActive:WA_INACTIVE fMinimized:False hwndPrevious null)[wParam:00000000 lParam:00000000]
WM_ACTIVATE lResult:00000000
WM_ACTIVATEAPP fActive:False dwThreadID:00000C74 [wParam:00000000 lParam00000C74]
WM_ACTIVATEAPP lResult:00000000
WM_KILLFOCUS hwndGetFocus null) [wParam:00000000 lParam:00000000]
WM_KILLFOCUS lResult:00000000
WM_DEVICECHANGE Event:0007 dwData:00000000 [wParam:00000007 lParam:00000000]
Can you please help me??? This was a great idea, especially if you can help me make it work!
Visit here to learn to make the VB interface fit you!.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison 
"The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge
-
Oct 28th, 2006, 07:29 PM
#9
Addicted Member
Re: 'Talk' with Windows Media Player *please help*
VB Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Const MEDIA_STOP = 13
Const WM_APPCOMMAND = &H319
Private Sub Command1_Click()
Dim WinWnd As Long
WinWnd = FindWindow(vbNullString, "Windows Media Player")
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
SendMessage WinWnd, WM_APPCOMMAND, 0&, ByVal (MEDIA_STOP * &H10000)
End Sub
Edit : This works for me , for Media Player 9
-
Oct 28th, 2006, 07:38 PM
#10
Thread Starter
Fanatic Member
-
Oct 28th, 2006, 07:52 PM
#11
Addicted Member
Re: 'Talk' with Windows Media Player *please help*
I don't know except these :
VB Code:
Const MEDIA_NEXTTRACK = 11
Const MEDIA_PREVIOUSTRACK = 12
Const MEDIA_STOP = 13
Const MEDIA_PLAY_PAUSE = 14
Search , you may find more. , mark this as resolved if it is !!!
-
Oct 28th, 2006, 07:54 PM
#12
Addicted Member
Re: 'Talk' with Windows Media Player *please help*
BTW , thanks for your cookies
-
Oct 28th, 2006, 08:20 PM
#13
Thread Starter
Fanatic Member
Re: 'Talk' with Windows Media Player *please help*
Visit here to learn to make the VB interface fit you!.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison 
"The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge
-
Oct 28th, 2006, 08:37 PM
#14
Addicted Member
Re: [Resolved - thanx to msayed2004]'Talk' with Windows Media Player *please help*
Chocolate brownie , WOW , YES YES YES
-
Oct 28th, 2006, 08:42 PM
#15
Thread Starter
Fanatic Member
Re: [Resolved - thanx to msayed2004]'Talk' with Windows Media Player *please help*
 Originally Posted by msayed2004
Chocolate brownie , WOW , YES YES YES
kk, *gives you a brownie*
Here, I just whipped this up before I go to bed (it's already 10 to 10 my time)
VB Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Const MEDIA_STOP = 13
Const WM_APPCOMMAND = &H319
Const MEDIA_NEXTTRACK = 11
Const MEDIA_PREVIOUSTRACK = 12
Const MEDIA_PLAY_PAUSE = 14
Dim QwertY As Integer
Dim blFlg As Boolean
Dim WinWnd As Long
Private Sub Timer1_Timer()
If (GetAsyncKeyState(162) = -32768) And (GetAsyncKeyState(160) = -32768) And (GetAsyncKeyState(81) = -32768) And Not blFlg Then
WinWnd = FindWindow(vbNullString, "Windows Media Player")
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
SendMessage WinWnd, WM_APPCOMMAND, 0&, ByVal (MEDIA_PLAY_PAUSE * &H10000)
Timer2.Enabled = True
blFlg = True
End If
If (GetAsyncKeyState(162) = -32768) And (GetAsyncKeyState(160) = -32768) And (GetAsyncKeyState(87) = -32768) And Not blFlg Then
WinWnd = FindWindow(vbNullString, "Windows Media Player")
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
SendMessage WinWnd, WM_APPCOMMAND, 0&, ByVal (MEDIA_STOP * &H10000)
Timer2.Enabled = True
blFlg = True
End If
If (GetAsyncKeyState(162) = -32768) And (GetAsyncKeyState(160) = -32768) And (GetAsyncKeyState(83) = -32768) And Not blFlg Then
WinWnd = FindWindow(vbNullString, "Windows Media Player")
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
SendMessage WinWnd, WM_APPCOMMAND, 0&, ByVal (MEDIA_NEXTTRACK * &H10000)
Timer2.Enabled = True
blFlg = True
End If
If (GetAsyncKeyState(162) = -32768) And (GetAsyncKeyState(160) = -32768) And (GetAsyncKeyState(65) = -32768) And Not blFlg Then
WinWnd = FindWindow(vbNullString, "Windows Media Player")
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
SendMessage WinWnd, WM_APPCOMMAND, 0&, ByVal (MEDIA_PREVIOUSTRACK * &H10000)
Timer2.Enabled = True
blFlg = True
End If
End Sub
Private Sub Timer2_Timer()
blFlg = False
Timer2.Enabled = False
End Sub
Timer1 is set at 1ms intervals, timer2 is at 200ms intervals (w/o this, you can't push the button on and off fast enough to avoid it being caught two - ten times!). I'll just run this in the background invisibly, and voila, a WMP tray control with hot-keys (I know there is a WMP tray control, but I need one w/ hot-keys!) Thanx again! (note I gave full credit to you in the thread title )
*eats a brownie my self*
*LOLs with joy*
*goes to bed*
Visit here to learn to make the VB interface fit you!.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison 
"The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge
-
Oct 28th, 2006, 09:37 PM
#16
Addicted Member
Re: [Resolved - thanx to msayed2004]'Talk' with Windows Media Player *please help*
You can register hot keys by this (better than GetAsyncKeyState which may be stopped by any anti-spyware) :
VB Code:
Private Const MOD_ALT = &H1
Private Const MOD_CONTROL = &H2
Private Const MOD_SHIFT = &H4
Private Const PM_REMOVE = &H1
Private Const WM_HOTKEY = &H312
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type Msg
hWnd As Long
Message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Private Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long) As Long
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Declare Function WaitMessage Lib "user32" () As Long
Private bCancel As Boolean
Private Sub ProcessMessages()
Dim Message As Msg
'loop until bCancel is set to True
Do While Not bCancel
'wait for a message
WaitMessage
'check if it's a HOTKEY-message
If PeekMessage(Message, Me.hWnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then
'minimize the form
WindowState = vbMinimized
End If
'let the operating system process other events
DoEvents
Loop
End Sub
Private Sub Form_Load()
'KPD-Team 2000
'URL: [url]http://www.allapi.net/[/url]
Dim ret As Long
bCancel = False
'register the Ctrl-F hotkey
ret = RegisterHotKey(Me.hWnd, &HBFFF&, MOD_CONTROL, vbKeyF)
'show some information
Me.AutoRedraw = True
Me.Print "Press CTRL-F to minimize this form"
'show the form and
Show
'process the Hotkey messages
ProcessMessages
End Sub
Private Sub Form_Unload(Cancel As Integer)
bCancel = True
'unregister hotkey
Call UnregisterHotKey(Me.hWnd, &HBFFF&)
End Sub
Copied from API Guide
-
Oct 28th, 2006, 10:25 PM
#17
Thread Starter
Fanatic Member
Re: [Resolved - thanx to msayed2004]'Talk' with Windows Media Player *please help*
Whatev
This way is easier and safer (that code will crash badly if not closed right).
I'm off 2 bed, but I've made a quick sample program out of this whole thing and I'll post it tomorrow. Thanx again for all your help!
Visit here to learn to make the VB interface fit you!.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison 
"The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge
-
Oct 29th, 2006, 01:42 PM
#18
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|