Add References to git
This commit is contained in:
8
info/Minesweeper/WindowController/.classpath
Normal file
8
info/Minesweeper/WindowController/.classpath
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="lib" path="jna-4.2.1.jar"/>
|
||||
<classpathentry kind="lib" path="jna-platform-4.2.1.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
17
info/Minesweeper/WindowController/.project
Normal file
17
info/Minesweeper/WindowController/.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>WindowController</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
info/Minesweeper/WindowController/jna-4.2.1.jar
Normal file
BIN
info/Minesweeper/WindowController/jna-4.2.1.jar
Normal file
Binary file not shown.
BIN
info/Minesweeper/WindowController/jna-platform-4.2.1.jar
Normal file
BIN
info/Minesweeper/WindowController/jna-platform-4.2.1.jar
Normal file
Binary file not shown.
@ -0,0 +1,77 @@
|
||||
package window.controller;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.WinDef;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
//import com.sun.jna.*;
|
||||
//import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.win32.*;
|
||||
|
||||
public class GetWindowRect {
|
||||
|
||||
public interface MyUser32 extends StdCallLibrary {
|
||||
MyUser32 INSTANCE = (MyUser32) Native.loadLibrary("user32", MyUser32.class,
|
||||
W32APIOptions.DEFAULT_OPTIONS);
|
||||
|
||||
HWND FindWindow(String lpClassName, String lpWindowName);
|
||||
|
||||
int GetWindowRect(HWND handle, int[] rect);
|
||||
}
|
||||
|
||||
public static int[] getRect(String windowName) throws WindowNotFoundException,
|
||||
GetWindowRectException {
|
||||
|
||||
|
||||
HWND hwnd = MyUser32.INSTANCE.FindWindow(null, windowName);
|
||||
|
||||
/*
|
||||
char[] buffer = new char[1000];
|
||||
|
||||
//HWND next = User32.INSTANCE.GetForegroundWindow();
|
||||
HWND next = User32.INSTANCE.FindWindow(null, null);
|
||||
|
||||
//HWND next = User32.INSTANCE.GetWindow(all, new DWORD(2));
|
||||
|
||||
while (next != null) {
|
||||
|
||||
User32.INSTANCE.GetWindowText(next, buffer, buffer.length);
|
||||
|
||||
if (next != null) {
|
||||
System.out.println("found something - " + String.valueOf(buffer));
|
||||
}
|
||||
|
||||
next = User32.INSTANCE.GetWindow(next, new DWORD(2));
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
if (hwnd == null) {
|
||||
throw new WindowNotFoundException("", windowName);
|
||||
}
|
||||
|
||||
int[] rect = {0, 0, 0, 0};
|
||||
int result = MyUser32.INSTANCE.GetWindowRect(hwnd, rect);
|
||||
if (result == 0) {
|
||||
throw new GetWindowRectException(windowName);
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class WindowNotFoundException extends Exception {
|
||||
public WindowNotFoundException(String className, String windowName) {
|
||||
super(String.format("Window null for className: %s; windowName: %s",
|
||||
className, windowName));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class GetWindowRectException extends Exception {
|
||||
public GetWindowRectException(String windowName) {
|
||||
super("Window Rect not found for " + windowName);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user