我如何打开左右两侧的两扇窗户,喜欢胜利+←/→.



我想打开左右两侧的两个窗口,这是我的代码:

using System;
using System.Runtime.InteropServices;
namespace OpenWindows
{
class Program
{
static void Main(string[] args)
{
ShellExecute((IntPtr)0, "open", "ms-settings:storagesense", "", null, 9);
ShellExecute((IntPtr)0, "open", "msedge.exe", "www.google.com", null, 9);
}
[DllImport("Shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr ShellExecute(IntPtr hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);
}
}

此代码可以打开两个窗口:设置存储和边缘。我想要左右两侧的两个窗户,喜欢胜利+←/→:

单击此处打开图像

感谢@Thescion、@phuzi、@Thesciion、@DanielBrughera回答我的问题。

我搜索谷歌和编码,这个代码是工作,错误不完美,如果你有另一个程序,请告诉我。

using System;
using System.Diagnostics;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace AllTest.OpenWindows
{
class OpenWindows
{
static void Main(string[] args)
{
int width = Screen.PrimaryScreen.WorkingArea.Width;
int height = Screen.PrimaryScreen.WorkingArea.Height;
string arg = String.Format("--app="data:text/html,<html><body><script>window.resizeTo({0},{0});window.moveTo(0,0);window.location='http://www.google.com';</script></body></html>"", width / 2, height);
ShellExecute((IntPtr)0, "open", "msedge", arg, null, 9);
ShellExecute((IntPtr)0, "open", "ms-settings:storagesense", "", null, 9);
var res = Process.GetProcessesByName("ApplicationFrameHost");
IntPtr mhandle = res[0].MainWindowHandle;
MoveWindow(mhandle, width / 2, 0, width / 2, height, true);
}
[DllImport("Shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr ShellExecute(IntPtr hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);
[DllImport("User32.dll")]
static extern bool MoveWindow(IntPtr handle, int x, int y, int width, int height, bool redraw);
}
}

最新更新