我是JNA的新手.我试图获得所有窗口的句柄,包括最小化的窗口.我需要HWND所有的窗户.我已经解决了Windows的问题:如何获取所有可见窗口的列表?这有助于我获取窗口列表,但它的hWnd类型为int.我不能将它com.sun.jna.platform.win32.User32用于要求hWnd类型的功能com.sun.jna.platform.win32.WinDef.HWND.那么,有没有办法获得类型的所有窗口句柄com.sun.jna.platform.win32.WinDef.HWND而不是int指针?最后,为什么差异int和HWND?它如何接受两者?我有点困惑.谢谢.
我有以下代码(从Hovercreft的答案编辑):
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinDef.RECT;
import com.sun.jna.platform.win32.WinUser.WNDENUMPROC;
public class TryWithHWND {
public static void main(String[] args) {
final User32 user32 = User32.INSTANCE;
user32.EnumWindows(new WNDENUMPROC() {
int count = 0;
public boolean callback(HWND hWnd, Pointer arg1) {
char[] windowText = new char[512];
user32.GetWindowText(hWnd, windowText, 512);
String wText = Native.toString(windowText);
RECT rectangle = new RECT(); …Run Code Online (Sandbox Code Playgroud) 我们正在尝试开发一个屏幕捕获实用程序.
我们如何使用Java捕获另一个应用程序的选定屏幕?我们如何在捕获的屏幕上添加标注?
有没有办法让我在java中获取窗口的X和Y值?我读到我将不得不使用运行时,因为java不能直接混乱,但是我不太清楚如何做到这一点.谁能指出一些如何获得这个的链接/提示?
我正试图在Windows操作系统上挂钩CBT钩子.我目前正在使用Windows 7 x64.
我已经阅读了许多关于这个问题的线索,但没有一个解决了我的问题.应用程序运行良好; 挂钩已安装,我可以看到一些通知即将到来.
实际上出现的问题是应用程序没有得到关于在同一台机器上运行的其他进程的CBT钩子的通知.
该应用程序是用C#编写的(使用Microsoft .NET).这是一个正在运行的示例:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace WindowsHook
{
class Program
{
[STAThread]
static void Main(string[] args)
{
uint thid = (uint)AppDomain.GetCurrentThreadId();
bool global = true;
mHookDelegate = Marshal.GetFunctionPointerForDelegate(new HookProc(ManagedCallback));
if (global == true) {
mNativeWrapperInstance = LoadLibrary("Native_x64.dll");
thid = 0;
} else {
using (Process curProcess = Process.GetCurrentProcess())
using (ProcessModule curModule = curProcess.MainModule)
{
mNativeWrapperInstance = GetModuleHandle(curModule.ModuleName);
}
} …Run Code Online (Sandbox Code Playgroud)