我正在尝试使用youtube嵌入式播放器(轴激波闪光灯),并利用它制作一个很好的程序。
问题是,我正在尝试实现一个按钮,该按钮将重播/下一个/之前的当前视频。
我的自动取款机是:
private void btReplay_Click(object sender, EventArgs e)
{
if (!youtubePlayer.Focus())
{
youtubePlayer.Focus();
SendKeys.Send("0");
}
else
{
SendKeys.Send("0");
}
this.BringToFront();
}按“0”键可以从一开始就重放视频。只有它还会使窗体在其他打开的窗口之间消失。
如你所见,我试过使用带菌前,但它不起作用。
有什么想法吗?
另外,如果有人对此有任何经验,我也想发挥如何启用自动播放下一个视频时,使用‘结束’键。我知道autoplay=1函数,但在按END键时,它似乎不起作用。
编辑:使用WinForms
发布于 2014-03-24 15:25:54
this.BringToFront();
this.TopMost = true;为我工作,傻瓜,我没想过这个。
发布于 2014-02-18 10:35:42
您没有指定是使用winForms还是WPF。这个片段是给winforms的。
在这里,我给出了一个静态方法,它强制任何给定的形式出现在前面:
public static void bringWindowToFront(System.Windows.Forms.Form form)
{
uint foreThread = GetWindowThreadProcessId(GetForegroundWindow(), System.IntPtr.Zero);
uint appThread = GetCurrentThreadId();
const uint SW_SHOW = 5;
if (foreThread != appThread)
{
AttachThreadInput(foreThread, appThread, true);
BringWindowToTop(form.Handle);
ShowWindow(form.Handle, SW_SHOW);
AttachThreadInput(foreThread, appThread, false);
}
else
{
BringWindowToTop(form.Handle);
ShowWindow(form.Handle, SW_SHOW);
}
form.Activate();
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool AttachThreadInput(uint idAttach, uint idAttachTo, bool fAttach);
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
private static extern bool BringWindowToTop(System.IntPtr hWnd);
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
public static extern uint GetCurrentThreadId();
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern System.IntPtr GetForegroundWindow();
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern uint GetWindowThreadProcessId(System.IntPtr hWnd, System.IntPtr ProcessId);
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool ShowWindow(System.IntPtr hWnd, uint nCmdShow);https://stackoverflow.com/questions/21850723
复制相似问题