如何将我的WPF应用程序带到桌面的前端?到目前为止,我已经尝试过:
SwitchToThisWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle, true);
SetWindowPos(new WindowInteropHelper(Application.Current.MainWindow).Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
SetForegroundWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle);
Run Code Online (Sandbox Code Playgroud)
这些都没有Marshal.GetLastWin32Error()成功(说这些操作成功完成,每个定义的P/Invoke属性都有SetLastError=true).
如果我创建一个新的空白WPF应用程序,并SwitchToThisWindow使用计时器调用,它完全按预期工作,所以我不知道为什么它不能在我的原始情况下工作.
编辑:我正在与全球热键一起做这个.