gpt4 book ai didi

java - JNA 找到窗口,但不将其最小化

转载 作者:行者123 更新时间:2023-12-01 16:15:05 25 4
gpt4 key购买 nike

我正在尝试使用 JNA 操作 Java 上的外部窗口。我想找到一个特定的窗口,然后将其最小化。我尝试过的每个窗口都工作良好,但只有一个(显然是我需要的)。可以找到该文件并将其设置为前台,但无法以编程方式最小化。我还尝试使用 User32.INSTANCE.MoveWindow 移动它,但该命令也失败了。我想知道是否有应用程序不允许 JNA 窗口操作。如果是这样,我能做什么?我的代码如下所示。

    HWND test = User32.INSTANCE.FindWindow(null,"windowname");
User32.INSTANCE.SetForegroundWindow(test);
User32.INSTANCE.ShowWindow(test, WinUser.SW_MINIMIZE);

最佳答案

来自API for ShowWindow :

nCmdShow

Type: int

Controls how the window is to be shown. This parameter is ignored the first time an application calls ShowWindow, if the program that launched the application provides a STARTUPINFO structure. Otherwise, the first time ShowWindow is called, the value should be the value obtained by the WinMain function in its nCmdShow parameter. In subsequent calls, this parameter can be one of the following values.

如果您第二次调用它,您的最小化命令可能会起作用。

关于java - JNA 找到窗口,但不将其最小化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62421029/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com