mpv.net attaches now to the parent terminal

This commit is contained in:
Frank Skare
2019-07-26 03:22:17 +02:00
parent 2068bfb6fa
commit b47d3c34f2
6 changed files with 24 additions and 11 deletions

View File

@@ -17,6 +17,10 @@
to fail if it was waiting for a drive to wakeup
- a new JavaScript was included to show the playlist with a smaller font size,
the script is located at startup/scripts
- mpv.net attaches now to the parent terminal, when started from
a PowerShell terminal using the --terminal switch mpvnet gives
status messages on the console and debug messages useful to write
JavaScript and Lua scripts
### 4.7.7

View File

@@ -64,7 +64,9 @@ namespace mpvnet
return;
}
Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
Application.Run(new MainForm());
Native.FreeConsole();
mutex.Dispose();
}
catch (Exception ex)

View File

@@ -6,6 +6,12 @@ namespace mpvnet
{
public class Native
{
[DllImport("kernel32.dll")]
public static extern bool AttachConsole(int dwProcessId);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool FreeConsole();
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);

View File

@@ -137,7 +137,7 @@
Ctrl+t set ontop yes #menu: View > On Top > Enable
Ctrl+T set ontop no #menu: View > On Top > Disable
b cycle border #menu: View > Toggle Border
i script-message mpv.net show-info #menu: View > File Info
i script-message mpv.net show-info #menu: View > File/Stream Info
t script-binding stats/display-stats #menu: View > Show Statistics
T script-binding stats/display-stats-toggle #menu: View > Toggle Statistics
Del script-binding osc/visibility #menu: View > Toggle OSC Visibility
@@ -190,4 +190,5 @@
Ctrl+Wheel_Up no-osd seek 7
Ctrl+Wheel_Down no-osd seek -7
MBTN_Left_DBL cycle fullscreen
KP_Enter cycle fullscreen
KP_Enter cycle fullscreen
MBTN_Left ignore

View File

@@ -598,7 +598,7 @@ namespace mpvnet
foreach (string url in App.UrlWhitelist)
{
if (clipboard.Contains("://") && ! clipboard.Contains("\n") &&
! clipboard.Contains(" ") && clipboard.Contains(url.ToLower()) &&
! clipboard.Contains(" ") && clipboard.Contains(url.ToLower().Trim()) &&
RegHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible)
{
RegHelp.SetObject(App.RegPath, "LastURL", clipboard);

View File

@@ -554,14 +554,6 @@ namespace mpvnet
}
}
Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control));
if (files.Count == 0 || files[0].Contains("://"))
{
VideoSizeAutoResetEvent.Set();
VideoSizeChanged?.Invoke();
}
foreach (string i in args)
{
if (i.StartsWith("--"))
@@ -583,6 +575,14 @@ namespace mpvnet
}
}
}
Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control));
if (files.Count == 0 || files[0].Contains("://"))
{
VideoSizeAutoResetEvent.Set();
VideoSizeChanged?.Invoke();
}
}
public static DateTime LastLoad;