我尝试使用WindowsAccessBridge.dll.
我可以获得窗口句柄但调用该函数isJavaWindow(System.IntPtr hWnd)总是返回false
请在下面找到我的代码:
static void Main()
{
System.Int32 vmID = 0;
System.Int64 _acParent = 0;
string WndName = "GLOBUS EDU";
string ClassName = "SunAwtFrame";
Windows_run();
System.IntPtr hWnd = System.IntPtr.Zero;
hWnd = (System.IntPtr)FindWindow(ClassName, WndName);
bool Found = isJavaWindow(hWnd);
if (!Found) { throw new System.Exception("ERROR: Unable to find window by classname " + ClassName + " and " + WndName + "!"); }
System.Console.WriteLine("Application is finished. Press ENTER to exit...");
System.Console.ReadKey();
}
互操作:
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
[System.Runtime.InteropServices.DllImport("WindowsAccessBridge-64.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
private extern static bool getAccessibleContextFromHWNDFct(System.IntPtr hwnd, out System.Int32 vmID, out System.Int32 _acParent);
private static bool getAccesibleContextFromHWND(System.IntPtr hWnd, out System.Int32 vmID, out System.Int64 acParent)
{
System.Int32 ac = -1;
bool retVal = false;
getAccessibleContextFromHWNDFct(hWnd, out vmID, out ac);
acParent = ac;
return retVal;
}
[System.Runtime.InteropServices.DllImport("WindowsAccessBridge-64.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
private extern static bool getAccessibleContextInfo(int vmID, System.IntPtr ac, out AccessibleContextInfo textInfo);
该功能FindWindow运行良好,我也得到了窗口句柄,Spy++ 也向我展示了。类名SunAwtFrame正如 Spy++ 所说。
我的 Java 应用程序以 64 位运行,但我尝试了所有库(-32、-64),并且还在 VS 配置管理器中从 x86 切换到 x64 并返回。
AccessBridge 本身运行良好 - Java-Monkey-64.exe 可以监视我正在运行的 Java 应用程序。
有没有人有想法,为什么这不起作用?
慕莱坞森
慕尼黑8549860
相关分类