简体   繁体   English

JNA 找到 window,但没有最小化它

[英]JNA finding window, but not minimizing it

I'm trying to manipulate an external window on Java, with JNA.我正在尝试使用 JNA 在 Java 上操作外部 window。 I want to find a specific window and then minimize it.我想找到一个特定的 window 然后最小化它。 Every window that I've tried worked well but one (obviously the one that I need).我试过的每一个 window 都运行良好,但是一个(显然是我需要的)。 That one can be found and set to the foreground, but can not be minimized programmatically.可以找到那个并将其设置为前台,但不能以编程方式最小化。 I've also tried to move it with User32.INSTANCE.MoveWindow, but that command failed too.我也尝试使用 User32.INSTANCE.MoveWindow 移动它,但该命令也失败了。 I was wondering if there are applications that do not allow JNA window manipulations.我想知道是否有不允许 JNA window 操作的应用程序。 If so, what can I do?如果是这样,我该怎么办? My code is shown below.我的代码如下所示。

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

From the API for ShowWindow :来自ShowWindow 的 API

nCmdShow nCmdShow

Type: int类型:整数

Controls how the window is to be shown.控制如何显示 window。 This parameter is ignored the first time an application calls ShowWindow , if the program that launched the application provides a STARTUPINFO structure.如果启动应用程序的程序提供 STARTUPINFO 结构,则应用程序第一次调用 ShowWindow 时忽略此参数 Otherwise, the first time ShowWindow is called, the value should be the value obtained by the WinMain function in its nCmdShow parameter.否则,第一次调用ShowWindow,该值应该是WinMain function在其nCmdShow参数中得到的值。 In subsequent calls, this parameter can be one of the following values.在后续调用中,此参数可以是以下值之一。

It would seem to be that your minimize command may work if you call it a second time.如果您再次调用它,您的最小化命令似乎会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM