教你如何自定义win8.1屏幕的大小
今天 教你如何自定义win8.1屏幕的大小。我听说Start Charming这个工具可以使开始屏幕窗体化,这让我非常的好奇;于是我稍稍研究了一下(只是使用IDA,OD,ILSpy,Spy++)……终于自己就可以写出自定义开始屏幕的大小的代码了,先上代码(C#,我一般不写注释,但为了照顾小白没办法)
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Drawing;
namespace StartScreenToStartMenu
{
class Program
{
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "MoveWindow")]
public static extern int MoveWindow(IntPtr hwnd, int x, int y, int nWidth, int nHeight, bool bRepaint);
static void Main(string[] args)
{
Rectangle rect =Screen.PrimaryScreen.Bounds;
IntPtr childHwnd = FindWindow("ImmersiveLauncher", null);
if (childHwnd != IntPtr.Zero)
{
int Width = 1024; //自定义开始屏幕的宽度
int Height = 768; //自定义开始屏幕的高度
MoveWindow(childHwnd, 0, rect.Height - Height - 40, Width, Height, true);
//MoveWindow(childHwnd, 0, 0, rect.Width, rect.Height, true); //如果想恢复原样的话把这行代码复制到上一行就OK了
}
else
{
Console.WriteLine("没有找到窗口");
}
}
}
}
复制代码
运行效果
PS:本程序如果explorer进程结束后得再运行一次才能保持你要的效果, 我也试过要实现ModernMix的效果,但是因为Metro应用后面总有个讨厌的窗体(以Metro开视屏主要颜色为背景的未知窗口),就无法实现了;抱歉;如果可以的话,希望在我的基础上更进一步 Metro应用窗体都是统一的,窗体类名都叫Windows.UI.Core.CoreWindow。
欢迎来到这里!