如何使用相同的标题/标题调整两个窗口的大小?

时间:2018-02-12 16:53:37

标签: c#

我像这样开始几次.jar

    public void LaunchNewClient(string Username, string UUID, string AccessToken)
    {
        string JavaDir = @"C:\Program Files\Java\jdk1.8.0_161\bin\javaw.exe";//GetJavaInstallationDir();
        string ClientDir = CurrentDirectory + @"\Client";
        string Assets = ClientDir + @"\assets";
        string Libraries = ClientDir + @"\libraries";
        string Jar = ClientDir + @"\versions\1.12.2\1.12.2.jar";
        string JavaLibrary = ClientDir + @"\versions\1.12.2\1.12.2-natives";
        string Arguments = @"-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M -Djava.library.path=""" + JavaLibrary + @""" -cp """ + Libraries + @"\oshi-project\oshi-core\1.1\oshi-core-1.1.jar"";""" + Libraries + @"\net\java\dev\jna\jna\4.4.0\jna-4.4.0.jar"";""" + Libraries + @"\net\java\dev\jna\platform\3.4.0\platform-3.4.0.jar"";""" + Libraries + @"\com\ibm\icu\icu4j-core-mojang\51.2\icu4j-core-mojang-51.2.jar"";""" + Libraries + @"\net\sf\jopt-simple\jopt-simple\5.0.3\jopt-simple-5.0.3.jar"";""" + Libraries + @"\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar"";""" + Libraries + @"\com\paulscode\codecwav\20101023\codecwav-20101023.jar"";""" + Libraries + @"\com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar"";""" + Libraries + @"\com\paulscode\librarylwjglopenal\20100824\librarylwjglopenal-20100824.jar"";""" + Libraries + @"\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar"";""" + Libraries + @"\io\netty\netty-all\4.1.9.Final\netty-all-4.1.9.Final.jar"";""" + Libraries + @"\com\google\guava\guava\21.0\guava-21.0.jar"";""" + Libraries + @"\org\apache\commons\commons-lang3\3.5\commons-lang3-3.5.jar"";""" + Libraries + @"\commons-io\commons-io\2.5\commons-io-2.5.jar"";""" + Libraries + @"\commons-codec\commons-codec\1.10\commons-codec-1.10.jar"";""" + Libraries + @"\net\java\jinput\jinput\2.0.5\jinput-2.0.5.jar"";""" + Libraries + @"\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar"";""" + Libraries + @"\com\google\code\gson\gson\2.8.0\gson-2.8.0.jar"";""" + Libraries + @"\com\mojang\authlib\1.5.25\authlib-1.5.25.jar"";""" + Libraries + @"\com\mojang\realms\1.10.18\realms-1.10.18.jar"";""" + Libraries + @"\org\apache\commons\commons-compress\1.8.1\commons-compress-1.8.1.jar"";""" + Libraries + @"\org\apache\httpcomponents\httpclient\4.3.3\httpclient-4.3.3.jar"";""" + Libraries + @"\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar"";""" + Libraries + @"\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar"";""" + Libraries + @"\it\unimi\dsi\fastutil\7.1.0\fastutil-7.1.0.jar"";""" + Libraries + @"\org\apache\logging\log4j\log4j-api\2.8.1\log4j-api-2.8.1.jar"";""" + Libraries + @"\org\apache\logging\log4j\log4j-core\2.8.1\log4j-core-2.8.1.jar"";""" + Libraries + @"\org\lwjgl\lwjgl\lwjgl\2.9.4-nightly-20150209\lwjgl-2.9.4-nightly-20150209.jar"";""" + Libraries + @"\org\lwjgl\lwjgl\lwjgl_util\2.9.4-nightly-20150209\lwjgl_util-2.9.4-nightly-20150209.jar"";""" + Libraries + @"\com\mojang\text2speech\1.10.3\text2speech-1.10.3.jar"";""" + Jar + @""" net.minecraft.client.main.Main --username " + Username + @" --version 1.12.2 --gameDir """ + ClientDir + @""" --assetsDir """ + Assets + @""" --assetIndex 1.12 --uuid " + UUID + " --accessToken " + AccessToken + " --userType legacy --versionType ${version_type}";
        Process Client = new Process();
        Client.StartInfo.FileName = JavaDir;
        Client.StartInfo.Arguments = Arguments;
        Client.Start();
    }

删除标题并像这样调整窗口大小

    IntPtr window = FindWindowByCaption(IntPtr.Zero, "Minecraft 1.12.2");//
    SetWindowLong(window, GWL_STYLE, WS_SYSMENU);
    SetWindowPos(window , -2, x, y, Width , Height ,0x0040);

但是这只会从一个窗口调整大小并删除边框

如何使用相同的标题调整其他窗口的大小?

1 个答案:

答案 0 :(得分:0)

启动过程后,Client.MainWindowHandle已经有了窗口句柄。只需将其用于SetWindowLong()SetWindowPos()即可。没有必要按标题找到窗口。