Execute Macro with batch script?

If you have a question or need help, this is the place to be.
Post Reply
jachin99
Experienced User
Posts: 472
Joined: Sat Feb 13, 2016 8:39 pm

Execute Macro with batch script?

Post by jachin99 » Fri Mar 16, 2018 9:00 pm

I need to change inputs on my reciever when I select a tile on my startmenu in WMC. The first way I have thought of to solve this problem is to have WMC execute a batch script when I select a tile. In order to do so, I would like to create a batch file that executes a particular macro (The macro to change my AVR Input) in EG. How would I do this.

jachin99
Experienced User
Posts: 472
Joined: Sat Feb 13, 2016 8:39 pm

Re: Execute Macro with batch script?

Post by jachin99 » Sat Mar 17, 2018 3:52 am

I guess the script itself just needs to generate a unique log event. If I could could even get the name of the bat to register in the log then it would be enough

User avatar
kgschlosser
Site Admin
Posts: 3914
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Execute Macro with batch script?

Post by kgschlosser » Sat Mar 17, 2018 6:13 am

WMC has a start menu?
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 472
Joined: Sat Feb 13, 2016 8:39 pm

Re: Execute Macro with batch script?

Post by jachin99 » Sat Mar 17, 2018 7:03 pm

Start menu, home screen, whatever it is you would want to call it. I think MS called it something similar. You can add or "register" assemblies, web links, Media Center Links (.mcl files), or executables on it. I'm basically looking to add a graphic that when selected, creates and EG event. Preferably without a box popping but I can live with that if absolutely neccessary. This kind of got me thinking, when a bat file executes, it flashes a window for just a second but when an exe executes, it doesnt do this, and just jumps straight to the program. What If someone built an exe that did nothing, would anything still be displayed on the screen? I would want something that doesn't steal remote or keyboard focus, and doesn't have any visible effect.

I found this on stack exchange: https://superuser.com/questions/381103/ ... es-nothing

You may use rundll32:
•No console window
•No side effects
•Just 44 KB
•No arguments required
•Works on every recent Windows version (XP, Vista, 7), and probably on every NT-based system.

That couldn't be too hard to build I think.

User avatar
kgschlosser
Site Admin
Posts: 3914
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Execute Macro with batch script?

Post by kgschlosser » Sat Mar 17, 2018 7:11 pm

I am trying to get a better understanding of exactly what you are trying to do. I am not familiar with the mcl files

From what I am gathering is you want an event to take place in EG when you run one of these mcl files from inside of Media Center. If i am correct then my next question is. what are you trying to run?
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 472
Joined: Sat Feb 13, 2016 8:39 pm

Re: Execute Macro with batch script?

Post by jachin99 » Sat Mar 17, 2018 7:25 pm

Sorry, its kind of hard to conceptualize if your not familiar with it i guess. Maybe I could do this better with an MCL file. If I'm not mistaken, you use media portal so Imagine selecting a tile on the media portal screen, and having it do nothing but generate an event in the EG log. I'm trying to do that with windows media center. I want my event to trigger actions that do things like change the input on my avr, turn on my xbox, etc. I want to make a graphic that when selected, turns on a given game system, and changes the stereo to the input for the game system using the MCE IR vista+ and yamaha network events plugins. I created a quick blank exe file but I still get a small flash. I'm wondering if the MCL file would behave differently but I'm not sure how much scripting mcl files allow for security reasons.

User avatar
kgschlosser
Site Admin
Posts: 3914
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Execute Macro with batch script?

Post by kgschlosser » Sat Mar 17, 2018 9:28 pm

let me do some digging and see if there is a way to capture events from WMC.
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 472
Joined: Sat Feb 13, 2016 8:39 pm

Re: Execute Macro with batch script?

Post by jachin99 » Sat Mar 17, 2018 9:46 pm

Ok, thanks. To give you a head start, it has a restful interface. If you cant find documentation let me know, and I'll get it for you. I can also provide a few projects that have used the web api. Look up NGRC for vista, and Remote potato. I know the code for remote potato is on a sourceforge/github type site somewhere.

User avatar
kgschlosser
Site Admin
Posts: 3914
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Execute Macro with batch script?

Post by kgschlosser » Sun Mar 18, 2018 6:51 am

NO NO. No need to use REST


I am going right for the meat and potatoes. Going to interface with the thing directly.

I am not yet finished. But here is what I have thus far

Code: Select all

import ctypes
import comtypes
from comtypes import GUID
from ctypes.wintypes import (
    HRESULT,
    POINTER,
    LPVOID,
)

from comtypes.automation import (
    IDispatch,
    VARIANT,
)
from comtypes._safearray import tagSAFEARRAY

DISPID = ctypes.c_long
REFIID = GUID
PVOID = LPVOID

SAFEARRAY = tagSAFEARRAY

IID_IMediaStatusSession = GUID(
    '{A70D81F2-C9D2-4053-AF0E-CDEA39BDD1AD}'
)
IID_IMediaStatusSink = GUID(
    '{075FC453-F236-41DA-B90D-9FBB8BBDC101}'
)


enum = ctypes.c_int

class MEDIASTATUSPROPERTYTAG(enum):
  MSPROPTAG_Unknown = 0
  MSPROPTAG_Mute = 0x1000
  MSPROPTAG_Play =0x1001
  MSPROPTAG_Pause = 0x1002
  MSPROPTAG_Stop = 0x1003
  MSPROPTAG_Shuffle = 0x1004
  MSPROPTAG_RepeatSet = 0x1005
  MSPROPTAG_Recording = 0x1006
  MSPROPTAG_Rewind1 = 0x1007
  MSPROPTAG_Rewind2 = 0x1008
  MSPROPTAG_Rewind3 = 0x1009
  MSPROPTAG_FF1 = 0x100A
  MSPROPTAG_FF2 = 0x100B
  MSPROPTAG_FF3 = 0x100C
  MSPROPTAG_Next = 0x100D
  MSPROPTAG_Prev = 0x100E
  MSPROPTAG_Error = 0x100F
  MSPROPTAG_Ejecting = 0x1010
  MSPROPTAG_MediaTypes= 0x2000,
  MSPROPTAG_DVD = 0x2001
  MSPROPTAG_CD = 0x2002
  MSPROPTAG_PVR = 0x2003
  MSPROPTAG_StreamingContentAudio = 0x2004
  MSPROPTAG_StreamingContentVideo = 0x2005
  MSPROPTAG_TVTuner = 0x2006
  MSPROPTAG_MediaTime = 0x2007
  MSPROPTAG_TrackNumber = 0x2008
  MSPROPTAG_TotalTracks = 0x2009
  MSPROPTAG_TrackDuration = 0x200A
  MSPROPTAG_TrackTime = 0x200B
  MSPROPTAG_TitleNumber = 0x200C
  MSPROPTAG_Volume = 0x200D
  MSPROPTAG_FS_Home = 0x200E
  MSPROPTAG_FS_TV = 0x200F
  MSPROPTAG_FS_DVD = 0x2010
  MSPROPTAG_FS_Guide = 0x2011
  MSPROPTAG_FS_Music = 0x2012
  MSPROPTAG_FS_Photos = 0x2013
  MSPROPTAG_FS_Videos = 0x2014
  MSPROPTAG_FS_RecordedShows = 0x2015
  MSPROPTAG_FS_Extensibility = 0x2016
  MSPROPTAG_FS_Unknown = 0x2017
  MSPROPTAG_MediaName = 0x2018
  MSPROPTAG_ArtistName = 0x2019
  MSPROPTAG_TrackName = 0x201A
  MSPROPTAG_Photos = 0x201B
  MSPROPTAG_CurrentPicture = 0x201C
  MSPROPTAG_TransitionTime = 0x201D
  MSPROPTAG_GuideLoaded = 0x201E
  MSPROPTAG_SlowMotion1 = 0x201F
  MSPROPTAG_SlowMotion2 = 0x2020
  MSPROPTAG_SlowMotion3 = 0x2021
  MSPROPTAG_NextFrame = 0x2022
  MSPROPTAG_PrevFrame = 0x2023
  MSPROPTAG_Radio = 0x2024
  MSPROPTAG_RadioFrequency = 0x2025
  MSPROPTAG_FS_Radio = 0x2026
  MSPROPTAG_Visualization = 0x2027
  MSPROPTAG_PhoneCall = 0x2028
  MSPROPTAG_CallingPartyNumber = 0x2029
  MSPROPTAG_CallingPartyName = 0x202A
  MSPROPTAG_ParentalAdvisoryRating = 0x202B
  MSPROPTAG_RequestForTuner = 0x202C
  MSPROPTAG_DiscWriter_Start = 0x202D
  MSPROPTAG_DiscWriter_SelectedFormat = 0x202E
  MSPROPTAG_DiscWriter_ProgressTimeChanged = 0x202F
  MSPROPTAG_DiscWriter_ProgressPercentageChanged = 0x2030
  MSPROPTAG_DiscWriter_Stop = 0x2031
  MSPROPTAG_MSASPrivateTags = 0xF000
  MSPROPTAG_Application = 0xF001

MEDIASTATUSTAGARRAY = MEDIASTATUSPROPERTYTAG
MEDIASTATUSPROPARRAY = VARIANT


class IMediaStatusSession(IDispatch):
    _case_insensitive_ = True
    _iid_ = IID_IMediaStatusSession
    _methods_ = (
        comtypes.COMMETHOD(
            [],
            HRESULT,
            'MediaStatusChange',
            (['in'], MEDIASTATUSTAGARRAY, 'Tags'),
            (['in'], MEDIASTATUSPROPARRAY, 'Properties'),
        ),
        comtypes.COMMETHOD(
            [],
            HRESULT,
            'Close'
        )
    )

class IMediaStatusSink(IDispatch):
    _case_insensitive_ = True
    _iid_ = IID_IMediaStatusSink
    _methods_ = (
        comtypes.COMMETHOD(
            [],
            HRESULT,
            'Initialize'
        ),
        comtypes.COMMETHOD(
            [],
            HRESULT,
            'CreateSession',
            (['out', 'retval'], POINTER(POINTER(IMediaStatusSession)), 'MediaStatusSession'),
        )
    )

comtypes.CoInitialize()

sink = comtypes.CoCreateInstance(
            GUID('{FCB0C2A3-9747-4c95-9d02-820AFEDEF13F}'),
            IMediaStatusSink,
            comtypes.CLSCTX_INPROC_SERVER
        )

media_status = sink.CreateSession()
print media_status.MediaStatusChange()
Now this does not work at the moment. I am trying to figure out why.
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 472
Joined: Sat Feb 13, 2016 8:39 pm

Re: Execute Macro with batch script?

Post by jachin99 » Sun Mar 18, 2018 6:03 pm

Thanks for the help!!

User avatar
kgschlosser
Site Admin
Posts: 3914
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Execute Macro with batch script?

Post by kgschlosser » Wed Mar 21, 2018 2:25 pm

this is quite the task to get this running. i am still messing around with it tho. just wanted to let ya know.
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 472
Joined: Sat Feb 13, 2016 8:39 pm

Re: Execute Macro with batch script?

Post by jachin99 » Wed Mar 21, 2018 2:40 pm

Thanks bud!! I got your PM, and I'll take a look at it soon, and let you know how it goes.

jachin99
Experienced User
Posts: 472
Joined: Sat Feb 13, 2016 8:39 pm

Re: Execute Macro with batch script?

Post by jachin99 » Thu Mar 29, 2018 11:02 pm

Hey there I'm just checking in on this. I can dig around some old forums if you let me know what your having trouble with.

User avatar
kgschlosser
Site Admin
Posts: 3914
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Execute Macro with batch script?

Post by kgschlosser » Fri Mar 30, 2018 3:04 am

The issue is that the notification system for WMC has been depreciated and the service is not used anymore.
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 472
Joined: Sat Feb 13, 2016 8:39 pm

Re: Execute Macro with batch script?

Post by jachin99 » Fri Mar 30, 2018 12:30 pm

Ok. I know there is a way to send popup dialog boxes to WMC, and I'm guessing in order to do so WMC itself has to recieve some type of notification that an event has occured from an addon, etc. I'm hosting two files for you that might be relevent to what your are trying to accomplish. File one is an addin called MCE popups that someone used as a kind of notification service that sent WMC popups when they recieved a call on skype. The skype APIs the plugins used are long gone but the pop service itself likely still works. File 2 is a growl addin. This required growl to be installed and working on the machine or it annoys the crap out of you but you might find something useful there. There are also quite a few other addons that send popups, and I can share those also. I hope this helps, and I have seen countless conversations where people find undocumented APIs, etc. to get things to work. If these don't solve your problem, can you tell me what deprecated method you are trying to use? From time to time, I hop on the web archive, and look around the old mediacenter sandbox, which was the WMC dev site for a long time. Here is a link to the files. https://drive.google.com/open?id=10Bb18 ... 4O3x6sQZlJ

Post Reply