Launch Media Player & Position It

cav609

New Member
Joined
Nov 7, 2005
Messages
13
Hi

I want to launch Windows Media Player from an Excel macro; play a web stream and re-position the player on my desktop. I can launch the player and get the stream to play, but how do I re-position the player to specific co-ordinates on my desktop?? Code so far:

-------------------------------------------------------------------------------
Sub WebOpenBloombergTV()
Dim WMPID
WMPID = Shell("C:\Program Files\Windows Media Player\wmplayer.exe http://www.bloomberg.com/streams/video/LiveUK_nb.asxx", 1)
AppActivate WMPID
End Sub
-------------------------------------------------------------------------------

Any help on the re-positioning of the player more than gratefully accepted!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Here is some code. You might also be interested in the link to some code I have written for Media Player Audio.
Code:
'=======================================================
'- API - FIND WINDOW
Private Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
'--------------------------------------------------------
'- API - SET WINDOW POSITION
Private Declare Function SetWindowPos Lib "user32" ( _
    ByVal hWnd As Long, _
    ByVal hWndInsertAfter As Long, _
    ByVal x As Long, _
    ByVal y As Long, _
    ByVal cx As Long, _
    ByVal cy As Long, _
    ByVal wFlags As Long) As Long
'-------------------------------------------------------
'- possible positions relative to other windows
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_NOZORDER = &H4
Private Const WM_CLOSE = &H10
Dim hWnd As Long  ' window handle

'======================================================
'- OPEN CALCULATOR AND POSITION
'======================================================
Sub Open_Calculator()
    Dim Wtop As Long
    Dim Wleft As Long
    Dim Wwidth As Long
    Dim Wheight As Long
    '--------------------------------------------------
    '- required position & size
    Wtop = 0
    Wleft = 0
    Wwidth = 280
    Wheight = 280
    '--------------------------------------------------
    '- get window handle
    hWnd = FindWindow(vbNullString, "Calculator")
    '--------------------------------------------------
    '- open application if necessary
    If hWnd = 0 Then
        Shell "C:\Calc.exe", 1
        hWnd = FindWindow(vbNullString, "Calculator")
    End If
    '--------------------------------------------------
    '- position window
    SetWindowPos hWnd, _
        HWND_TOP, _
        Wtop, Wleft, Wwidth, Wheight, _
        SWP_SHOWWINDOW
End Sub

http://www.mrexcel.com/board2/viewtopic.php?p=835993#835993
 
Upvote 0

Forum statistics

Threads
1,203,620
Messages
6,056,330
Members
444,861
Latest member
B4you_Andrea

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top