package macro;

import static macro.EnumerateWindows.User32DLL.GetForegroundWindow;
import static macro.EnumerateWindows.User32DLL.GetWindowTextW;

import com.sun.jna.Native;

public class Window {
	
	private static final int MAX_TITLE_LENGTH = 1024;
	public static boolean isFocused(String windowName) {
		return getFocusedWindow().toLowerCase().equals(windowName.toLowerCase());
	}
	
	public static boolean isFocusedNoFullName(String windowName) {
		return getFocusedWindow().toLowerCase().contains(windowName.toLowerCase());
	}
	
	public static String getFocusedWindow() {
        char[] buffer = new char[MAX_TITLE_LENGTH * 2];
        GetWindowTextW(GetForegroundWindow(), buffer, MAX_TITLE_LENGTH);
        return Native.toString(buffer).toLowerCase();
    }
}
