The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: sinsi on November 06, 2006, 11:26:33 AM

Title: Interacting with Media Player
Post by: sinsi on November 06, 2006, 11:26:33 AM
What I would like to do is:
  Start playing a playlist in Media Player
  Minimise it
  Have a way (from any prog of mine) of previous/next song

I am thinking FindWindow to get Media Player's hwnd and using SendMessage to send
a keystroke. The trouble is how do I send ctrl-b or ctrl-f? For that matter, how can I send
a window a key?

I don't want to have to go into the Media Player SDK for such a simple(?) thing... ::)
Title: Re: Interacting with Media Player
Post by: ragdog on November 06, 2006, 11:56:45 AM
hi

What are you after? the send apis to play,stop,back...???
Title: Re: Interacting with Media Player
Post by: sinsi on November 06, 2006, 12:06:05 PM
G'day ragdog, all I want is back/forward...that's it, since it's on repeat. Is there an API for it?
Title: Re: Interacting with Media Player
Post by: ragdog on November 06, 2006, 12:23:12 PM
use this http://www.codeproject.com/csharp/wmp_pinvoke.asp
:U
Title: Re: Interacting with Media Player
Post by: ragdog on November 06, 2006, 12:32:23 PM
18808 play
18809 stop
18810 back
18811 forward
Title: Re: Interacting with Media Player
Post by: sinsi on November 06, 2006, 12:41:39 PM
ragdog, that link seems perfect, bewdy mate!  :U

[a bit later]Just saw your latest post, adds to my understanding (and the value of the link). Champion!  :clap:
Title: Re: Interacting with Media Player
Post by: ragdog on November 06, 2006, 12:49:03 PM
:bg
if your project finsish post the program? :bg
Title: Re: Interacting with Media Player
Post by: sinsi on November 06, 2006, 12:53:35 PM
heh heh if it ever gets beyond the "it works on my machine" stage  :bg
Title: Re: Interacting with Media Player
Post by: ragdog on November 06, 2006, 01:21:29 PM
not the source the exe
Title: Re: Interacting with Media Player
Post by: ragdog on November 06, 2006, 01:24:44 PM
i have self written with winamp :U
Title: Re: Interacting with Media Player
Post by: sinsi on November 06, 2006, 02:58:47 PM
Here is some quick, dirty and drunk code...but it works on my machine  :bg which is xp home sp2 and mp11 beta.
This is just to see if it works, obviously a slicker gui would help  :bdg

Edit: added the exe to the zip

[attachment deleted by admin]
Title: Re: Interacting with Media Player
Post by: ragdog on November 06, 2006, 03:04:35 PM
 :bg thsi work on my maschine :bdg

here is my source

[attachment deleted by admin]
Title: Re: Interacting with Media Player
Post by: sinsi on November 08, 2006, 01:16:35 PM
This is the most brilliant thing, sending a menu-click to a window...
You, ragdog, are a BLOODY LEGEND.

Now, I'll put an app on a timer and use GetAsyncKeyState to control it (just like a game trainer (oops! shh)).
Title: Re: Interacting with Media Player
Post by: ragdog on November 08, 2006, 04:11:53 PM
hi sinsi :toothy

this work´s too with GetAsyncKeyState! :8)

have you powerdvd commands?

best regards
ragdog
Title: Re: Interacting with Media Player
Post by: sinsi on March 04, 2009, 07:47:58 AM
Old topic, but new info: the same code works in win7beta/mp12 (although fast-forward has changed) but if I run a game as admin (old games, fair enough but new *vista* compatible games? cmon) the keys don't work...unless I run my program as admin too. I've seen stuff about raising privileges via the good old manifest, anyone got one that actually works?

ETA: lay off the beer, sinsi. Topic: Run Elevated (http://www.masm32.com/board/index.php?topic=9422.msg68586#msg68586)
The sad thing is that I posted in that thread...
Title: Re: Interacting with Media Player
Post by: sinsi on June 24, 2010, 08:48:04 AM
Revisiting old code, guess who discovered VK_MEDIA_NEXT_TRACK? Much better way of controlling media player and no need for admin privileges.
Sorry about the old thread but I seem to have an affinity for it...
Title: Re: Interacting with Media Player
Post by: dedndave on June 24, 2010, 10:49:12 AM
Quoteinclude \asm\win32.inc

???
i tried replacing it with \masm32\include\masm32rt.inc....
MPctrl.asm(6) : error A2008: syntax error : input_dn
MPctrl.asm(7) : error A2008: syntax error : input_up
MPctrl.asm(32) : error A2006: undefined symbol : INPUT
Title: Re: Interacting with Media Player
Post by: sinsi on June 24, 2010, 10:57:49 AM
Sorry, I forgot that windows.inc doesn't seem to have the INPUT structure.

KEYBDINPUT struct
wVk         dw ?
wScan       dw ?
dwFlags     dd ?
time        dd ?
dwExtraInfo dd ?
KEYBDINPUT ends

MOUSEINPUT struct
_dx         dd ?
_dy         dd ?
mouseData   dd ?
dwFlags     dd ?
time        dd ?
dwExtraInfo dd ?
MOUSEINPUT ends

HARDWAREINPUT struct
uMsg    dd ?
wParamL dw ?
wParamH dw ?
HARDWAREINPUT ends

INPUT struct
_type dd ?
union
  ki KEYBDINPUT <>
  mi MOUSEINPUT <>
  hi HARDWAREINPUT <>
ends
INPUT ends


Also, I use ebx to call an API, my linking happens via _imp__API, just replace "call ebx" with "call API".
What can I say, it's a hack, but 2 of my long-suffering guinea pigs have been using it for a few years now.