INTERACT FORUM
Windows => Plug-in Development => Topic started by: raym on September 19, 2009, 11:09:43 pm
-
Hi. I'm trying to write a script to query the current "mode" MC is in (ie, Standard View, Display View, Theater View etc) but I can't find a suitable automation call to do it.
Anyone know if this can be done?
Cheers.
-
I don't know specifically how to do what you are asking, but the info below might be useful?
I long ago reached the limit of what the official plug-in API can do - but I discovered that MC stores a lot of "live" and persisted settings in the registry.
HKEY_CURRENT_USER\Software\JRiver\Media Center 13\Properties
HKEY_CURRENT_USER\Software\JRiver\Media Center 13\Player Core
HKEY_CURRENT_USER\Software\JRiver\Media Center 13\Playback Engine
Reading and writing to these gets you some additional tools to integrate with MC.
You might find the "View Mode" is in their somewhere. (Caveat: All of this is undocumented, and presumably subject to changing on JR's whim.)
-
Hmm, I found a reg key called "Last UI Mode" under HKEY_CURRENT_USER\Software\JRiver\Media Center 13\Properties but this value is only updated when the app is closed rather than between UI mode transitions. So close yet so far....
I'll keep searching but it's not looking good. Thanks for the suggestion though.
-
JRiver (Matt?) - would it be possible please to update this reg key on each view mode change? Extending the API to query the current view mode would be the ultimate but I'm assuming the reg change would be simpler to implement and serve me just as well.
Thanks in advance.
-
i would also like this very much, and i think the api is the right place.
an event when switching mode? where string3 tells to which mode the switch is made?
:)
gab
-
an event when switching mode? where string3 tells to which mode the switch is made?
Hmmmm, I never considered this. By event, do you mean one of the MCC_NOTIFY notifications? Would the existing MCC_NOTIFY_VIEW_CHANGED (34001) do the trick? Sorry, I'm not too sure if I'm on the right track with this. If this worked, how would I use it?
-
guess not, i just tried, but like these events: http://wiki.jrmediacenter.com/index.php/Media_Center_Automation#Event_Handling
and when i switch to thv, there is no event fired what so ever. but ofcource there might be a way to catch those mcc notifications. i have no idea, but when you find it, it would be great to know.
:)
gab
-
did you find a solution?
ive been trying to use the findwindow and findwindowex functions, but without succes.
does someone else have a suggestion?
:)
gab
-
did you find a solution?
Sorry for the late reply. Unfortunately, no. This is still something I'm trying to resolve.
JRiver, any chance of adding this capability please? Even the registry idea discussed above would be fine if it's easier to implement.
Thanks.
-
*BUMP*
JRiver, any chance of adding this capability please? Even the registry idea discussed above would be fine if it's easier to implement.
Maybe for MC15 please? .....
-
*BUMP*
Maybe for MC15 please? .....
Raym,
while we're waiting for changes to the plugin API (!) here's a method you can use, I believe, to detect if the display view and theater view windows are active.
This is similar to what Gappie is proposing above. The "WindowEnumProc" function will iterate through all child views of the JRiver main wndow and "Display", "Theater[]" can thus be used to detect the mode.
Cumbersome, yes...
public delegate bool WindowEnumDelegate(IntPtr hwnd, int lParam);
// declare the API function to enumerate child windows
[DllImport("user32.dll")]
public static extern int EnumChildWindows(IntPtr hwnd, WindowEnumDelegate del, int lParam);
[DllImport("user32.dll")]
static extern int GetForegroundWindow();
[DllImport("user32.dll")]
public static extern int GetWindowText(IntPtr hwnd, StringBuilder bld, int size);
[DllImport("user32.dll")]
public static extern int GetWindowRect(IntPtr hwnd, ref Rectangle lpRect);
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
//[DllImport("user32.dll")]
Graphics g = null;
private void timer1_Tick(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder (256);
IntPtr handle = (IntPtr) mcRef.GetWindowHandle();
// instantiate the delegate
WindowEnumDelegate del
= new WindowEnumDelegate(WindowEnumProc);
// call the win32 function
Debug.WriteLine("-----------------------------------------");
EnumChildWindows(handle, del, 0);
}
static IntPtr hwndDisplay;
public static bool WindowEnumProc(IntPtr hwnd, int lParam)
{
// get the text from the window
StringBuilder bld = new StringBuilder(256);
GetWindowText(hwnd, bld, 256);
string text = bld.ToString();
if (text.Length > 0)
if (text == "Display")
//if (text == "JRiver Display Window")
hwndDisplay = hwnd;
return true;
}
-
Thanks Raldo. This looks a little beyond me (I'm more of your "coder by example" kind of guy). I'll take a closer look at it tonight though.
-
Thanks Raldo. This looks a little beyond me (I'm more of your "coder by example" kind of guy). I'll take a closer look at it tonight though.
Well, it's a code example, so go for it :)!
-
Not sure if this helps, but I use the following to determine if THV has focus:
; Look for the Theater View or Display View using Visible Text Keyword
ifWinExist, ahK_Class MJFrame, Display
{
WinWaitNotActive ; Wait until MC loses focus
ifWinNotExist, ahk_class JRiver Menu Class ; If it's not the THV menu, set focus back to MC
WinActivate
}
else
{
WinWait, ahK_Class MJFrame , Display ; If Display or THV not found, wait for it to show up
}
And I am using this to determine "Display" mode (I'm not sure this works in v15):
MC_IsInDisplayMode() {
Save := A_DetectHiddenText
nRet := -1
DetectHiddenText off
ifWinExist,, JRiver Report Control
nRet := False
Else
nRet := True
DetectHiddenText, %Save%
Return nRet
-
In 15.0.41 and later:
Changed: Added command MCC_QUERY_UI_MODE (32000) to allow querying the user interface mode of the program from a batch file.
Changed: MC15.exe is a console application so it's easier to use in batch files or with other scripting.
Changed: MC15.exe /MCC will exit the process with the result of the call. (so in a batch file, %ERRORLEVEL% will be the result after a call)
-
In 15.0.41 and later:
Changed: Added command MCC_QUERY_UI_MODE (32000) to allow querying the user interface mode of the program from a batch file.
Changed: MC15.exe is a console application so it's easier to use in batch files or with other scripting.
Changed: MC15.exe /MCC will exit the process with the result of the call. (so in a batch file, %ERRORLEVEL% will be the result after a call)
Matt, thanks again for adding this. I think build 42 removed the second two changes though right? I don't think it matters much (to me at least) and for anyone who's interested, here's a VERY simple batch script example to show how to use this new query to do something based on whether MC is in Theater View or not:
@ECHO OFF
REM --- Look for Theater View
MC15.exe /MCC 32000 | find "3"
IF %ERRORLEVEL% == 0 GOTO TheaterView
:NotTheaterView
REM --- Do something
EXIT
:TheaterView
REM --- Do something Theater View specific
EXIT
Thanks again!
-
thanks for adding this.. 8)