Popular Post junkew Posted January 16, 2015 Popular Post Share Posted January 16, 2015 (edited) As a starter and far from perfect and real messy code a simple spy for Java Accessibility Bridge Based on the information in general help and support '?do=embed' frameborder='0' data-embedContent>> Many functions still to make and enhance but I would call at a 0.1 version for automating Java from within AutoIT and Java accessibility Spy detects based on mouse position make sure you have JABSWITCH /ENABLE Childs start counting from 0 Hover mouse over your Java Element and press Ctrl+W and you will get some basic information Prerequisites 1. Only Java Runtime needed (no need for samples / JDK to install) from JRE 1.7 and higher (for 1.6 you need to install accessibility bridge 2.0.2 yourself)2. JABSWITCH /ENABLE should have been run from commandline3. Then script can be run (will run JavaCPL with shellexecute("C:Program FilesJavajre1.8.0_25binjavacpl.exe")) so needs change if other JRE versionOptional (mainly for definitions in header files but main info copied in au3 script in comments)4. Java Accessibility Bridge 2.0.2. for CPP source and headers and javamonkey (java spy tool) 5. JDK installed for other JAVA sample applications6. NVDA screen reader source JABHANDLER.PY as a reference Please enhance / help in extending by posting small helper functions / translating the definitions (at the moment I have little time but the start is promising) Unfortunately there is not much documented on Java Accessibility Bridge Output example Mouse position is retrieved 1490-415 JAVA window found <> Java Window Title= Handle=0x00000000000E098C res: 1 Result getAccessibleContextFromHWND is <> ubound: 4 We have a VMid 133566 ac 1530827472 Call version info: PASSED VMID found : 133566 VMVersion: <1.8.0_25> bridgeJavaClassVersion: <1.8.0_25> bridgeJavaDLLVersion: <1.8.0_25> bridgeWinDLLVersion: <1.8.0_25> *** getAccessibleContextAT result is <1530827448> *** getAccessibleContextAT result is <1530827448> Network Settings... <html>Modify Internet connection settings</html> push button push button enabled,focusable,visible,showing,opaque enabled,focusable,visible,showing,opaque 0 0 1424 406 127 0 End of getAcceccibleContextAt info Source JABSimpleSpy expandcollapse popup#AutoIt3Wrapper_UseX64=Y ;~ It depends on amount of information you need if you require admin, run scite also as adminuser otherwise you will not see output in scitewindow ;~ #RequireAdmin #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <constants.au3> #include <WinAPI.au3> #include <WinAPIEx.au3> #include <debug.au3> #include <memory.au3> #include <Misc.au3> #include <javaui.au3> HotKeySet("{ESC}", "Close") ; Set ESC as a hotkey to exit the script. HotKeySet("^w", "GetElementInfo") ; Set Hotkey Ctrl+W to get some basic information in the GUI Global $hAccessBridgeDll ;~ reference to the accessbridge dll #Const $tagAccessBridgeVersionInfo = "WCHAR VMversion[256];WCHAR bridgeJavaClassVersion[256];WCHAR bridgeJavaDLLVersion[256];WCHAR bridgeWinDLLVersion[256]" ;~ const $c_JOBJECT64="UINT64" ;~ JOBJECT64 ;~ const $cP_JOBJECT64="UINT64*" ;~ POINTER(JOBJECT64) #Const $c_JOBJECT64 = (@AutoItX64) ? ("UINT64") : ("UINT") ;~ JOBJECT64 #Const $cP_JOBJECT64 = (@AutoItX64) ? ("UINT64*") : ("UINT*") ;~ POINTER(JOBJECT64) Const $c_AccessibleContext=$c_JOBJECT64 Const $cP_AccessibleContext=$cP_JOBJECT64 Local $tAccessBridgeVersionInfo = DllStructCreate($tagAccessBridgeVersionInfo) #Const $tagAccessibleContextInfo = "WCHAR name[1024];WCHAR description[1024];WCHAR role[256];WCHAR role_en_US[256];WCHAR states[256];WCHAR states_en_US[256];INT indexInParent;INT childrenCount;INT x;INT y;INT width;INT height;BOOL accessibleComponent;BOOL accessibleAction;BOOL accessibleSelection;BOOL accessibleText;BOOL accessibleInterfaces" Local $tAccessibleContextInfo = DllStructCreate($tagAccessibleContextInfo) ;~ struct AccessibleTextInfo { ;~ jint charCount; // # of characters in this text object ;~ jint caretIndex; // index of caret ;~ jint indexAtPoint; // index at the passsed in point ;~ }; #Const $tagAccessibleTextInfo = "INT charCount;INT caretIndex;INT indexAtPoint" Const $AutoSpy = 0 ;2000 ; SPY about every 2000 milliseconds automatically, 0 is turn of use only ctrl+w ;~ global $oldUIElement ; To keep track of latest referenced element Global $frmSimpleSpy, $edtCtrlInfo, $lblCapture, $lblEscape, $lblRecord, $edtCtrlRecord, $msg Global $i ; Just a simple counter to measure time expired in main loop If @AutoItX64 <> 1 Then Local $sJavaReg = "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment" $sJavaVersion = RegRead($sJavaReg, "CurrentVersion") $sJavaHome = RegRead($sJavaReg & "\" & $sJavaVersion, "JavaHome") ElseIf @AutoItX64 = 1 Then Local $sJavaReg64 = "HKLM64\SOFTWARE\JavaSoft\Java Runtime Environment" Local $sJavaReg32 = "HKLM64\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment" local $regKey $regKey=(@AutoItX64) ? $sJavaReg64 : $sJavaReg32 consolewrite("Reading from regkey: "& $regkey & @CRLF) $sJavaVersion = RegRead($regkey, "CurrentVersion") if (@error=1) Then $regKey=$sJavaReg32 EndIf $sJavaVersion = RegRead($regkey, "CurrentVersion") $sJavaHome = RegRead($regkey & "\" & $sJavaVersion, "JavaHome") $sJavaHome = StringReplace($sJavaHome," (x86)","") $sJavaHome = "C:\Program Files\Java\jdk1.8.0_172\jre" ;~ consolewrite($sJavaHome & @ProgramFilesDir) ;~ exit EndIf if $sJavaHome="" Then Local $sJavaHome=envget("JAVA_HOME") if stringright($sJavaHome,1)="\" Then $sJavaHome=stringleft($sJavaHome,stringlen($sJavaHome)-1) EndIf endif ;~ Global $sWow64 = (@AutoItX64) ? ("\Wow6432Node") : ("") ;~ Global $sJavaVersion = RegRead("HKLM\SOFTWARE" & $sWow64 & "\JavaSoft\Java Runtime Environment", "CurrentVersion") ;~ Global $sJavaHome = RegRead("HKLM\SOFTWARE" & $sWow64 & "\JavaSoft\Java Runtime Environment\" & $sJavaVersion, "JavaHome") ConsoleWrite("JAVAHOME=" & $sJavaHome & @CRLF) consolewrite("The current working directory: " & @CRLF & @WorkingDir) ShellExecute($sJavaHome & "\bin\javacpl.exe") Sleep(3000) _JABInit() ;~ _Example1_IterateJavaWindows() #Region ### START Koda GUI section ### Form= $frmSimpleSpy = GUICreate("Simple UIA Spy", 801, 601, 181, 4) $edtCtrlInfo = GUICtrlCreateEdit("", 18, 18, 512, 580) GUICtrlSetData(-1, "") $lblCapture = GUICtrlCreateLabel("Ctrl+W to capture information", 544, 10, 528, 17) $lblEscape = GUICtrlCreateLabel("Escape to exit", 544, 53, 528, 17) $edtCtrlRecord = GUICtrlCreateEdit("", 544, 72, 233, 520) GUICtrlSetData(-1, "//TO DO edtCtrlRecord") ;~ $lblRecord = GUICtrlCreateLabel("Ctrl + R to record code", 544, 32, 527, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ _UIA_Init() ;~ loadCodeTemplates() ; //TODO: To use templates per class/controltype ; Run the GUI until the dialog is closed While True $msg = GUIGetMsg() Sleep(100) ;~ if _ispressed(01) Then ;~ getelementinfo() ;~ endif ;Just to show anyway the information about every n ms so ctrl+w is not interfering / removing window as unwanted side effects $i = $i + 100 If ($AutoSpy <> 0) And ($i >= $AutoSpy) Then $i = 0 GetElementInfo() EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd _JABShutDown() Func GetElementInfo() Local $acParent = 0 Local $vmID = 0 Local $tStruct = DllStructCreate($tagPOINT) Local $description $description = "" $xMouse = MouseGetPos(0) $yMouse = MouseGetPos(1) DllStructSetData($tStruct, "x", $xMouse) DllStructSetData($tStruct, "y", $yMouse) $tGetMousePos = _WinAPI_GetMousePos() $hwnd = _WinAPI_WindowFromPoint($tGetMousePos) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "isJavaWindow", "hwnd", $hwnd) If @error = 0 Then If $result[0] = 1 Then consolewrite("mouse position retrieved" & @CRLF) $description = "Mouse position is retrieved " & $xMouse & "-" & $yMouse & @CRLF ;~ GUICtrlSetData($edtCtrlInfo, "Mouse position is retrieved " & $xMouse & "-" & $yMouse & @CRLF) $description = $description & (" JAVA window found <" & "> Java Window Title=" & " Handle=" & $hwnd & @TAB & " res: " & $result[0] & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $hwnd, "long*", $vmID, $cP_AccessibleContext, $acParent) If @error = 0 Then $description = $description & ("Result getAccessibleContextFromHWND is <" & $result & "> ubound: " & UBound($result) & @CRLF) $vmID = $result[2] $acParent = $result[3] $description = $description & (" We have a VMid " & $vmID & " ac " & $acParent & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getVersionInfo", "long", $vmID, "struct*", DllStructGetPtr($tAccessBridgeVersionInfo)) If @error = 0 Then $s1 = DllStructGetData($tAccessBridgeVersionInfo, "VMVersion") $s2 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeJavaClassVersion") $s3 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeJavaDLLVersion") $s4 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeWinDLLVersion") $description = $description & ("Call version info: PASSED VMID found : " & $vmID & @CRLF) $description = $description & (" VMVersion: <" & $s1 & ">" & @CRLF) $description = $description & (" bridgeJavaClassVersion: <" & $s2 & ">" & @CRLF) $description = $description & (" bridgeJavaDLLVersion: <" & $s3 & ">" & @CRLF) $description = $description & (" bridgeWinDLLVersion: <" & $s4 & ">" & @CRLF) Else $description = $description & ("getVersionInfo error:" & @error & @CRLF) EndIf Local $childAT_AC __getAccessibleContextAt($vmID, $acParent, $xmouse, $yMouse, $childAT_AC) $description = $description & (" *** getAccessibleContextAT result is <" & $childAT_AC & "> " & @CRLF) If @error = 0 Then $description = $description & (" *** getAccessibleContextAT result is <" & $childAT_AC & "> " & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $childAT_AC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo = $result[3] $description = $description & (getDescription($AccessibleContextInfo)) $description = $description & ("End of getAcceccibleContextAt info" & @CRLF) $acX = DllStructGetData($AccessibleContextInfo, "x") $acY = DllStructGetData($AccessibleContextInfo, "y") $acW = DllStructGetData($AccessibleContextInfo, "width") $acH = DllStructGetData($AccessibleContextInfo, "height") ConsoleWrite("rect:" & $acX & $acX+$acW & $acy & $acY+$acH) _UIA_DrawRect($acX,$acX+$acW, $acy, $acY+$acH) EndIf EndIf EndIf EndIf GUICtrlSetData($edtCtrlInfo, $description & @CRLF) EndFunc ;==>GetElementInfo Func Close() _JABShutDown() Exit EndFunc ;==>Close Func _JABInit() ;~ Make sure Java Access Bridge is turned on RunWait($sJavaHome & "\bin\jabswitch /enable", "", @SW_MAXIMIZE) ;~ TODO: Check if it works with both dll's ConsoleWrite("We are using " & @OSArch & " at cpu " & @CPUArch & " Autoit 64 bit version @AutoItX64=" & @AutoItX64 & @CRLF) If Not IsAdmin() Then ConsoleWrite("Warning: The script is advicable to be run with #requireadmin" & @CRLF) EndIf $sAccessBridgeDLL = (@AutoItX64) ? "WindowsAccessBridge-64.dll" : "WindowsAccessBridge-32.dll" ;~ $sAccessBridgeDLLFull = (@AutoItX64) ? $sJavaHome & "\bin\" & $sAccessBridgeDLL : "C:\Windows\SysWOW64\" & $sAccessBridgeDLL $sAccessBridgeDLLFull = $sJavaHome & "\bin\" & $sAccessBridgeDLL ;~ Open the Dll for accessibility ConsoleWrite("Opening " & $sAccessBridgeDLLFull & @CRLF) $hAccessBridgeDll = DllOpen($sAccessBridgeDLLFull) If $hAccessBridgeDll = True Then ConsoleWrite(" PASS : Windows accessbridge " & $sAccessBridgeDLLFull & " opened returns: " & $hAccessBridgeDll & @CRLF) Else ConsoleWrite(" ERROR: Windows accessbridge " & $sAccessBridgeDLLFull & " opened returns: " & $hAccessBridgeDll & @CRLF) EndIf ;~ TODO: Handle messages received from initialize $result = __Windows_run() ConsoleWrite($result & " " & @error & " initializeAccessBridge is finished") Sleep(250) ConsoleWrite("Windows_run passed :" & $result & @CRLF) EndFunc ;==>_JABInit ;~ _fixBridgeFunc(None,'Windows_run') ;~ Func __Windows_run() ;~ $result = DllCall($hAccessBridgeDll, "NONE", "Windows_run") ;~ If @error Then Return SetError(1, 0, 0) ;~ Return $result[0] ;~ EndFunc ;==>__Windows_run ;~ _fixBridgeFunc(None,'setFocusGainedFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyStateChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyCaretChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyActiveDescendentChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'releaseJavaObject',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getVersionInfo',POINTER(AccessBridgeVersionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'isJavaWindow',HWND) ;~ _fixBridgeFunc(BOOL,'isSameObject',c_long,JOBJECT64,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextFromHWND',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(HWND,'getHWNDFromAccessibleContext',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextAt',c_long,JOBJECT64,jint,jint,POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextWithFocus',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextInfo',c_long,JOBJECT64,POINTER(AccessibleContextInfo),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleParentFromContext',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleRelationSet',c_long,JOBJECT64,POINTER(AccessibleRelationSetInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextInfo',c_long,JOBJECT64,POINTER(AccessibleTextInfo),jint,jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextItems',c_long,JOBJECT64,POINTER(AccessibleTextItemsInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextSelectionInfo',c_long,JOBJECT64,POINTER(AccessibleTextSelectionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextAttributes',c_long,JOBJECT64,jint,POINTER(AccessibleTextAttributesInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextLineBounds',c_long,JOBJECT64,jint,POINTER(jint),POINTER(jint),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextRange',c_long,JOBJECT64,jint,jint,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCurrentAccessibleValueFromContext',c_long,JOBJECT64,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'selectTextRange',c_long,JOBJECT64,c_int,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getTextAttributesInRange',c_long,JOBJECT64,c_int,c_int,POINTER(AccessibleTextAttributesInfo),POINTER(c_short),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(c_int,'getObjectDepth',c_long,JOBJECT64) ;~ _fixBridgeFunc(JOBJECT64,'getActiveDescendent',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'requestFocus',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'setCaretPosition',c_long,JOBJECT64,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCaretLocation',c_long,JOBJECT64,POINTER(AccessibleTextRectInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActions),errcheck=True) ;~ _fixBridgeFunc(BOOL,'doAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActionsToDo),POINTER(jint),errcheck=True) ;~ By inspecting the WindowsAccessBridge-32.dll it reveals some information about the hidden dialogs ;~ So it seems the hidden dialog is shown after you call windows_run() no clue if interaction is needed ;~ ;~ Somehow it sends a message unclear if this is to the JVM to respond to ;~ push SSZ6E73E320_AccessBridge_FromJava_Hello ;~ push SSZ6E73E300_AccessBridge_FromWindows_Hello ;~ db 'AccessBridge-FromWindows-Hello',0 ;~ db 'AccessBridge-FromJava-Hello',0 ;~ JABHANDLER.PY is a usefull source to study on internet ;~ ******* ;~ Every AccessibleContext IntPtr must be replaced by long, including but not limited to getAccessibleContextFromHWND, getAccessibleParentFromContext, getAccessibleChildFromContext, getAccessibleTextInf ;~ JOBJECT64 is defined as jlong on 64-bit systems and jobject on legacy versions of Java Access Bridge. For definitions, see the section ACCESSBRIDGE_ARCH_LEGACY in the AccessBridgePackages.h header file. ;~ #ifdef ACCESSBRIDGE_ARCH_LEGACY ;~ typedef jobject JOBJECT64; ;~ typedef HWND ABHWND64; ;~ #define ABHandleToLong ;~ #define ABLongToHandle ;~ #else ;~ typedef jlong JOBJECT64; ;~ typedef long ABHWND64; ;~ #define ABHandleToLong HandleToLong ;~ #define ABLongToHandle LongToHandle ;~ #endif ;~ a jobject is a 32 bit pointer for 32 bit builds ;~ 'bool' is a built-in C++ type while 'BOOL' is a Microsoft specific type that is defined as an 'int'. You can find it in 'windef.h' ;~ ;~ ** jni_md.h ** ;~ typedef long jint; ;~ typedef __int64 jlong; ;~ typedef signed char jbyte; ;~ ******* ;~ accessbridgecalls.h ;~ typedef JOBJECT64 AccessibleContext; ;~ typedef JOBJECT64 AccessibleText; ;~ typedef JOBJECT64 AccessibleValue; ;~ typedef JOBJECT64 AccessibleSelection; ;~ typedef JOBJECT64 Java_Object; ;~ typedef JOBJECT64 PropertyChangeEvent; ;~ typedef JOBJECT64 FocusEvent; ;~ typedef JOBJECT64 CaretEvent; ;~ typedef JOBJECT64 MouseEvent; ;~ typedef JOBJECT64 MenuEvent; ;~ typedef JOBJECT64 AccessibleTable; ;~ typedef JOBJECT64 AccessibleHyperlink; ;~ typedef JOBJECT64 AccessibleHypertext; ;~ #Appropriately set the return and argument types of all the access bridge dll functions ;~ if bridgeDll: ;~ _fixBridgeFunc(None,'Windows_run') ;~ _fixBridgeFunc(None,'setFocusGainedFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyStateChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyCaretChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyActiveDescendentChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'releaseJavaObject',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getVersionInfo',POINTER(AccessBridgeVersionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'isJavaWindow',HWND) ;~ _fixBridgeFunc(BOOL,'isSameObject',c_long,JOBJECT64,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextFromHWND',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(HWND,'getHWNDFromAccessibleContext',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextAt',c_long,JOBJECT64,jint,jint,POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextWithFocus',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextInfo',c_long,JOBJECT64,POINTER(AccessibleContextInfo),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleParentFromContext',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleRelationSet',c_long,JOBJECT64,POINTER(AccessibleRelationSetInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextInfo',c_long,JOBJECT64,POINTER(AccessibleTextInfo),jint,jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextItems',c_long,JOBJECT64,POINTER(AccessibleTextItemsInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextSelectionInfo',c_long,JOBJECT64,POINTER(AccessibleTextSelectionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextAttributes',c_long,JOBJECT64,jint,POINTER(AccessibleTextAttributesInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextLineBounds',c_long,JOBJECT64,jint,POINTER(jint),POINTER(jint),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextRange',c_long,JOBJECT64,jint,jint,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCurrentAccessibleValueFromContext',c_long,JOBJECT64,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'selectTextRange',c_long,JOBJECT64,c_int,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getTextAttributesInRange',c_long,JOBJECT64,c_int,c_int,POINTER(AccessibleTextAttributesInfo),POINTER(c_short),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(c_int,'getObjectDepth',c_long,JOBJECT64) ;~ _fixBridgeFunc(JOBJECT64,'getActiveDescendent',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'requestFocus',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'setCaretPosition',c_long,JOBJECT64,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCaretLocation',c_long,JOBJECT64,POINTER(AccessibleTextRectInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActions),errcheck=True) ;~ _fixBridgeFunc(BOOL,'doAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActionsToDo),POINTER(jint),errcheck=True) ;~ Primitive Types and Native Equivalents ;~ Java Type Native Type Description ;~ boolean jboolean unsigned 8 bits ;~ byte jbyte signed 8 bits ;~ char jchar unsigned 16 bits ;~ short jshort signed 16 bits ;~ int jint signed 32 bits ;~ long jlong signed 64 bits ;~ float jfloat 32 bits ;~ double jdouble 64 bits ;~ void void not applicable ;~ Copied from this NVDA reference and translated to AutoIT ;~ http://www.webbie.org.uk/nvda/api/JABHandler-pysrc.html ;~ ;~ def initialize(): ;~ global isRunning ;~ if not bridgeDll: ;~ raise NotImplementedError("dll not available") ;~ bridgeDll.Windows_run() ;~ #Accept wm_copydata and any wm_user messages from other processes even if running with higher privilages ;~*** ChangeWindowMessageFilter=getattr(windll.user32,'ChangeWindowMessageFilter',None) ;~*** if ChangeWindowMessageFilter: ;~*** if not ChangeWindowMessageFilter(winUser.WM_COPYDATA,1): ;~*** raise WinError() ;~*** for msg in xrange(winUser.WM_USER+1,65535): ;~*** if not ChangeWindowMessageFilter(msg,1): ;~*** raise WinError() ;~ #Register java events ;~ bridgeDll.setFocusGainedFP(internal_event_focusGained) ;~ bridgeDll.setPropertyActiveDescendentChangeFP(internal_event_activeDescendantChange) ;~ bridgeDll.setPropertyNameChangeFP(event_nameChange) ;~ bridgeDll.setPropertyDescriptionChangeFP(event_descriptionChange) ;~ bridgeDll.setPropertyValueChangeFP(event_valueChange) ;~ bridgeDll.setPropertyStateChangeFP(internal_event_stateChange) ;~ bridgeDll.setPropertyCaretChangeFP(internal_event_caretChange) ;~ isRunning=True ;create the structs ;~ ;~ http://docs.oracle.com/javase/accessbridge/2.0.2/api.htm ;~ ;~ #define MAX_STRING_SIZE 1024 ;~ #define SHORT_STRING_SIZE 256 ;~ struct AccessBridgeVersionInfo { ;~ wchar_t VMversion[SHORT_STRING_SIZE]; // version of the Java VM ;~ wchar_t bridgeJavaClassVersion[SHORT_STRING_SIZE]; // version of the AccessBridge.class ;~ wchar_t bridgeJavaDLLVersion[SHORT_STRING_SIZE]; // version of JavaAccessBridge.dll ;~ wchar_t bridgeWinDLLVersion[SHORT_STRING_SIZE]; // version of WindowsAccessBridge.dll ;~ }; ;~ struct AccessibleContextInfo { ;~ wchar_ name[MAX_STRING_SIZE]; // the AccessibleName of the object ;~ wchar_ description[MAX_STRING_SIZE]; // the AccessibleDescription of the object ;~ wchar_ role[SHORT_STRING_SIZE]; // localized AccesibleRole string ;~ wchar_ states[SHORT_STRING_SIZE]; // localized AccesibleStateSet string ;~ // (comma separated) ;~ jint indexInParent // index of object in parent ;~ jint childrenCount // # of children, if any ;~ jint x; // screen x-axis co-ordinate in pixels ;~ jint y; // screen y-axis co-ordinate in pixels ;~ jint width; // pixel width of object ;~ jint height; // pixel height of object ;~ BOOL accessibleComponent; // flags for various additional ;~ BOOL accessibleAction; // Java Accessibility interfaces ;~ BOOL accessibleSelection; // FALSE if this object doesn't ;~ BOOL accessibleText; // implement the additional interface ;~ BOOL accessibleInterfaces; // new bitfield containing additional ;~ // interface flags ;~ }; ;~ typedef struct AccessibleContextInfoTag { ;~ wchar_t name[MAX_STRING_SIZE]; // the AccessibleName of the object ;~ wchar_t description[MAX_STRING_SIZE]; // the AccessibleDescription of the object ;~ wchar_t role[SHORT_STRING_SIZE]; // localized AccesibleRole string ;~ wchar_t role_en_US[SHORT_STRING_SIZE]; // AccesibleRole string in the en_US locale ;~ wchar_t states[SHORT_STRING_SIZE]; // localized AccesibleStateSet string (comma separated) ;~ wchar_t states_en_US[SHORT_STRING_SIZE]; // AccesibleStateSet string in the en_US locale (comma separated) ;~ jint indexInParent; // index of object in parent ;~ jint childrenCount; // # of children, if any ;~ jint x; // screen coords in pixels ;~ jint y; // " ;~ jint width; // pixel width of object ;~ jint height; // pixel height of object ;~ BOOL accessibleComponent; // flags for various additional ;~ BOOL accessibleAction; // Java Accessibility interfaces ;~ BOOL accessibleSelection; // FALSE if this object doesn't ;~ BOOL accessibleText; // implement the additional interface ;~ // in question ;~ // BOOL accessibleValue; // old BOOL indicating whether AccessibleValue is supported ;~ BOOL accessibleInterfaces; // new bitfield containing additional interface flags ;~ } AccessibleContextInfo; Local $hwnd Local $i Local $result Local $vmID Local $ac ;~ //TODO: Check if needed ;~ Make messages elevated ;~ _ChangeWindowMessageFilter($WM_COPYDATA,1) ;~ for $i=$WM_USER to $WM_USER+65536 ;~ _ChangeWindowMessageFilter($i, 1) ;~ Next ;~ Func _ChangeWindowMessageFilter($iMsg, $iAction) ;~ Local $aCall = DllCall("user32.dll", "bool", "ChangeWindowMessageFilter", "dword", $iMsg, "dword", $iAction) ;~ If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) ;~ Return 1 ;~ EndFunc ;~ typedef AccessibleContext (*getTopLevelObjectFP) (const long vmID, const AccessibleContext ac); ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) ;~ Func __getTopLevelObject($vmID, $ac) ;~ Seems not to be allowed to call with null so passing $acParent ;~ $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getTopLevelObject", "long", $vmID, $c_JOBJECT64, $ac) ;~ If @error Then Return SetError(1, 0, 0) ;~ Return $result[0] ;~ EndFunc ;==>__getTopLevelObject ;~ typedef AccessibleContext (*GetAccessibleChildFromContextFP) (long vmID, AccessibleContext ac, jint i); ;~ typedef AccessibleContext (*GetAccessibleParentFromContextFP) (long vmID, AccessibleContext ac); ;~ typedef AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint index); ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ Returns an AccessibleContext object that represents the nth child of the object ac, where n is specified by the value index. #cs Func __getAccessibleChildFromContext($vmID, $ac, $index) ;~ Seems not to be allowed to call with null so passing $acParent $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getAccessibleChildFromContext", "long", $vmID, $c_JOBJECT64, $ac, "int", $index) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;==>__getAccessibleChildFromContext ;~ _fixBridgeFunc(JOBJECT64,'getActiveDescendent',c_long,JOBJECT64) Func __getActiveDescendent($vmID, $ac) ;~ Seems not to be allowed to call with null so passing $acParent $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getActiveDescendent", "long", $vmID, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;==>__getActiveDescendent ;~ _fixBridgeFunc(BOOL,'getAccessibleContextAt',c_long,JOBJECT64,jint,jint,POINTER(JOBJECT64),errcheck=True) ;~ BOOL GetAccessibleContextAt(long vmID, AccessibleContext acParent, jint x, jint y, AccessibleContext *ac) Func __getAccessibleContextAt($vmID, $acParent, $x, $y, ByRef $ac) ;~ Seems not to be allowed to call with null so passing $acParent consolewrite("BREAKING: AcceccibleContextAt 1 " & $c_JOBJECT64 & @CRLF) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleContextAt", "long", $vmID, $c_JOBJECT64, $acParent, "int", $x, "int", $y, $cP_JOBJECT64, $ac) consolewrite("PASSED : AcceccibleContextAt 2 " & @CRLF) ConsoleWrite(@error) If @error Then Return SetError(1, 0, 0) consolewrite("AcceccibleContextAt 3 ") ConsoleWrite("hello") $ac = $result[5] Return $result[0] EndFunc ;==>__getAccessibleContextAt #ce Func _Example1_IterateJavaWindows() ;~ Just check all windows if its a java window Local $var = WinList() ConsoleWrite("Before checking all Windows: " & $var[0][0] & @CRLF) For $i = 1 To $var[0][0] ; Only display visble windows that have a title If IsVisible($var[$i][1]) Then Local $handle = WinGetHandle($var[$i][0]) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "isJavaWindow", "hwnd", $handle) If @error = 0 Then If $result[0] = 1 Then ConsoleWrite(" JAVA window found <" & $i & "> Java Window Title=" & $var[$i][0] & " Handle=" & $var[$i][1] & @TAB & " res: " & $result[0] & @CRLF) Local $acParent = 0 Local $vmID = 0 ;~AccessibilityContext (acParent above), which I had incorrectly mapped as an IntPtr, is actually an Int32 when using the "legacy" WindowsAccessBridge.dll library (used under x86), ;~and an Int64 when using the WOW64 WindowsAccessBridge-32.dll library. ;~WindowsAccessBridge-32.dll bool getAccessibleContextFromHWND(IntPtr hwnd, out Int32 vmID, out Int64 acParent); ;~WindowsAccessBridge.dll bool _getAccessibleContextFromHWND(IntPtr hwnd, out Int32 vmID, out Int32 acParent); ;~ _fixBridgeFunc(BOOL,'getAccessibleContextFromHWND',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $handle, "long*", $vmID, "UINT64*", $acParent) ;~ $result =dllcall($hAccessBridgeDll,"BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $handle, "long*", $vmID, "ptr*", $acParent) ;~ $result =dllcall($hAccessBridgeDll,"BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $handle, "long*", $vmID, "INT64*", $acParent) If @error = 0 Then ConsoleWrite("Result getAccessibleContextFromHWND is <" & $result & "> ubound: " & UBound($result) & @CRLF) $vmID = $result[2] $acParent = $result[3] ConsoleWrite(" We have a VMid " & $vmID & " ac " & $acParent & @CRLF) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getVersionInfo", "long", $vmId, "struct", $AccessBridgeVersionInfo) ;~ typedef BOOL (*GetVersionInfoFP) (long vmID, AccessBridgeVersionInfo *info); $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getVersionInfo", "long", $vmID, "struct*", DllStructGetPtr($tAccessBridgeVersionInfo)) If @error = 0 Then $s1 = DllStructGetData($tAccessBridgeVersionInfo, "VMVersion") $s2 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeJavaClassVersion") $s3 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeJavaDLLVersion") $s4 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeWinDLLVersion") ConsoleWrite("Call version info: PASSED VMID found : " & $vmID & @CRLF) ConsoleWrite(" VMVersion: <" & $s1 & ">" & @CRLF) ConsoleWrite(" bridgeJavaClassVersion: <" & $s2 & ">" & @CRLF) ConsoleWrite(" bridgeJavaDLLVersion: <" & $s3 & ">" & @CRLF) ConsoleWrite(" bridgeWinDLLVersion: <" & $s4 & ">" & @CRLF) Else ConsoleWrite("getVersionInfo error:" & @error & @CRLF) EndIf ;~ /** ;~ * Returns the Accessible Context for the top level object in ;~ * a Java Window. This is same Accessible Context that is obtained ;~ * from GetAccessibleContextFromHWND for that window. Returns ;~ * (AccessibleContext)0 on error. ;~ */ ;~ AccessibleContext getTopLevelObject (const long vmID, const AccessibleContext accessibleContext); ;~ typedef AccessibleContext (*getTopLevelObjectFP) (const long vmID, const AccessibleContext ac); ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) Local $topAC = __getTopLevelObject($vmID, $acParent) If @error = 0 Then ConsoleWrite(" *** getTopLevelObject Result is <" & $topAC & "> " & @CRLF) ;~ $vmID=$result[1] ;~ local $tPtr = DllStructCreate( "ptr", $result[0] ) ;~ local $ptr = DllStructGetData( $tPtr,1 ) ;~ local $topAC = $result ;~ DllStructCreate( $tagAccessibleContextInfo, $ptr ) ;~ Local $topAC=DllStructCreate($tagAccessibleContextInfo,DllStructGetPtr($result[0])) ;~ Local $topAC=DllStructCreate($tagAccessibleContextInfo,$result[0]) ;~ dllstructsetdata($topAC,-1,$result[0] ConsoleWrite("We have a VMid " & $vmID & " toplevel object ac " & $topAC & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $topAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo = $result[3] ConsoleWrite(getDescription($AccessibleContextInfo)) ConsoleWrite("End of top level object info" & @CRLF) $childAC = __getAccessibleChildFromContext($vmID, $topAC, 0) ConsoleWrite(" *** getAccessibleChildFromContext Result is <" & $childAC & "> " & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $childAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo = $result[3] ConsoleWrite(getDescription($AccessibleContextInfo)) ConsoleWrite("End of getAccessibleChild object info" & @CRLF) $descentAC = __getActiveDescendent($vmID, $topAC) ConsoleWrite(" *** getActiveDescendent Result is <" & $descentAC & "> " & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $descentAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo = $result[3] ConsoleWrite(getDescription($AccessibleContextInfo)) ConsoleWrite("End of getActiveDescendent object info" & @CRLF) Else ConsoleWrite("getTopLevelObjecterror:" & @error & @CRLF) _WinAPI_DisplayStruct($topAC, $tagAccessibleContextInfo) EndIf ConsoleWrite(" We still have a VMid " & $vmID & " acParent " & $acParent & @CRLF) ;~ Retrieves an AccessibleContextInfo object of the AccessibleContext object ac. ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "ptr", $ac, "ptr", DllStructGetPtr($AccessibleContextInfo)) ;~ typedef BOOL (*GetAccessibleContextInfoFP) (long vmID, AccessibleContext ac, AccessibleContextInfo *info); ;~ _fixBridgeFunc(BOOL,'getAccessibleContextInfo',c_long,JOBJECT64,POINTER(AccessibleContextInfo),errcheck=True) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","INT64", $vmId, "int", $ac, "ptr*", DllStructGetPtr($AccessibleContextInfo)) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "long", $ac, "ptr", DllStructGetPtr($AccessibleContextInfo),DllStructGetSize($AccessibleContextInfo)) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "INT64", $acParent, "struct*", DllStructGetPtr($AccessibleContextInfo)) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $acParent, "struct*", $tAccessibleContextInfo) If @error <> 0 Then ConsoleWrite("We have an error " & @error & @CRLF) EndIf ;~ We should pass it by reference ;~ Exception code c0000005 is an access violation, also known as general protection fault. The program is reading from, or writing to, an address which is not part of the virtual address space. ;~ A very common cause is that you are de-referencing a stale pointer. In other words, the pointer was once valid, but you have subsequently freed it. Then later when you attempt to access it, ;~ an exception is raised. ;~ The problem is don't use out parameter. Use the IntPtr. ;~ So it should be getAccessibleContextInfo(Int32 vmID, IntPtr accessibleContext, IntPtr acInfo) ConsoleWrite("Result is <" & $result & "> ubound: " & UBound($result) & @CRLF) $AccessibleContextInfo = $result[3] _WinAPI_DisplayStruct($tAccessibleContextInfo, $tagAccessibleContextInfo) ConsoleWrite(getDescription($AccessibleContextInfo)) $s9 = DllStructGetData($AccessibleContextInfo, "x") $s10 = DllStructGetData($AccessibleContextInfo, "y") $s11 = DllStructGetData($AccessibleContextInfo, "width") $s12 = DllStructGetData($AccessibleContextInfo, "height") ConsoleWrite(" We still have before getAccessible Child FromContext a VMid " & $vmID & " acParent " & $acParent & @CRLF) ConsoleWrite("rect:" & $s9 & $s9 + $s11 & $s10 & $s10 + $s12) _UIA_DrawRect($s9, $s9 + $s11, $s10, $s10 + $s12) Sleep(3000) ;~ AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint index); ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ Returns an AccessibleContext object that represents the nth child of the object ac, where n is specified by the value index. $childAC = __getAccessibleChildFromContext($vmID, $topAC, 0) ConsoleWrite(" *** getAccessibleChildFromContext Result is <" & $childAC & "> " & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $childAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo = $result[3] ConsoleWrite(getDescription($AccessibleContextInfo)) ConsoleWrite("End of getAccessibleChild object info" & @CRLF) _WinAPI_DisplayStruct($tAccessibleContextInfo, $tagAccessibleContextInfo) ;~ memcpy(tData->ResponceHTML, m_pResponse, INT_BUFFERSIZE); ConsoleWrite(getDescription($AccessibleContextInfo)) Else ConsoleWrite(@error & " No context found" & @CRLF) EndIf EndIf Else EndIf EndIf Next EndFunc ;==>_Example1_IterateJavaWindows ;~ http://www.autohotkey.com/board/topic/95343-how-to-send-to-unseen-controls-in-a-java-app/ Func _JABShutDown() Local $result $result = DllCall($hAccessBridgeDll, "BOOL", "shutdownAccessBridge") EndFunc ;==>_JABShutDown Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible ; Draw rectangle on screen. Func _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4) Local $hDC, $hPen, $obj_orig, $x1, $x2, $y1, $y2 $x1 = $tLeft $x2 = $tRight $y1 = $tTop $y2 = $tBottom $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $PenWidth, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1) ; horizontal to right _WinAPI_DrawLine($hDC, $x2, $y1, $x2, $y2) ; vertical down on right _WinAPI_DrawLine($hDC, $x2, $y2, $x1, $y2) ; horizontal to left right _WinAPI_DrawLine($hDC, $x1, $y2, $x1, $y1) ; vertical up on left ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>_UIA_DrawRect Func getDescription($ac) $s1 = DllStructGetData($ac, "name") $s2 = DllStructGetData($ac, "description") $s3 = DllStructGetData($ac, "role") $s4 = DllStructGetData($ac, "role_en_US") $s5 = DllStructGetData($ac, "states") $s6 = DllStructGetData($ac, "states_en_US") $s7 = DllStructGetData($ac, "indexInParent") $s8 = DllStructGetData($ac, "childrenCount") $s9 = DllStructGetData($ac, "x") $s10 = DllStructGetData($ac, "y") $s11 = DllStructGetData($ac, "width") $s12 = DllStructGetData($ac, "height") $s13 = DllStructGetData($ac, "accessibleComponent") $s14 = DllStructGetData($ac, "accessibleAction") ConsoleWrite(" name: <" & $s1 & ">" & @CRLF) ConsoleWrite(" description: <" & $s2 & ">" & @CRLF) ConsoleWrite(" role: <" & $s3 & ">" & @CRLF) ConsoleWrite(" role_en_US: <" & $s4 & ">" & @CRLF) ConsoleWrite(" states: <" & $s5 & ">" & @CRLF) ConsoleWrite(" states_en_US: <" & $s6 & ">" & @CRLF) ConsoleWrite(" indexInParent: <" & $s7 & ">" & @CRLF) ConsoleWrite(" childrenCount: <" & $s8 & ">" & @CRLF) ConsoleWrite(" x: <" & $s9 & ">" & @CRLF) ConsoleWrite(" y: <" & $s10 & ">" & @CRLF) ConsoleWrite(" width: <" & $s11 & ">" & @CRLF) ConsoleWrite(" height: <" & $s12 & ">" & @CRLF) ConsoleWrite(" accessibleComponent: <" & $s13 & ">" & @CRLF) ConsoleWrite(" accessibleAction: <" & $s14 & ">" & @CRLF) Return $s1 & @CRLF & $s2 & @CRLF & $s3 & @CRLF & $s4 & @CRLF & $s5 & @CRLF & $s6 & @CRLF & $s7 & @CRLF & $s8 & @CRLF & $s9 & @CRLF & $s10 & @CRLF & $s11 & @CRLF & $s12 & @CRLF & $s13 & @CRLF & $s14 & @CRLF EndFunc ;==>getDescription Source JAVAUI.au3 expandcollapse popup;~ ******* ;~ Every AccessibleContext IntPtr must be replaced by long, including but not limited to getAccessibleContextFromHWND, getAccessibleParentFromContext, getAccessibleChildFromContext, getAccessibleTextInf ;~ JOBJECT64 is defined as jlong on 64-bit systems and jobject on legacy versions of Java Access Bridge. For definitions, see the section ACCESSBRIDGE_ARCH_LEGACY in the AccessBridgePackages.h header file. ;~ #ifdef ACCESSBRIDGE_ARCH_LEGACY ;~ typedef jobject JOBJECT64; ;~ typedef HWND ABHWND64; ;~ #else ;~ typedef jlong JOBJECT64; ;~ typedef long ABHWND64; ;~ #endif ;~ a jobject is a 32 bit pointer for 32 bit builds ;~ 'bool' is a built-in C++ type while 'BOOL' is a Microsoft specific type that is defined as an 'int'. You can find it in 'windef.h' ;~ ;~ ** jni_md.h ** ;~ typedef long jint; ;~ typedef __int64 jlong; ;~ typedef signed char jbyte; ;~ ******* ;~ accessbridgecalls.h ;~ typedef JOBJECT64 AccessibleContext; ;~ typedef JOBJECT64 AccessibleText; ;~ typedef JOBJECT64 AccessibleValue; ;~ typedef JOBJECT64 AccessibleSelection; ;~ typedef JOBJECT64 Java_Object; ;~ typedef JOBJECT64 PropertyChangeEvent; ;~ typedef JOBJECT64 FocusEvent; ;~ typedef JOBJECT64 CaretEvent; ;~ typedef JOBJECT64 MouseEvent; ;~ typedef JOBJECT64 MenuEvent; ;~ typedef JOBJECT64 AccessibleTable; ;~ typedef JOBJECT64 AccessibleHyperlink; ;~ typedef JOBJECT64 AccessibleHypertext; ;~ Primitive Types and Native Equivalents ;~ Java Type Native Type Description ;~ boolean jboolean unsigned 8 bits ;~ byte jbyte signed 8 bits ;~ char jchar unsigned 16 bits ;~ short jshort signed 16 bits ;~ int jint signed 32 bits ;~ long jlong signed 64 bits ;~ float jfloat 32 bits ;~ double jdouble 64 bits ;~ void void not applicable ;#AutoIt3Wrapper_UseX64 = y #include <array.au3> Global Const $c_JOBJECT64 = "UINT64" ;~ JOBJECT64 Global Const $cP_JOBJECT64 = "UINT64*" ;~ POINTER(JOBJECT64) ;=====================================Accessibility information================================ Global Const $MAX_BUFFER_SIZE = 10240 Global Const $MAX_STRING_SIZE = 1024 Global Const $SHORT_STRING_SIZE = 256 Global Const $tagAccessBridgeVersionInfo = _ "WCHAR VMversion[256];" & _ ; output of "java -version" "WCHAR bridgeJavaClassVersion[256];" & _ ; version of the AccessBridge.class "WCHAR bridgeJavaDLLVersion[256];" & _ ; version of JavaAccessBridge.dll "WCHAR bridgeWinDLLVersion[256]" ; version of WindowsAccessBridge.dll Global Const $tagAccessibleContextInfo = _ "WCHAR name[1024];" & _ ; the AccessibleName of the object "WCHAR description[1024];" & _ ; the AccessibleDescription of the object "WCHAR role[256];" & _ ; localized AccesibleRole string "WCHAR role_en_US[256];" & _ ; AccesibleRole string in the en_US locale "WCHAR states[256];" & _ ; localized AccesibleStateSet string (comma separated) "WCHAR states_en_US[256];" & _ ; AccesibleStateSet string in the en_US locale (comma separated) "INT indexInParent;" & _ ; index of object in parent "INT childrenCount;" & _ ; # of children, if any "INT x;" & _ ; screen x-axis co-ordinate in pixels "INT y;" & _ ; screen y-axis co-ordinate in pixels "INT width;" & _ ; pixel width of object "INT height;" & _ ; pixel height of object "BOOL accessibleComponent;" & _ ; flags for various additional Java Accessibility interfaces "BOOL accessibleAction;" & _ "BOOL accessibleSelection;" & _ ; FALSE if this object does not implement the additional interface in question "BOOL accessibleText;" & _ "BOOL accessibleInterfaces" ; new bitfield containing additional interface flags Global Const $tagAccessibleTextInfo = _ "INT charCount;" & _ ; # of characters in this text object "INT caretIndex;" & _ ; index of caret "INT indexAtPoint" ; index at the passsed in point Global Const $tagAccessibleTextItemsInfo = _ "WCHAR letter;" & _ "WCHAR word[256];" & _ "WCHAR sentence[1024]" Global Const $tagAccessibleTextSelectionInfo = _ "INT selectionStartIndex;" & _ "INT selectionEndIndex;" & _ "WCHAR selectedText[1024]" Global Const $tagAccessibleTextRectInfo = _ "INT x;" & _ ; bounding recttangle of char at index, x-axis co-ordinate "INT y;" & _ ; y-axis co-ordinate "INT width;" & _ ; bounding rectangle width "INT height" ; bounding rectangle height Global Const $tagAccessibleTextAttributesInfo = _ "BOOL bold;" & _ "BOOL italic;" & _ "BOOL underline;" & _ "BOOL strikethrough;" & _ "BOOL superscript;" & _ "BOOL subscript;" & _ "WCHAR backgroundColor[256];" & _ "WCHAR foregroundColor[256];" & _ "WCHAR fontFamily[256];" & _ "INT fontSize;" & _ "INT alignment;" & _ "INT bidiLevel;" & _ "FLOAT firstLineIndent;" & _ "FLOAT LeftIndent;" & _ "FLOAT rightIndent;" & _ "FLOAT lineSpacing;" & _ "FLOAT spaceAbove;" & _ "FLOAT spaceBelow;" & _ "WCHAR fullAttributesString[1024]" ;=====================================AccessibleTable================================ Global Const $MAX_TABLE_SELECTIONS = 64 Global Const $tagAccessibleTableInfo = _ "UINT64 caption;" & _ ; AccessibleContext "UINT64 summary;" & _ ; AccessibleContext "INT rowCount;" & _ "INT columnCount;" & _ "UINT64 accessibleContext;" & _ "UINT64 accessibleTable" Global Const $tagAccessibleTableCellInfo = _ "UINT64 accessibleContext;" & _ "INT index;" & _ "INT row;" & _ "INT column;" & _ "INT rowExtent;" & _ "INT columnExtent;" & _ "BOOL isSelected" ;=====================================AccessibleRelationSet================================ Global Const $MAX_RELATION_TARGETS = 25 Global Const $MAX_RELATIONS = 5 Global Const $tagAccessibleRelationInfo = _ "WCHAR key[256];" & _ "INT targetCount;" & _ "UINT64 targets[25]" ; AccessibleContexts Local $tag_Relations = "" For $i = 1 To 5 If $tag_Relations = "" Then $tag_Relations = $tagAccessibleRelationInfo Else $tag_Relations = $tag_Relations & ";" & $tagAccessibleRelationInfo EndIf Next Global Const $tagAccessibleRelationSetInfo = _ "INT relationCount;" & _ $tag_Relations ; $tAccessibleRelationInfo relations[5] ;=====================================AccessibleHypertext================================ Global Const $MAX_HYPERLINKS = 64 ;~ maximum number of hyperlinks returned Global Const $tagAccessibleHyperlinkInfo = _ "WCHAR text[256];" & _ ; the hyperlink text "INT startIndex;" & _ ; index in the hypertext document where the link begins "INT endIndex;" & _ ; index in the hypertext document where the link ends "UINT64 accessibleHyperlink" ; AccessibleHyperlink object Local $tag_Links = "" For $i = 1 To 64 If $tag_Links = "" Then $tag_Links = $tagAccessibleHyperlinkInfo Else $tag_Links = $tag_Links & ";" & $tagAccessibleHyperlinkInfo EndIf Next Global Const $tagAccessibleHypertextInfo = _ "INT linkCount;" & _ ; number of hyperlinks $tag_Links & ";" & _ ; the hyperlinks ,$tAccessibleHyperlinkInfo links[64] "UINT64 accessibleHypertext" ; AccessibleHypertext object ;=====================================Accessible Key Bindings================================ Global Const $MAX_KEY_BINDINGS = 8 Global Const $tagAccessibleKeyBindingInfo = _ "WCHAR character;" & _ ; the key character "INT modifiers" ; the key modifiers Local $tag_KeyBindingInfo = "" For $i = 1 To 8 If $tag_KeyBindingInfo = "" Then $tag_KeyBindingInfo = $tagAccessibleKeyBindingInfo Else $tag_KeyBindingInfo = $tag_KeyBindingInfo & ";" & $tagAccessibleKeyBindingInfo EndIf Next Global Const $tagAccessibleKeyBindings = _ "INT keyBindingsCount;" & _ ; number of key bindings $tag_KeyBindingInfo ; $tAccessibleKeyBindingInfo keyBindingInfo[8] ;=====================================AccessibleIcon================================ Global Const $MAX_ICON_INFO = 8 Global Const $tagAccessibleIconInfo = _ "WCHAR description[256];" & _ ; icon description "INT height;" & _ ; icon height "INT width" ; icon width Local $tag_IconInfo = "" For $i = 1 To 8 If $tag_IconInfo = "" Then $tag_IconInfo = $tagAccessibleIconInfo Else $tag_IconInfo = $tag_IconInfo & ";" & $tagAccessibleIconInfo EndIf Next Global Const $tagAccessibleIcon = _ "INT iconsCount;" & _ ; number of icons $tag_IconInfo ; the icons ,$tAccessibleIconInfo iconInfo[8] ;=====================================AccessibleAction================================ Global Const $MAX_ACTION_INFO = 256 Global Const $MAX_ACTIONS_TO_DO = 32 Global Const $tagAccessibleActionInfo = _ "WCHAR name[256]" Local $tag_ActionInfo = "" For $i = 1 To 256 If $tag_ActionInfo = "" Then $tag_ActionInfo = $tagAccessibleActionInfo Else $tag_ActionInfo = $tag_ActionInfo & ";" & $tagAccessibleActionInfo EndIf Next Global Const $tagAccessibleActions = _ "INT actionsCount;" & _ $tag_ActionInfo ; $tAccessibleActionInfo actionInfo[256] Local $tag_Actions = "" For $i = 1 To 32 If $tag_Actions = "" Then $tag_Actions = $tagAccessibleActionInfo Else $tag_Actions = $tag_Actions & ";" & $tagAccessibleActionInfo EndIf Next Global Const $tagAccessibleActionsToDo = _ "INT actionsCount;" & _ $tag_Actions ; $tAccessibleActions actions[32] ;=====================================VisibleChilden================================ Global Const $MAX_VISIBLE_CHILDREN = 256 Global Const $tagVisibleChildenInfo = _ "INT returnedChildrenCount;" & _ ; number of children returned "UINT64 children[256]" ; the visible children Global $hAccessBridgeDll ;~ reference to the accessbridge dll _JAB_init() Func _JAB_init() ;~ Determine java location Local $sJavaVersion Local $sJavaHome Local $sAccessBridgeDLL If @AutoItX64 <> 1 Then Local $sJavaReg = "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment" $sJavaVersion = RegRead($sJavaReg, "CurrentVersion") $sJavaHome = RegRead($sJavaReg & "\" & $sJavaVersion, "JavaHome") ElseIf @AutoItX64 = 1 Then Local $sJavaReg64 = "HKLM64\SOFTWARE\JavaSoft\Java Runtime Environment" Local $sJavaReg32 = "HKLM64\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment" $sJavaVersion = RegRead(((@AutoItX64) ? $sJavaReg64 : $sJavaReg32 ), "CurrentVersion") $sJavaHome = RegRead(((@AutoItX64) ? $sJavaReg64 : $sJavaReg32 ) & "\" & $sJavaVersion, "JavaHome") EndIf If $sJavaHome = "" Then consolewrite(" Unable to find Java Registry using hardcoded value" & @CRLF) $sJavaHome = "C:\Program Files\Java\jdk1.8.0_172\jre" EndIf consolewrite(" Java Home: " & $sJavaHome & @CRLF) ;~ TODO: Check which dll that Autoit can work with, still can't find eazy way to work with both dlls consolewrite(" We are using OS " & @OSArch & " at cpu " & @CPUArch & "; Autoit 64 bit version @AutoItX64="& @AutoItX64 & @CRLF) ;~ Only Autoit 64 bit version can open WindowsAccessBridge-64.dll, so use @AutoItX64 to decide which WindowsAccessBridge can be opened $sAccessBridgeDLL = (@AutoItX64) ? "WindowsAccessBridge-64.dll" : "WindowsAccessBridge-32.dll" ;~ Open the Dll for accessibility consolewrite($sJavaHome & "\bin\" & $sAccessBridgeDLL) $hAccessBridgeDll = DllOpen($sJavaHome & "\bin\" & $sAccessBridgeDLL) If $hAccessBridgeDll <> -1 Then ConsoleWrite(" PASS: Windows accessbridge " & $sAccessBridgeDLL & " opened returns: " & $hAccessBridgeDll & @CRLF) Else ConsoleWrite(" ERROR: Windows accessbridge " & $sAccessBridgeDLL & " open failed returns: " & $hAccessBridgeDll & @CRLF) Return EndIf ;~ Make sure Java Access Bridge is turned on Runwait($sJavaHome & "\bin\jabswitch /enable","",@SW_MAXIMIZE) ;~ TODO: Handle messages received from initialize $result = __Windows_run() consolewrite(@error & " Windows_run returns: " & $result & @CRLF) ;$result = __initializeAccessBridge() ;consolewrite($result & " " & @error & " initializeAccessBridge is finished" & @CRLF) EndFunc Func _JAB_shutDown() __shutdownAccessBridge() EndFunc Func _JAB_getName($vmId, $ac) Local $acInfo = DllStructCreate($tagAccessibleContextInfo) __getAccessibleContextInfo($vmId, $ac, $acInfo) Return DllStructGetData($acInfo, "name") EndFunc Func _JAB_getRole($vmId, $ac) Local $acInfo = DllStructCreate($tagAccessibleContextInfo) __getAccessibleContextInfo($vmId, $ac, $acInfo) Return DllStructGetData($acInfo, "role") EndFunc Func _JAB_getIndexInParent($vmId, $ac) Local $acInfo = DllStructCreate($tagAccessibleContextInfo) __getAccessibleContextInfo($vmId, $ac, $acInfo) Return DllStructGetData($acInfo, "indexInParent") EndFunc Func _JAB_getChildrenCount($vmId, $ac) Local $acInfo = DllStructCreate($tagAccessibleContextInfo) __getAccessibleContextInfo($vmId, $ac, $acInfo) Return DllStructGetData($acInfo, "childrenCount") EndFunc ;~ Must use the AccessibleContext got from the win handle which include the target element Func _JAB_getAccessibleContextByFindAll($vmId, $ac, $sName, $sRole) Local $find_ac = 0 Local $iCount =_JAB_getChildrenCount($vmId, $ac) If $iCount = 0 Then Return EndIf For $i = 0 To $iCount - 1 Local $child_ac = __getAccessibleChildFromContext($vmId, $ac, $i) Local $s1 = _JAB_getName($vmId, $child_ac) Local $s3 = _JAB_getRole($vmId, $child_ac) ;~ consolewrite($child_ac & "|" & $s1 & "," & $s3 & @CRLF) If $s1 = $sName And $s3 = $sRole Then ;~ consolewrite("FOUND:" & $child_ac & "|" & $s1 & "," & $s3 & @CRLF) $find_ac = $child_ac ExitLoop Else If $find_ac = 0 Then $find_ac = _JAB_getAccessibleContextByFindAll($vmId, $child_ac, $sName, $sRole) EndIf EndIf Next Return $find_ac EndFunc ;~ $next can be negative Func _JAB_getNextSibling($vmId, $ac, $next = 1) If Not IsInt($next) Then consolewrite("_JAB_findNextSibling: $next must be int" & @CRLF) Return EndIf Local $s7 = _JAB_getIndexInParent($vmId, $ac) Local $parent_ac = __getAccessibleParentFromContext($vmId, $ac) Local $parent_s8 = _JAB_getChildrenCount($vmId, $parent_ac) If $s7 + $next >= 0 and $s7 + $next <= $parent_s8 - 1 Then Local $sibling_ac = __getAccessibleChildFromContext($vmId, $parent_ac, $s7 + $next) Return $sibling_ac EndIf EndFunc Func _JAB_getFirstChildByRole($vmId, $ac, $sRole) Local $iCount = _JAB_getChildrenCount($vmId, $ac) consolewrite("Investigating" & $iCount) If $iCount = 0 Then Return EndIf Local $re1 = -1 For $i = 0 To $iCount - 1 Local $child_ac = __getAccessibleChildFromContext($vmId, $ac, $i) Local $child_ac_s3 = _JAB_getRole($vmId, $child_ac) If $child_ac_s3 = $sRole Then $re1 = $child_ac Return $child_ac ExitLoop EndIf Next If $re1 = -1 Then consolewrite("_JAB_getFirstChildByRole: " & $sRole & " is not found" & @CRLF) Return EndIf EndFunc ;~ list element's actions Func _JAB_getAllActions($vmId, $ac) Local $actions = DllStructCreate($tagAccessibleActions) __getAccessibleActions($vmId, $ac, $actions) Local $s1 = DllStructGetData($actions, "actionsCount") If $s1 = 0 Then consolewrite("_JAB_findAllActions: this element has no action" & @CRLF) Return EndIf Local $re = "" For $i = 2 To $s1 + 1 Local $s = $i&"|"&DllStructGetData($actions, $i)&@CRLF If $re = "" Then $re = $s Else $re = $re & $s EndIf Next Return $re EndFunc ;~ Only applicable for single action element like button or check box, menu, menu item Func _JAB_singleAction($vmId, $ac) Local $actions = DllStructCreate($tagAccessibleActions) Local $actionsToDo = DllStructCreate($tagAccessibleActionsToDo) __getAccessibleActions($vmId, $ac, $actions) Local $s1 = DllStructGetData($actions, "actionsCount") Local $s2 = DllStructGetData($actions, 2) If $s1 <> 1 Then consolewrite("_JAB_singleAction: Only applicable for single action element like button or check box, menu, menu item" & @CRLF) Return EndIf Local $failure DllStructSetData($actionsToDo, "actionsCount", 1) DllStructSetData($actionsToDo, 2, $s2) __doAccessibleActions($vmId, $ac, $actionsToDo, $failure) EndFunc Func _JAB_setValue($vmId, $ac, $sValue) Local $actions = DllStructCreate($tagAccessibleActions) __getAccessibleActions($vmId, $ac, $actions) Local $s1 = DllStructGetData($actions, "actionsCount") If $s1 = 0 Then consolewrite("_JAB_setValue: this element has no action" & @CRLF) Return EndIf Local $re1 = 0 Local $re2 = 0 For $i = 2 To $s1 + 1 Local $s = DllStructGetData($actions, $i) If $s = "select-all" Then $re1 = 1 ExitLoop EndIf Next If $re1 = 0 Then consolewrite("_JAB_setValue: this element doesn't support select-all action" & @CRLF) Return EndIf For $i = 2 To $s1 + 1 Local $s = DllStructGetData($actions, $i) If $s = "paste-from-clipboard" Then $re2 = 1 ExitLoop EndIf Next If $re2 = 0 Then consolewrite("_JAB_setValue: this element doesn't support paste-from-clipboard action" & @CRLF) Return EndIf Local $actionsToDo = DllStructCreate($tagAccessibleActionsToDo) Local $failure ClipPut($sValue) DllStructSetData($actionsToDo, "actionsCount", 2) DllStructSetData($actionsToDo, 2, "select-all") DllStructSetData($actionsToDo, 3, "paste-from-clipboard") __doAccessibleActions($vmId, $ac, $actionsToDo, $failure) EndFunc Func _JAB_getValue($vmId, $ac) Local $actions = DllStructCreate($tagAccessibleActions) __getAccessibleActions($vmId, $ac, $actions) Local $s1 = DllStructGetData($actions, "actionsCount") If $s1 = 0 Then consolewrite("_JAB_getValue: this element has no action" & @CRLF) Return EndIf Local $re1 = 0 For $i = 2 To $s1 + 1 Local $s = DllStructGetData($actions, $i) If $s = "copy-to-clipboard" Then $re1 = 1 ExitLoop EndIf Next If $re1 = 0 Then consolewrite("_JAB_getValue: this element doesn't support copy-to-clipboard action" & @CRLF) Return EndIf ;~ empty the clipboard ClipPut("") Local $actionsToDo = DllStructCreate($tagAccessibleActionsToDo) Local $failure DllStructSetData($actionsToDo, "actionsCount", 1) DllStructSetData($actionsToDo, 2, "copy-to-clipboard") __doAccessibleActions($vmId, $ac, $actionsToDo, $failure) Return ClipGet() EndFunc Func _JAB_selectCheckBox($vmId, $ac) Local $acInfo = DllStructCreate($tagAccessibleContextInfo) __getAccessibleContextInfo($vmId, $ac, $acInfo) Local $s3 = DllStructGetData($acInfo, "role") If $s3 <> "check box" Then consolewrite("_JAB_selectCheckBox: this element isn't check box" & @CRLF) Return EndIf Local $s6 = DllStructGetData($acInfo, "states_en_US") If StringInStr($s6, "checked") Then Return Else _JAB_singleAction($vmId, $ac) EndIf EndFunc Func _JAB_unselectCheckBox($vmId, $ac) Local $acInfo = DllStructCreate($tagAccessibleContextInfo) __getAccessibleContextInfo($vmId, $ac, $acInfo) Local $s3 = DllStructGetData($acInfo, "role") If $s3 <> "check box" Then consolewrite("_JAB_unselectCheckBox: this element isn't check box" & @CRLF) Return EndIf Local $s6 = DllStructGetData($acInfo, "states_en_US") If StringInStr($s6, "checked") Then _JAB_singleAction($vmId, $ac) EndIf EndFunc ;~ scroll pane-->viewport-->table ;~ |-->scroll bar ;~ |-->scroll bar ;~ |-->viewport-->panel-->panel:column1 ;~ |-->panel:column2 ;~ Must use unique name to find column ac Func _JAB_getTableFromColumn($vmId, $ac) Local $p1_ac = __getAccessibleParentFromContext($vmId, $ac) Local $p2_ac = __getAccessibleParentFromContext($vmId, $p1_ac) Local $s3 = _JAB_getRole($vmId, $p2_ac) If $s3 <> "viewport" Then consolewrite("_JAB_getTableFromColumn: find wrong column viewport" & @CRLF) Return EndIf Local $p3_ac = __getAccessibleParentFromContext($vmId, $p2_ac) Local $iCount = _JAB_getChildrenCount($vmId, $p3_ac) For $i = 0 To $iCount - 1 Local $child_ac = __getAccessibleChildFromContext($vmId, $p3_ac, $i) Local $child_s3 = _JAB_getRole($vmId, $child_ac) If $child_s3 = "viewport" Then ;~ first child is table, begin from 0 Local $grandson_ac = __getAccessibleChildFromContext($vmId, $child_ac, 0) Local $grandson_s3 = _JAB_getRole($vmId, $grandson_ac) If $grandson_s3 = "table" Then Return $grandson_ac ExitLoop EndIf EndIf Next EndFunc ;~ row and column begin from 0 Func _JAB_getTableCellText($vmId, $ac, $iRow = 0, $iColumn = 0) If Not IsInt($iRow) Or Not IsInt($iColumn) Then consolewrite("_JAB_getTableCellText: $iRow and $iColumn must be int" & @CRLF) Return EndIf Local $s3 = _JAB_getRole($vmId, $ac) If $s3 <> "table" Then consolewrite("_JAB_getTableCellText: this element isn't table" & @CRLF) Return EndIf Local $tableInfo = DllStructCreate($tagAccessibleTableInfo) __getAccessibleTableInfo($vmId, $ac, $tableInfo) Local $table_s3 = DllStructGetData($tableInfo, "rowCount") Local $table_s4 = DllStructGetData($tableInfo, "columnCount") Local $table_s6 = DllStructGetData($tableInfo, "accessibleTable") If $iRow < 0 Or $iRow > $table_s3 - 1 Then consolewrite("_JAB_getTableCellText: $iRow out of range" & @CRLF) Return EndIf If $iColumn < 0 Or $iColumn > $table_s4 - 1 Then consolewrite("_JAB_getTableCellText: $iColumn out of range" & @CRLF) Return EndIf Local $tableCellInfo = DllStructCreate($tagAccessibleTableCellInfo) __getAccessibleTableCellInfo($vmId, $table_s6, $iRow, $iColumn, $tableCellInfo) Local $cell_s1 = DllStructGetData($tableCellInfo, "accessibleContext") Return _JAB_getName($vmId, $cell_s1) EndFunc Func _JAB_selectAFromTableWhereB($vmId, $ac, $iColumnA, $iColumnB, $sB) If Not IsInt($iColumnA) Or Not IsInt($iColumnB) Then consolewrite("_JAB_selectAFromTableWhereB: $iColumnA and $iColumnB must be int" & @CRLF) Return EndIf Local $s3 = _JAB_getRole($vmId, $ac) If $s3 <> "table" Then consolewrite("_JAB_selectAFromTableWhereB: this element isn't table" & @CRLF) Return EndIf Local $tableInfo = DllStructCreate($tagAccessibleTableInfo) __getAccessibleTableInfo($vmId, $ac, $tableInfo) Local $table_s3 = DllStructGetData($tableInfo, "rowCount") Local $table_s4 = DllStructGetData($tableInfo, "columnCount") Local $table_s6 = DllStructGetData($tableInfo, "accessibleTable") If $iColumnA < 0 Or $iColumnA > $table_s4 - 1 Then consolewrite("_JAB_selectAFromTableWhereB: $iColumnA out of range" & @CRLF) Return EndIf If $iColumnB < 0 Or $iColumnB > $table_s4 - 1 Then consolewrite("_JAB_selectAFromTableWhereB: $iColumnB out of range" & @CRLF) Return EndIf Local $re = -1 For $i = 0 To $table_s3 - 1 Local $tableCellInfo = DllStructCreate($tagAccessibleTableCellInfo) __getAccessibleTableCellInfo($vmId, $table_s6, $i, $iColumnB, $tableCellInfo) Local $cell_s1 = DllStructGetData($tableCellInfo, "accessibleContext") Local $s1 = _JAB_getName($vmId, $cell_s1) If StringInStr($s1, $sB) Then $re = 1 __getAccessibleTableCellInfo($vmId, $table_s6, $i, $iColumnA, $tableCellInfo) Local $cell_s2 = DllStructGetData($tableCellInfo, "accessibleContext") Return _JAB_getName($vmId, $cell_s2) ExitLoop EndIf Next If $re = -1 Then consolewrite("_JAB_selectAFromTableWhereB: " & $sB & " is not found" & @CRLF) Return EndIf EndFunc Func _JAB_menuSelectItem($vmId, $ac, $item1 = "", $item2 = "", $item3 = "", $item4 = "", $item5 = "", $item6 = "") Local $s3 = _JAB_getRole($vmId, $ac) If $s3 <> "menu" Then consolewrite("_JAB_menuSelectItem: this element isn't menu" & @CRLF) Return EndIf _JAB_singleAction($vmId, $ac) Sleep(250) If $item1 <> "" Then Local $re1 = -1 Local $iCount = _JAB_getChildrenCount($vmId, $ac) For $i = 0 To $iCount - 1 Local $ac1 = __getAccessibleChildFromContext($vmId, $ac, $i) Local $ac1_s1 = _JAB_getName($vmId, $ac1) If StringInStr($ac1_s1, $item1) Then _JAB_singleAction($vmId, $ac1) Sleep(250) $re1 = $ac1 ExitLoop EndIf Next If $re1 = -1 Then consolewrite("_JAB_menuSelectItem: " & $item1 & " is not found" & @CRLF) Return EndIf If $item2 <> "" Then Local $re2 = -1 Local $iCount = _JAB_getChildrenCount($vmId, $re1) For $i = 0 To $iCount - 1 Local $ac2 = __getAccessibleChildFromContext($vmId, $re1, $i) Local $ac2_s1 = _JAB_getName($vmId, $ac2) If StringInStr($ac2_s1, $item2) Then _JAB_singleAction($vmId, $ac2) Sleep(250) $re2 = $ac2 ExitLoop EndIf Next If $re2 = -1 Then consolewrite("_JAB_menuSelectItem: " & $item2 & " is not found" & @CRLF) Return EndIf If $item3 <> "" Then Local $re3 = -1 Local $iCount = _JAB_getChildrenCount($vmId, $re2) For $i = 0 To $iCount - 1 Local $ac3 = __getAccessibleChildFromContext($vmId, $re2, $i) Local $ac3_s1 = _JAB_getName($vmId, $ac3) If StringInStr($ac3_s1, $item3) Then _JAB_singleAction($vmId, $ac3) Sleep(250) $re3 = $ac3 ExitLoop EndIf Next If $re3 = -1 Then consolewrite("_JAB_menuSelectItem: " & $item3 & " is not found" & @CRLF) Return EndIf If $item4 <> "" Then Local $re4 = -1 Local $iCount = _JAB_getChildrenCount($vmId, $re3) For $i = 0 To $iCount - 1 Local $ac4 = __getAccessibleChildFromContext($vmId, $re3, $i) Local $ac4_s1 = _JAB_getName($vmId, $ac4) If StringInStr($ac4_s1, $item4) Then _JAB_singleAction($vmId, $ac4) Sleep(250) $re4 = $ac4 ExitLoop EndIf Next If $re4 = -1 Then consolewrite("_JAB_menuSelectItem: " & $item4 & " is not found" & @CRLF) Return EndIf If $item5 <> "" Then Local $re5 = -1 Local $iCount = _JAB_getChildrenCount($vmId, $re4) For $i = 0 To $iCount - 1 Local $ac5 = __getAccessibleChildFromContext($vmId, $re4, $i) Local $ac5_s1 = _JAB_getName($vmId, $ac5) If StringInStr($ac5_s1, $item5) Then _JAB_singleAction($vmId, $ac5) Sleep(250) $re5 = $ac5 ExitLoop EndIf Next If $re5 = -1 Then consolewrite("_JAB_menuSelectItem: " & $item5 & " is not found" & @CRLF) Return EndIf If $item6 <> "" Then Local $re6 = -1 Local $iCount = _JAB_getChildrenCount($vmId, $re5) For $i = 0 To $iCount - 1 Local $ac6 = __getAccessibleChildFromContext($vmId, $re5, $i) Local $ac6_s1 = _JAB_getName($vmId, $ac6) If StringInStr($ac6_s1, $item6) Then _JAB_singleAction($vmId, $ac6) Sleep(250) $re6 = $ac6 ExitLoop EndIf Next If $re6 = -1 Then consolewrite("_JAB_menuSelectItem: " & $item6 & " is not found" & @CRLF) Return EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndFunc ;~ combo box-->popup menu-->scroll pane-->viewport-->list- ;~ | |-->label 0 ;~ | |-->label 1 ;~ | |-->label 2 ;~ | |-->label 3 ;~ -->scroll bar Func _JAB_comboBoxSelectItem($vmId, $ac, $listItem) Local $s3 = _JAB_getRole($vmId, $ac) If $s3 <> "combo box" Then consolewrite("_JAB_comboBoxSelectItem: this element isn't combo box" & @CRLF) Return EndIf Local $popup_ac = _JAB_getFirstChildByRole($vmId, $ac, "popup menu") If $popup_ac = "" Then consolewrite("_JAB_comboBoxSelectItem: popup menu is not found" & @CRLF) Return EndIf Local $scroll_ac = _JAB_getFirstChildByRole($vmId, $popup_ac, "scroll pane") If $scroll_ac = "" Then consolewrite("_JAB_comboBoxSelectItem: scroll pane is not found" & @CRLF) Return EndIf Local $viewport_ac = _JAB_getFirstChildByRole($vmId, $scroll_ac, "viewport") If $viewport_ac = "" Then consolewrite("_JAB_comboBoxSelectItem: viewport is not found" & @CRLF) Return EndIf Local $list_ac = _JAB_getFirstChildByRole($vmId, $viewport_ac, "list") If $list_ac = "" Then consolewrite("_JAB_comboBoxSelectItem: list is not found" & @CRLF) Return EndIf Local $re2 = -1 Local $iCount = _JAB_getChildrenCount($vmId, $list_ac) For $i = 0 To $iCount - 1 Local $child_ac = __getAccessibleChildFromContext($vmId, $list_ac, $i) Local $child_ac_s1 = _JAB_getName($vmId, $child_ac) If StringInStr($child_ac_s1 ,$listItem) Then $re2 = $i ExitLoop EndIf Next If $re2 = -1 Then consolewrite("_JAB_comboBoxSelectItem: " & $listItem & " is not found" & @CRLF) Return EndIf __addAccessibleSelectionFromContext($vmId, $ac, $re2) EndFunc ;~ _fixBridgeFunc(None,'Windows_run') Func __Windows_run() $result = DllCall($hAccessBridgeDll, "NONE", "Windows_run") If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ _fixBridgeFunc(None,'setFocusGainedFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyNameChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyDescriptionChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyValueChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyStateChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyCaretChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyActiveDescendentChangeFP',c_void_p) ;========================================Initialization/Shutdown Functions========================================== ; Starts Java Access Bridge. You can't use any part of the Java Access Bridge API until you call this function. Func __initializeAccessBridge() $result = DllCall($hAccessBridgeDll, "NONE", "initializeAccessBridge") If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; Shuts down Java Access Bridge. Func __shutdownAccessBridge() $result = DllCall($hAccessBridgeDll, "NONE", "shutdownAccessBridge") If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;========================================Gateway Functions========================================================= ;~ BOOL IsJavaWindow(HWND window) ; Checks to see if the given window implements the Java Accessibility API. Func __isJavaWindow($hwnd) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "isJavaWindow", "hwnd", $hwnd) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ BOOL GetAccessibleContextFromHWND(HWND target, long *vmID, AccessibleContext *ac) ; Returns the virtual machine ID and AccessibleContext for a top-level window. Func __getAccessibleContextFromHWND($hwnd, byref $vmID, byref $ac) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleContextFromHWND", "hwnd", $hwnd, "long*", $vmId, $cP_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) $vmID = $result[2] $ac = $result[3] Return $result[0] EndFunc ;========================================General Functions========================================================= ;~ void ReleaseJavaObject(long vmID, Java_Object object) ; Release the memory used by the Java object object, where object is an object returned to you by Java Access Bridge. Func __releaseJavaObject($vmId, $object) $result = DllCall($hAccessBridgeDll, "NONE", "releaseJavaObject", "long", $vmId, $c_JOBJECT64, $object) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ BOOL GetVersionInfo(long vmID, AccessBridgeVersionInfo *info) ; Gets the version information of the instance of Java Access Bridge instance your application is using. ; $tAccessBridgeVersionInfo $info Func __getVersionInfo($vmId, byref $info) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getVersionInfo", "long", $vmId, "struct*", $info) If @error Then Return SetError(1, 0, 0) $info = $result[2] Return $result[0] EndFunc ;========================================Accessible Context Functions========================================================= ;~ BOOL GetAccessibleContextAt(long vmID, AccessibleContext acParent, jint x, jint y, AccessibleContext *ac) ; Retrieves an AccessibleContext object of the window or object that is under the mouse pointer. Func __getAccessibleContextAt($vmId, $acParent, $x, $y, byref $ac) ;~ Seems not to be allowed to call with null so passing $acParent $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleContextAt", "long", $vmId, $c_JOBJECT64, $acParent, "int", $x, "int", $y, $cP_JOBJECT64, $ac) consolewrite(@error) If @error Then Return SetError(1, 0, 0) $ac = $result[5] Return $result[0] EndFunc ;~ BOOL GetAccessibleContextWithFocus(HWND window, long *vmID, AccessibleContext *ac) ; Retrieves an AccessibleContext object of the window or object that has the focus. Func __getAccessibleContextWithFocus($hwnd, byref $vmID, byref $ac) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleContextWithFocus", "hwnd", $hwnd, "long*", $vmId, $cP_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) $vmID = $result[2] $ac = $result[3] Return $result[0] EndFunc ;~ BOOL GetAccessibleContextInfo(long vmID, AccessibleContext ac, AccessibleContextInfo *info) ; Retrieves an AccessibleContextInfo object of the AccessibleContext object ac. ; $tAccessibleContextInfo $info Func __getAccessibleContextInfo($vmId, $ac, byref $info) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleContextInfo", "long", $vmId, $c_JOBJECT64, $ac, "struct*", $info) If @error Then Return SetError(1, 0, 0) $info = $result[3] Return $result[0] EndFunc ;~ AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint index)) ; Returns an AccessibleContext object that represents the nth child of the object ac, where n is specified by the value index. Func __getAccessibleChildFromContext($vmId, $ac, $index) ;~ Seems not to be allowed to call with null so passing $acParent $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getAccessibleChildFromContext", "long", $vmId, $c_JOBJECT64, $ac, "int", $index) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ AccessibleContext GetAccessibleParentFromContext(long vmID, AccessibleContext ac) ; Returns an AccessibleContext object that represents the parent of object ac. Func __getAccessibleParentFromContext($vmId, $ac) $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getAccessibleParentFromContext", "long", $vmId, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ HWND getHWNDFromAccessibleContext(long vmID, AccessibleContext ac) ; Returns the HWND from the AccessibleContextof a top-level window. Func __getHWNDFromAccessibleContext($vmId, $ac) $result = DllCall($hAccessBridgeDll, "hwnd", "getHWNDFromAccessibleContext", "long", $vmId, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;========================================Accessible Text Functions========================================================= ;~ BOOL GetAccessibleTextInfo(long vmID, AccessibleText at, AccessibleTextInfo *textInfo, jint x, jint y) ; $tAccessibleTextInfo $textInfo Func __getAccessibleTextInfo($vmId, $at, byref $textInfo, $x, $y) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTextInfo", "long", $vmId, $c_JOBJECT64, $at, "struct*", $textInfo, "int", $x, "int", $y) If @error Then Return SetError(1, 0, 0) $textInfo = $result[3] Return $result[0] EndFunc ;~ BOOL GetAccessibleTextItems(long vmID, AccessibleText at, AccessibleTextItemsInfo *textItems, jint index) ; $tAccessibleTextItemsInfo $textItems Func __getAccessibleTextItems($vmId, $at, byref $textItems, $index) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTextItems", "long", $vmId, $c_JOBJECT64, $at, "struct*", $textItems, "int", $index) If @error Then Return SetError(1, 0, 0) $textItems = $result[3] Return $result[0] EndFunc ;~ BOOL GetAccessibleTextSelectionInfo(long vmID, AccessibleText at, AccessibleTextSelectionInfo *textSelection) ; $tAccessibleTextSelectionInfo $textSelection Func __getAccessibleTextSelectionInfo($vmId, $at, byref $textSelection) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTextSelectionInfo", "long", $vmId, $c_JOBJECT64, $at, "struct*", $textSelection) If @error Then Return SetError(1, 0, 0) $textSelection = $result[3] Return $result[0] EndFunc ;~ BOOL GetAccessibleTextAttributes(long vmID, AccessibleText at, jint index, AccessibleTextAttributesInfo *attributes) ; $tAccessibleTextAttributesInfo $attributes Func __getAccessibleTextAttributes($vmId, $at, $index, byref $attributes) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTextAttributes", "long", $vmId, $c_JOBJECT64, $at, "int", $index, "struct*", $attributes) If @error Then Return SetError(1, 0, 0) $attributes = $result[4] Return $result[0] EndFunc ; BOOL GetAccessibleTextRect(long vmID, AccessibleText at, AccessibleTextRectInfo *rectInfo, jint index); ; $tAccessibleTextRectInfo $rectInfo Func __getAccessibleTextRect($vmId, $at, byref $rectInfo, $index) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTextRect", "long", $vmId, $c_JOBJECT64, $at, "struct*", $rectInfo, "int", $index) If @error Then Return SetError(1, 0, 0) $attributes = $result[3] Return $result[0] EndFunc ;~ BOOL GetAccessibleTextRange(long vmID, AccessibleText at, jint start, jint end, wchar_t *text, short len) Func __getAccessibleTextRange($vmId, $at, $start, $end, $text, $len) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTextRange", "long", $vmId, $c_JOBJECT64, $at, "int", $start, "int", $end, "wstr", $text, "short", $len) If @error Then Return SetError(1, 0, 0) $text = $result[5] Return $result[0] EndFunc ;~ BOOL GetAccessibleTextLineBounds(long vmID, AccessibleText at, jint index, jint *startIndex, jint *endIndex) Func __getAccessibleTextLineBounds($vmId, $at, $index, byref $startIndex, byref $endIndex) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTextLineBounds", "long", $vmId, $c_JOBJECT64, $at, "int", $index, "int*", $startIndex, "int*", $endIndex) If @error Then Return SetError(1, 0, 0) $startIndex = $result[4] $endIndex = $result[5] Return $result[0] EndFunc ;========================================Additional Text Functions========================================================= ;~ _fixBridgeFunc(BOOL,'selectTextRange',c_long,JOBJECT64,c_int,c_int,errcheck=True) ; Selects text between two indices. Selection includes the text at the start index and the text at the end index. ; AccessibleContext $ac Func __selectTextRange($vmId, $ac, $startIndex, $endIndex) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "selectTextRange", "long", $vmId, $c_JOBJECT64, $ac, "int", $startIndex, "int", $endIndex) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ _fixBridgeFunc(BOOL,'getTextAttributesInRange',c_long,JOBJECT64,c_int,c_int,POINTER(AccessibleTextAttributesInfo),POINTER(c_short),errcheck=True) ; Get text attributes between two indices. The attribute list includes the text at the start index and the text at the end index. ; AccessibleContext $ac ; $tAccessibleTextAttributesInfo $attributes Func __getTextAttributesInRange($vmId, $ac, $startIndex, $endIndex, byref $attributes, byref $len) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getTextAttributesInRange", "long", $vmId, $c_JOBJECT64, $ac, "int", $startIndex, "int", $endIndex, "struct*", $attributes, "short*", $len) If @error Then Return SetError(1, 0, 0) $attributes = $result[5] $len = $result[6] Return $result[0] EndFunc ;~ _fixBridgeFunc(BOOL,'setCaretPosition',c_long,JOBJECT64,c_int,errcheck=True) ; Set the caret to a text position. ; AccessibleContext $ac Func __setCaretPosition($vmId, $ac, $position) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "setCaretPosition", "long", $vmId, $c_JOBJECT64, $ac, "int", $position) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ _fixBridgeFunc(BOOL,'getCaretLocation',c_long,JOBJECT64,POINTER(AccessibleTextRectInfo),jint,errcheck=True) ; Gets the text caret location. ; AccessibleContext $ac ; $tAccessibleTextRectInfo $rectInfo Func __getCaretLocation($vmId, $ac, byref $rectInfo, $position) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getCaretLocation", "long", $vmId, $c_JOBJECT64, $ac, "struct*", $position, "int", $position) If @error Then Return SetError(1, 0, 0) $rectInfo = $result[3] Return $result[0] EndFunc ; BOOL setTextContents (const long vmID, const AccessibleContext accessibleContext, const wchar_t *text) ; Sets editable text contents. The AccessibleContext must implement AccessibleEditableText and be editable. The maximum text length that can be set is MAX_STRING_SIZE - 1. Returns whether successful. ; AccessibleContext $ac Func __setTextContents($vmId, $ac, $text) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "setTextContents", "long", $vmId, $c_JOBJECT64, $ac, "wstr", $text) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;========================================Accessible Table Functions========================================================= ;~ BOOL getAccessibleTableInfo(long vmID, AccessibleContext acParent, AccessibleTableInfo *tableInfo) ; Returns information about the table, for example, caption, summary, row and column count, and the AccessibleTable. ; $tAccessibleTableInfo $tableInfo Func __getAccessibleTableInfo($vmId, $acParent, byref $tableInfo) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTableInfo", "long", $vmId, $c_JOBJECT64, $acParent, "struct*", $tableInfo) If @error Then Return SetError(1, 0, 0) $tableInfo = $result[3] Return $result[0] EndFunc ;~ BOOL getAccessibleTableCellInfo(long vmID, AccessibleTable accessibleTable, jint row, jint column, AccessibleTableCellInfo *tableCellInfo) ; Returns information about the specified table cell. The row and column specifiers are zero-based. ; $tAccessibleTableCellInfo $tableCellInfo Func __getAccessibleTableCellInfo($vmId, $table, $row, $column, byref $tableCellInfo) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTableCellInfo", "long", $vmId, $c_JOBJECT64, $table, "int", $row, "int", $column, "struct*", $tableCellInfo) If @error Then Return SetError(1, 0, 0) $tableCellInfo = $result[5] Return $result[0] EndFunc ;~ BOOL getAccessibleTableRowHeader(long vmID, AccessibleContext acParent, AccessibleTableInfo *tableInfo) ; Returns the table row headers of the specified table as a table. ; $tAccessibleTableInfo $tableInfo Func __getAccessibleTableRowHeader($vmId, $acParent, byref $tableInfo) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTableRowHeader", "long", $vmId, $c_JOBJECT64, $acParent, "struct*", $tableInfo) If @error Then Return SetError(1, 0, 0) $tableInfo = $result[3] Return $result[0] EndFunc ;~ BOOL getAccessibleTableColumnHeader(long vmID, AccessibleContext acParent, AccessibleTableInfo *tableInfo) ; Returns the table column headers of the specified table as a table. ; $tAccessibleTableInfo $tableInfo Func __getAccessibleTableColumnHeader($vmId, $acParent, byref $tableInfo) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTableColumnHeader", "long", $vmId, $c_JOBJECT64, $acParent, "struct*", $tableInfo) If @error Then Return SetError(1, 0, 0) $tableInfo = $result[3] Return $result[0] EndFunc ;~ AccessibleContext getAccessibleTableRowDescription(long vmID, AccessibleContext acParent, jint row) ; Returns the description of the specified row in the specified table. The row specifier is zero-based. Func __getAccessibleTableRowDescription($vmId, $acParent, $row) $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getAccessibleTableRowDescription", "long", $vmId, $c_JOBJECT64, $acParent, "int", $row) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ AccessibleContext getAccessibleTableColumnDescription(long vmID, AccessibleContext acParent, jint column) ; Returns the description of the specified column in the specified table. The column specifier is zero-based. Func __getAccessibleTableColumnDescription($vmId, $acParent, $column) $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getAccessibleTableColumnDescription", "long", $vmId, $c_JOBJECT64, $acParent, "int", $column) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; jint getAccessibleTableRowSelectionCount(long vmID, AccessibleTable table) ; Returns how many rows in the table are selected. Func __getAccessibleTableRowSelectionCount($vmId, $table) $result = DllCall($hAccessBridgeDll, "int:cdecl", "getAccessibleTableRowSelectionCount", "long", $vmId, $c_JOBJECT64, $table) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; BOOL isAccessibleTableRowSelected(long vmID, AccessibleTable table, jint row) ; Returns true if the specified zero based row is selected. Func __isAccessibleTableRowSelected($vmId, $table, $row) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "isAccessibleTableRowSelected", "long", $vmId, $c_JOBJECT64, $table, "int", $row) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; BOOL getAccessibleTableRowSelections(long vmID, AccessibleTable table, jint count, jint *selections) ; Returns an array of zero based indices of the selected rows. Func __getAccessibleTableRowSelections($vmId, $table, $count, byref $selections) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTableRowSelections", "long", $vmId, $c_JOBJECT64, $table, "int", $count, "int*", $selections) If @error Then Return SetError(1, 0, 0) $selections = $result[4] Return $result[0] EndFunc ; jint getAccessibleTableColumnSelectionCount(long vmID, AccessibleTable table) ; Returns how many columns in the table are selected. Func __getAccessibleTableColumnSelectionCount($vmId, $table) $result = DllCall($hAccessBridgeDll, "int:cdecl", "getAccessibleTableColumnSelectionCount", "long", $vmId, $c_JOBJECT64, $table) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; BOOL isAccessibleTableColumnSelected(long vmID, AccessibleTable table, jint column) ; Returns true if the specified zero based column is selected. Func __isAccessibleTableColumnSelected($vmId, $table, $column) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "isAccessibleTableColumnSelected", "long", $vmId, $c_JOBJECT64, $table, "int", $column) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; BOOL getAccessibleTableColumnSelections(long vmID, AccessibleTable table, jint count, jint *selections) ; Returns an array of zero based indices of the selected columns. Func __getAccessibleTableColumnSelections($vmId, $table, $count, byref $selections) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleTableColumnSelections", "long", $vmId, $c_JOBJECT64, $table, "int", $count, "int*", $selections) If @error Then Return SetError(1, 0, 0) $selections = $result[4] Return $result[0] EndFunc ;~ jint getAccessibleTableRow(long vmID, AccessibleTable table, jint index) ; Returns the row number of the cell at the specified cell index. The values are zero based. Func __getAccessibleTableRow($vmId, $table, $index) $result = DllCall($hAccessBridgeDll, "int:cdecl", "getAccessibleTableRow", "long", $vmId, $c_JOBJECT64, $table, "int", $index) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ jint getAccessibleTableColumn(long vmID, AccessibleTable table, jint index) ; Returns the column number of the cell at the specified cell index. The values are zero based. Func __getAccessibleTableColumn($vmId, $table, $index) $result = DllCall($hAccessBridgeDll, "int:cdecl", "getAccessibleTableColumn", "long", $vmId, $c_JOBJECT64, $table, "int", $index) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ jint getAccessibleTableIndex(long vmID, AccessibleTable table, jint row, jint column) ; Returns the index in the table of the specified row and column offset. The values are zero based. Func __getAccessibleTableIndex($vmId, $table, $row, $column) $result = DllCall($hAccessBridgeDll, "int:cdecl", "getAccessibleTableIndex", "long", $vmId, $c_JOBJECT64, $table, "int", $row, "int", $column) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;========================================Accessible Relation Set Function========================================================= ;~ BOOL getAccessibleRelationSet(long vmID, AccessibleContext accessibleContext, AccessibleRelationSetInfo *relationSetInfo) ; Returns information about an object's related objects. ; $tAccessibleRelationInfo $relationSetInfo Func __getAccessibleRelationSet($vmId, $ac, byref $relationSetInfo) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleRelationSet", "long", $vmId, $c_JOBJECT64, $ac, "struct*", $relationSetInfo) If @error Then Return SetError(1, 0, 0) $relationSetInfo = $result[3] Return $result[0] EndFunc ;========================================Accessible Hypertext Functions========================================================= ; BOOL getAccessibleHypertext(long vmID, AccessibleContext accessibleContext, AccessibleHypertextInfo *hypertextInfo) ; Returns hypertext information associated with a component. ; $tAccessibleHyperlinkInfo $hypertextInfo Func __getAccessibleHypertext($vmId, $ac, byref $hypertextInfo) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleHypertext", "long", $vmId, $c_JOBJECT64, $ac, "struct*", $hypertextInfo) If @error Then Return SetError(1, 0, 0) $hypertextInfo = $result[3] Return $result[0] EndFunc ; BOOL activateAccessibleHyperlink(long vmID, AccessibleContext accessibleContext, AccessibleHyperlink accessibleHyperlink) ; Requests that a hyperlink be activated. Func __activateAccessibleHyperlink($vmId, $ac, $accessibleHyperlink) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "activateAccessibleHyperlink", "long", $vmId, $c_JOBJECT64, $ac, $c_JOBJECT64, $accessibleHyperlink) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; jint getAccessibleHyperlinkCount(const long vmID, const AccessibleHypertext hypertext) ; Returns the number of hyperlinks in a component. Maps to AccessibleHypertext.getLinkCount. Returns -1 on error. Func __getAccessibleHyperlinkCount($vmId, $hypertext) $result = DllCall($hAccessBridgeDll, "int:cdecl", "getAccessibleHyperlinkCount", "long", $vmId, $c_JOBJECT64, $hypertext) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; BOOL getAccessibleHypertextExt(const long vmID, const AccessibleContext accessibleContext, const jint nStartIndex, AccessibleHypertextInfo *hypertextInfo) ; Iterates through the hyperlinks in a component. Returns hypertext information for a component starting at hyperlink index nStartIndex. No more than MAX_HYPERLINKS AccessibleHypertextInfo objects will be returned for each call to this method. Returns FALSE on error. ; $tAccessibleHyperlinkInfo $hypertextInfo Func __getAccessibleHypertextExt($vmId, $ac, $nStartIndex, byref $hypertextInfo) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleHypertextExt", "long", $vmId, $c_JOBJECT64, $ac, "int", $nStartIndex, "struct*", $hypertextInfo) If @error Then Return SetError(1, 0, 0) $hypertextInfo = $result[4] Return $result[0] EndFunc ; jint getAccessibleHypertextLinkIndex(const long vmID, const AccessibleHypertext hypertext, const jint nIndex) ; Returns the index into an array of hyperlinks that is associated with a character index in document. Maps to AccessibleHypertext.getLinkIndex. Returns -1 on error. Func __getAccessibleHypertextLinkIndex($vmId, $hypertext, $nIndex) $result = DllCall($hAccessBridgeDll, "int:cdecl", "getAccessibleHypertextLinkIndex", "long", $vmId, $c_JOBJECT64, $hypertext, "int", $nIndex) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; BOOL getAccessibleHyperlink(const long vmID, const AccessibleHypertext hypertext, const jint nIndex, AccessibleHypertextInfo *hyperlinkInfo) ; Returns the nth hyperlink in a document. Maps to AccessibleHypertext.getLink. Returns FALSE on error. ; $tAccessibleHyperlinkInfo $hypertextInfo Func __getAccessibleHyperlink($vmId, $hypertext, $nIndex, byref $hypertextInfo) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleHyperlink", "long", $vmId, $c_JOBJECT64, $hypertext, "int", $nIndex, "struct*", $hypertextInfo) If @error Then Return SetError(1, 0, 0) $hypertextInfo = $result[4] Return $result[0] EndFunc ;========================================Accessible Key Binding Function========================================================= ;~ BOOL getAccessibleKeyBindings(long vmID, AccessibleContext accessibleContext, AccessibleKeyBindings *keyBindings) ; Returns a list of key bindings associated with a component. ; $tAccessibleKeyBindings $keyBindings Func __getAccessibleKeyBindings($vmId, $ac, byref $keyBindings) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleKeyBindings", "long", $vmId, $c_JOBJECT64, $ac, "struct*", $keyBindings) If @error Then Return SetError(1, 0, 0) $keyBindings = $result[3] Return $result[0] EndFunc ;========================================Accessible Icon Function========================================================= ; BOOL getAccessibleIcons(long vmID, AccessibleContext accessibleContext, AccessibleIcons *icons) ; Returns a list of icons associate with a component. ; $tAccessibleIconInfo $icons Func __getAccessibleIcons($vmId, $ac, byref $icons) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleIcons", "long", $vmId, $c_JOBJECT64, $ac, "struct*", $icons) If @error Then Return SetError(1, 0, 0) $icons = $result[3] Return $result[0] EndFunc ;========================================Accessible Action Functions========================================================= ;~ BOOL getAccessibleActions(long vmID, AccessibleContext accessibleContext, AccessibleActions *actions) ; Returns a list of actions that a component can perform. ; $tAccessibleActions $actions Func __getAccessibleActions($vmId, $ac, byref $actions) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleActions", "long", $vmId, $c_JOBJECT64, $ac, "struct*", $actions) If @error Then Return SetError(1, 0, 0) $actions = $result[3] Return $result[0] EndFunc ;~ BOOL doAccessibleActions(long vmID, AccessibleContext accessibleContext, AccessibleActionsToDo *actionsToDo, jint *failure) ; Request that a list of AccessibleActions be performed by a component. ; $tAccessibleActionsToDo $actionsToDo Func __doAccessibleActions($vmId, $ac, byref $actionsToDo, byref $failure) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "doAccessibleActions", "long", $vmId, $c_JOBJECT64, $ac, "struct*", $actionsToDo, "int*", $failure) If @error Then Return SetError(1, 0, 0) $actionsToDo = $result[3] $failure = $result[4] Return $result[0] EndFunc ;========================================Utility Functions========================================================= ;~ BOOL IsSameObject(long vmID, JOBJECT64 obj1, JOBJECT64 obj2) ; Returns whether two object references refer to the same object. Func __isSameObject($vmId, $obj1, $obj2) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "isSameObject", "long", $vmId, $c_JOBJECT64, $obj1, $c_JOBJECT64, $obj2) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ AccessibleContext getParentWithRole (const long vmID, const AccessibleContext accessibleContext, const wchar_t *role) ;Returns the AccessibleContext with the specified role that is the ancestor of a given object. The role is one of the role strings defined in Java Access Bridge API Data Stuctures. Func __getParentWithRole($vmId, $ac, $role) $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getParentWithRole", "long", $vmId, $c_JOBJECT64, $ac, "wstr", $role) If @error Then Return SetError(1, 0, 0) $role = $result[3] Return $result[0] EndFunc ; AccessibleContext getParentWithRoleElseRoot(const long vmID, const AccessibleContext accessibleContext, const wchar_t *role); ; Returns the AccessibleContext with the specified role that is the ancestor of a given object. If an object with the specified role does not exist, returns the top level object for the Java Window. Func __getParentWithRoleElseRoot($vmId, $ac, $role) $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getParentWithRoleElseRoot", "long", $vmId, $c_JOBJECT64, $ac, "wstr", $role) If @error Then Return SetError(1, 0, 0) $role = $result[3] Return $result[0] EndFunc ;~ AccessibleContext getTopLevelObject (const long vmID, const AccessibleContext accessibleContext) ; Returns the AccessibleContext for the top level object in a Java window. Func __getTopLevelObject($vmId, $ac) $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getTopLevelObject", "long", $vmId, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) ;~ _ArrayDisplay($result) Return $result[0] EndFunc ;~ int getObjectDepth (const long vmID, const AccessibleContext accessibleContext) ; Returns how deep in the object hierarchy a given object is. The top most object in the object hierarchy has an object depth of 0. Returns -1 on error. Func __getObjectDepth($vmId, $ac) $result = DllCall($hAccessBridgeDll, "int:cdecl", "getObjectDepth", "long", $vmId, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ AccessibleContext getActiveDescendent (const long vmID, const AccessibleContext accessibleContext) ; Returns the AccessibleContext of the current ActiveDescendent of an object. This method assumes the ActiveDescendent is the component that is currently selected in a container object. Func __getActiveDescendent($vmId, $ac) $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getActiveDescendent", "long", $vmId, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ BOOL requestFocus(const long vmID, const AccessibleContext accessibleContext) ; Request focus for a component. Returns whether successful. Func __requestFocus($vmId, $ac) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "requestFocus", "long", $vmId, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ int getVisibleChildrenCount(const long vmID, const AccessibleContext accessibleContext) ; Returns the number of visible children of a component. Returns -1 on error. Func __getVisibleChildrenCount($vmId, $ac) $result = DllCall($hAccessBridgeDll, "int:cdecl", "getVisibleChildrenCount", "long", $vmId, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; BOOL getVisibleChildren(const long vmID, const AccessibleContext accessibleContext, const int startIndex, VisibleChildrenInfo *visibleChildrenInfo); ; Gets the visible children of an AccessibleContext. Returns whether successful. ; $tVisibleChildenInfo $visibleChildrenInfo Func __getVisibleChildren($vmId, $ac, $startIndex, byref $visibleChildrenInfo) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getVisibleChildren", "long", $vmId, $c_JOBJECT64, $ac, "int", $startIndex, "struct*", $visibleChildrenInfo) If @error Then Return SetError(1, 0, 0) $visibleChildrenInfo = $result[4] Return $result[0] EndFunc ; int getEventsWaiting() ; Gets the number of events waiting to fire. Func __getEventsWaiting() $result = DllCall($hAccessBridgeDll, "int:cdecl", "getEventsWaiting") If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;========================================Accessible Value Functions========================================================= ;~ BOOL GetCurrentAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_t *value, short len) Func __getCurrentAccessibleValueFromContext($vmId, $av, $value, $len) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getCurrentAccessibleValueFromContext", "long", $vmId, $c_JOBJECT64, $av, "wstr", $value, "short", $len) If @error Then Return SetError(1, 0, 0) $value = $result[3] Return $result[0] EndFunc ; BOOL GetMaximumAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_ *value, short len) Func __getMaximumAccessibleValueFromContext($vmId, $av, $value, $len) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getMaximumAccessibleValueFromContext", "long", $vmId, $c_JOBJECT64, $av, "wstr", $value, "short", $len) If @error Then Return SetError(1, 0, 0) $value = $result[3] Return $result[0] EndFunc ; BOOL GetMinimumAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_ *value, short len) Func __getMinimumAccessibleValueFromContext($vmId, $av, $value, $len) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getMinimumAccessibleValueFromContext", "long", $vmId, $c_JOBJECT64, $av, "wstr", $value, "short", $len) If @error Then Return SetError(1, 0, 0) $value = $result[3] Return $result[0] EndFunc ;========================================Accessible Selection Functions========================================================= ; void AddAccessibleSelectionFromContext(long vmID, AccessibleSelection as, int i) Func __addAccessibleSelectionFromContext($vmId, $as, $i) $result = DllCall($hAccessBridgeDll, "NONE", "addAccessibleSelectionFromContext", "long", $vmId, $c_JOBJECT64, $as, "int", $i) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; void ClearAccessibleSelectionFromContext(long vmID, AccessibleSelection as) Func __clearAccessibleSelectionFromContext($vmId, $as) $result = DllCall($hAccessBridgeDll, "NONE", "clearAccessibleSelectionFromContext", "long", $vmId, $c_JOBJECT64, $as) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; jobject GetAccessibleSelectionFromContext(long vmID, AccessibleSelection as, int i) Func __getAccessibleSelectionFromContext($vmId, $as, $i) $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getAccessibleSelectionFromContext", "long", $vmId, $c_JOBJECT64, $as, "int", $i) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; int GetAccessibleSelectionCountFromContext(long vmID, AccessibleSelection as) Func __getAccessibleSelectionCountFromContext($vmId, $as) $result = DllCall($hAccessBridgeDll, "int:cdecl", "getAccessibleSelectionCountFromContext", "long", $vmId, $c_JOBJECT64, $as) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; BOOL IsAccessibleChildSelectedFromContext(long vmID, AccessibleSelection as, int i) Func __isAccessibleChildSelectedFromContext($vmId, $as, $i) $result = DllCall($hAccessBridgeDll, "bool:cdecl", "isAccessibleChildSelectedFromContext", "long", $vmId, $c_JOBJECT64, $as, "int", $i) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; void RemoveAccessibleSelectionFromContext(long vmID, AccessibleSelection as, int i) Func __removeAccessibleSelectionFromContext($vmId, $as, $i) $result = DllCall($hAccessBridgeDll, "NONE", "removeAccessibleSelectionFromContext", "long", $vmId, $c_JOBJECT64, $as, "int", $i) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ; void SelectAllAccessibleSelectionFromContext(long vmID, AccessibleSelection as) Func __selectAllAccessibleSelectionFromContext($vmId, $as) $result = DllCall($hAccessBridgeDll, "NONE", "selectAllAccessibleSelectionFromContext", "long", $vmId, $c_JOBJECT64, $as) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc Full demo as was described in thread on page 3 expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <constants.au3> #include <WinAPI.au3> #include <WinAPIEx.au3> #include <debug.au3> #include <memory.au3> #include <Misc.au3> #include "JavaUI.au3" Global $__g_vmId ;~ Holds the global JVM ID (in case you have running multiple java programs you can expect different id's) Global $__g_acJavaMainWindow ;~ The accessibility context (ac) to the main java window Global $__g_acJavaDialogWindow ;~ The accessibility context (ac) to the java popup dialog window Global $__g_hwndJavaWindow ;~ The hwnd to the main Java Control Panel Window Global $__g_hwndJavaDialogWindow ;~ The hwnd to the java popup dialog window Global $__g_acJavaTLO main() func main() startJavaProgram() Local $wintitle = "Java Control Panel" $__g_hwndJavaWindow = WinActivate($wintitle) $result = __isJavaWindow($__g_hwndJavaWindow) __getAccessibleContextFromHWND($__g_hwndJavaWindow, $__g_vmId, $__g_acJavaMainWindow) ;~ Get our vmid into the global variable printMainWindowInformation() ;Works ok sleep(250) handleMainWindow() sleep(2500) handlePopupPage() sleep(250) $okButton= _JAB_getAccessibleContextByFindAll($__g_vmId, $__g_acJavaMainWindow, "Ok", "push button") _JAB_singleAction($__g_vmId, $okButton) sleep(1500) EndFunc func handleMainWindow() printTopLevelObjectInformation() ;~ In general its equal to java main window ;Works ok sleep(250) handleAboutButton() ;Works ok sleep(250) clickSecurityTab() ;Works ok sleep(250) clickSiteListButton();Works ok sleep(250) EndFunc func handlePopupPage() ;~ Main window ;~ So now we have a new window which we should determine before we can continue sleep(2000) consolewrite("Handle popup functionn" & @CRLF) $__g_hwndJavaDialogWindow= WinGetHandle("[TITLE:Exception Site List]","") ;~ Local $winHandle2= WinGetHandle("[CLASS:SunAwtDialog]","") ;~ Local $winHandle2= WinGetHandle("[ACTIVE]","") consolewrite( "Handle sunawt: " & $__g_hwndJavaDialogWindow & "(" & Dec(hex($__g_hwndJavaDialogWindow)) & ") from vm: " & $__g_vmId & @CRLF) ;~ winListInfo() ;~As above was troublesome to get right window some debughelper consolewrite("Main information" & @CRLF) __getAccessibleContextFromHWND($__g_hwndJavaDialogWindow, $__g_vmId, $__g_acJavaDialogWindow) consolewrite( "Handle sunawt 2: " & $__g_hwndJavaDialogWindow & "(" & Dec(hex($__g_hwndJavaDialogWindow)) & ") from vm: " & $__g_vmId & @CRLF) consolewrite("Returned ac : " & $__g_acJavaDialogWindow & @CRLF) highLightAC($__g_vmId,$__g_acJavaDialogWindow) $AddButton= _JAB_getAccessibleContextByFindAll($__g_vmId, $__g_acJavaDialogWindow, "Add", "push button") _JAB_singleAction($__g_vmId, $AddButton) ;~ Most likely we have to deal with information in the table ;~ $table= _JAB_getAccessibleContextByRole($__g_vmId, $__g_acJavaDialogWindow, "table",1) $table= _JAB_getAccessibleChildNByRole($__g_vmId, $__g_acJavaDialogWindow, "table",1) highLightAC($__g_vmId, $table) local $tableInfo=DllStructCreate($tagAccessibleTableInfo) __getAccessibleTableInfo($__g_vmId, $table, $tableInfo) ;~ So we now know the row and col count printDescriptionTable($tableInfo) ;~ TODO: ;~ $textBox= _JAB_getAccessibleContextByFindAll($__g_vmId, $__g_acJavaDialogWindow, "", "text") ;~ local $textBox ;~ __getAccessibleContextWithFocus($__g_hwndJavaDialogWindow, $__g_vmId, $textBox) ;~ __setTextContents($__g_vmId, $textBox, "https://www.autoitscript.com") ;~ _JAB_setvalue($__g_vmId, $textBox, "https://www.autoitscript.com") send("https://www.autoitscript.com") send("{ENTER}") sleep(1500) $okButton= _JAB_getAccessibleContextByFindAll($__g_vmId, $__g_acJavaDialogWindow, "Ok", "push button") _JAB_singleAction($__g_vmId, $okButton) sleep(1500) EndFunc func clickSiteListButton() $SiteListButton= _JAB_getAccessibleContextByFindAll($__g_vmId, $__g_acJavaMainWindow, "Edit Site List...", "push button") highLightAC($__g_vmId, $SiteListButton) printdescription($SiteListButton) sleep(2500) ;~ TODO: Somewhere here it hangs ;~ consolewrite("Just before it causes a blocking ..." & @CRLF) ;~ _JAB_singleAction($__g_vmId, $SiteListButton) ;~ consolewrite("Just after it causes a blocking ..." & @CRLF) clickac($__g_vmId, $SiteListButton) sleep(1500) __releaseJavaObject($__g_vmId, $SiteListButton) ;~ consolewrite("Just after it causes a blocking ... 2" & @CRLF) EndFunc func printMainWindowInformation() local $acInfo= DllStructCreate($tagAccessibleContextInfo) ;~ Main window consolewrite("Main information" & @CRLF) __getAccessibleContextInfo($__g_vmId, $__g_acJavaMainWindow, $acInfo) printDescription($acInfo) __releaseJavaObject($__g_vmId, $acInfo) ;~ Just for showing how to get a button by index showInfoPushButton(1) sleep(250) showInfoPushButton(2) sleep(250) showInfoPushButton(3) sleep(250) EndFunc func printTopLevelObjectInformation() local $acInfo= DllStructCreate($tagAccessibleContextInfo) consolewrite("Top Level Object information" & $__g_vmId & @CRLF) local $acJavaTLO $acJavaTLO=__getTopLevelObject($__g_vmId, $__g_acJavaMainWindow) consolewrite("TLO" & $__g_acJavaTLO & @CRLF) __getAccessibleContextInfo($__g_vmId, $acJavaTLO, $acInfo) printDescription($acInfo) __releaseJavaObject($__g_vmId, $acInfo) __releaseJavaObject($__g_vmId, $acJavaTLO) endfunc func startJavaProgram() shellexecute("C:\Program Files\Java\jdk1.8.0_172\jre\bin\javacpl.exe") sleep(3000) EndFunc func handleAboutButton() Local $sName = "About..." Local $sRole = "push button" ;~ Local $acInfo2 = DllStructCreate($tagAccessibleContextInfo) handleButton($sName, $sRole) endFunc func showInfoPushButton($index=1) ;~ First pushbutton by type/role ;~ local $re_ac=_JAB_getAccessibleContextByRole($__g_vmId, $__g_acJavaMainWindow, "push button", 1) local $re_ac=_JAB_getAccessibleChildNByRole($__g_vmId, $__g_acJavaMainWindow, "push button", $index) highLightAC($__g_vmId, $re_ac) printInfoPushButton($re_ac) __releaseJavaObject($__g_vmId, $re_ac) EndFunc func printInfoPushbutton($ac) ;~ Details from first pushbutton consolewrite("Button information" & @CRLF) local $sName = _JAB_getName($__g_vmId, $ac) Local $acInfo = DllStructCreate($tagAccessibleContextInfo) __getAccessibleContextInfo($__g_vmId, $ac, $acInfo) $acX = DllStructGetData($acInfo, "x") $acY = DllStructGetData($acInfo, "y") $acW = DllStructGetData($acInfo, "width") $acH = DllStructGetData($acInfo, "height") ConsoleWrite("Name:" & $sName & @CRLF) ConsoleWrite(" rect:" & $acX & $acX+$acW & $acy & $acY+$acH & @CRLF) printDescription($acInfo) __releaseJavaObject($__g_vmId, $acInfo) EndFunc func handleButton($sName, $sRole) ;~ First pushbutton by type/role with matching title/name local $ac = _JAB_getAccessibleContextByFindAll($__g_vmId, $__g_acJavaMainWindow, $sName, $sRole) $sName = _JAB_getName($__g_vmId, $ac) ;~ Details from first pushbutton Local $acInfo = DllStructCreate($tagAccessibleContextInfo) __getAccessibleContextInfo($__g_vmId, $ac, $acInfo) printDescription($acinfo) __releaseJavaObject($__g_vmId, $acInfo) __releaseJavaObject($__g_vmId, $ac) EndFunc func clickSecurityTab() ;- Find security tabpage local $SecurityTab = _JAB_getAccessibleContextByFindAll($__g_vmId, $__g_acJavaMainWindow, "Security", "page tab") ;~ Accessible action not supported according to access bridge explorer ;~ TODO: define tag/interface AccessibleComponent to call request focus Local $acInfo = DllStructCreate($tagAccessibleContextInfo) __getAccessibleContextInfo($__g_vmId, $SecurityTab, $acInfo) $blnAccessibleComponent = DllStructGetData($acInfo, "accessibleComponent") $blnAccessibleAction = DllStructGetData($acInfo, "accessibleAction") consolewrite("accessibleComponent supported: " & $blnAccessibleComponent & @CRLF) consolewrite("accessibleAction supported: " & $blnAccessibleAction & @CRLF) $acX = DllStructGetData($acInfo, "x") $acY = DllStructGetData($acInfo, "y") $acW = DllStructGetData($acInfo, "width") $acH = DllStructGetData($acInfo, "height") ConsoleWrite("rect:" & $acX & $acX+$acW & $acy & $acY+$acH & @CRLF) _UIA_DrawRect($acX, $acX+$acW, $acy,$acY+$acH) sleep(500) __requestFocus($__g_vmId,$SecurityTab) ;~ TODO: Screen not refreshed when requesting focus Return ;~ Many ways to click, for demo in 2 steps mousemove(int($acx+($acw/2)), int($acy +($ach/2))) MouseClick($MOUSE_CLICK_LEFT) ;~ _JAB_singleAction($vmId, $SecurityTab) not possible so we should have interface iAccessibleComponent.requestfocus or as done above move mouse and click __releaseJavaObject($__g_vmId, $acInfo) __releaseJavaObject($__g_vmId, $SecurityTab) EndFunc func clickAC($vmid, $ac) Local $acInfo = DllStructCreate($tagAccessibleContextInfo) __getAccessibleContextInfo($vmid, $ac, $acInfo) $acX = DllStructGetData($acInfo, "x") $acY = DllStructGetData($acInfo, "y") $acW = DllStructGetData($acInfo, "width") $acH = DllStructGetData($acInfo, "height") ConsoleWrite("rect:" & $acX & $acX+$acW & $acy & $acY+$acH & @CRLF) _UIA_DrawRect($acX, $acX+$acW, $acy,$acY+$acH) sleep(500) ;~ Many ways to click, for demo in 2 steps mousemove(int($acx+($acw/2)), int($acy +($ach/2))) MouseClick($MOUSE_CLICK_LEFT) ;~ _JAB_singleAction($vmId, $SecurityTab) not possible so we should have interface iAccessibleComponent.requestfocus or as done above move mouse and click __releaseJavaObject($__g_vmId, $acInfo) EndFunc Func _JAB_getAccessibleChildNByRole($vmId, $ac, $sRole,$index=1, $depth=0) Static $matchCount=0 if ($depth=0) then $matchCount=0 EndIf Local $iCount = _JAB_getChildrenCount($vmId, $ac) ;~ consolewrite("Investigating" & $iCount & ";" & $index & ";" & $matchCount & ";" & _JAB_getRole($vmId, $ac) & ";") If $iCount = 0 Then Return -1 EndIf local $retVal=-1 For $i = 0 To $iCount - 1 Local $child_ac = __getAccessibleChildFromContext($vmId, $ac, $i) Local $child_ac_s3 = _JAB_getRole($vmId, $child_ac) ;~ consolewrite($child_ac_s3 & @CRLF) If $child_ac_s3 = $sRole Then $matchCount+=1 ;~ consolewrite("Partial match" & $matchCount & @CRLF) if $index=$matchCount Then ;~ consolewrite("Full match" & $matchCount & @CRLF) Return $child_ac endif EndIf $depth+=1 local $retVal=_JAB_getAccessibleChildNByRole($vmId, $child_ac, $sRole, $index, $depth) if ($retVal <>-1) Then exitloop EndIf Next Return $retVal EndFunc ;~ Must use the AccessibleContext got from the win handle which include the target element Func _JAB_getAccessibleContextByRole($vmId, $ac, $sRole, $sIndex) Local $find_ac = 0 Local $iCount =_JAB_getChildrenCount($vmId, $ac) If $iCount = 0 Then Return EndIf For $i = 0 To $iCount - 1 Local $child_ac = __getAccessibleChildFromContext($vmId, $ac, $i) Local $s3 = _JAB_getRole($vmId, $child_ac) ; consolewrite($child_ac & "|" & $s1 & "," & $s3 & @CRLF) If $s3 = $sRole Then $find_ac = $child_ac ExitLoop Else If $find_ac = 0 Then $find_ac = _JAB_getAccessibleContextByRole($vmId, $child_ac, $sRole, $sIndex) EndIf EndIf Next Return $find_ac EndFunc Func _JAB_setValue2($vmId, $ac, $sValue) Local $actions = DllStructCreate($tagAccessibleActions) __getAccessibleActions($vmId, $ac, $actions) Local $s1 = DllStructGetData($actions, "actionsCount") If $s1 = 0 Then consolewrite("_JAB_setValue: this element has no action" & @CRLF) Return EndIf Local $re1 = 0 Local $re2 = 0 For $i = 2 To $s1 + 1 Local $s = DllStructGetData($actions, $i) If $s = "select-all" Then $re1 = 1 ExitLoop EndIf Next If $re1 = 0 Then consolewrite("_JAB_setValue: this element doesn't support select-all action" & @CRLF) Return EndIf For $i = 2 To $s1 + 1 Local $s = DllStructGetData($actions, $i) If $s = "paste-from-clipboard" Then $re2 = 1 ExitLoop EndIf Next If $re2 = 0 Then consolewrite("_JAB_setValue: this element doesn't support paste-from-clipboard action" & @CRLF) Return EndIf Local $actionsToDo = DllStructCreate($tagAccessibleActionsToDo) Local $failure ClipPut($sValue) DllStructSetData($actionsToDo, "actionsCount", 2) DllStructSetData($actionsToDo, 2, "select-all") DllStructSetData($actionsToDo, 3, "paste-from-clipboard") __doAccessibleActions($vmId, $ac, $actionsToDo, $failure) EndFunc ; Draw rectangle on screen. Func _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4) Local $hDC, $hPen, $obj_orig, $x1, $x2, $y1, $y2 $x1 = $tLeft $x2 = $tRight $y1 = $tTop $y2 = $tBottom $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $PenWidth, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1) ; horizontal to right _WinAPI_DrawLine($hDC, $x2, $y1, $x2, $y2) ; vertical down on right _WinAPI_DrawLine($hDC, $x2, $y2, $x1, $y2) ; horizontal to left right _WinAPI_DrawLine($hDC, $x1, $y2, $x1, $y1) ; vertical up on left ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>_UIA_DrawRect Func printDescription($acInfo) $s1 = DllStructGetData($acInfo, "name") $s2 = DllStructGetData($acInfo, "description") $s3 = DllStructGetData($acInfo, "role") $s4 = DllStructGetData($acInfo, "role_en_US") $s5 = DllStructGetData($acInfo, "states") $s6 = DllStructGetData($acInfo, "states_en_US") $s7 = DllStructGetData($acInfo, "indexInParent") $s8 = DllStructGetData($acInfo, "childrenCount") $s9 = DllStructGetData($acInfo, "x") $s10 = DllStructGetData($acInfo, "y") $s11 = DllStructGetData($acInfo, "width") $s12 = DllStructGetData($acInfo, "height") $s13 = DllStructGetData($acInfo, "accessibleComponent") $s14 = DllStructGetData($acInfo, "accessibleAction") $output="" $output&=" name: <" & $s1 & ">" & @CRLF $output&=" description: <" & $s2 & ">" & @CRLF $output&=" role: <" & $s3 & ">" & @CRLF $output&=" role_en_US: <" & $s4 & ">" & @CRLF $output&=" states: <" & $s5 & ">" & @CRLF $output&=" states_en_US: <" & $s6 & ">" & @CRLF $output&=" indexInParent: <" & $s7 & ">" & @CRLF $output&=" childrenCount: <" & $s8 & ">" & @CRLF $output&=" x: <" & $s9 & ">" & @CRLF $output&=" y: <" & $s10 & ">" & @CRLF $output&=" width: <" & $s11 & ">" & @CRLF $output&=" height: <" & $s12 & ">" & @CRLF $output&=" accessibleComponent: <" & $s13 & ">" & @CRLF $output&=" accessibleAction: <" & $s14 & ">" & @CRLF tooltip($output,10,10,"tooltip") consolewrite($output) EndFunc ;==>printDescription Func printDescriptionTable($acTableInfo) $s1 = DllStructGetData($acTableInfo, "caption") $s2 = DllStructGetData($acTableInfo, "summary") $s3 = DllStructGetData($acTableInfo, "rowCount") $s4 = DllStructGetData($acTableInfo, "columnCount") $s5 = DllStructGetData($acTableInfo, "accessibleContext") $s6 = DllStructGetData($acTableInfo, "accessibleTable") $output="" $output&=" caption: <" & $s1 & ">" & @CRLF $output&=" description: <" & $s2 & ">" & @CRLF $output&=" rowCount: <" & $s3 & ">" & @CRLF $output&=" columnCount: <" & $s4 & ">" & @CRLF $output&=" accessibleContext: <" & $s5 & ">" & @CRLF $output&=" accessibleTable: <" & $s6 & ">" & @CRLF tooltip($output,10,10,"tooltip") consolewrite($output) EndFunc ;==>printDescriptionTable func winlistinfo() ; Retrieve a list of window handles. Local $aList = WinList() ; Loop through the array displaying only visable windows with a title. For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then consolewrite("Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1]) if (__isJavaWindow($aList[$i][1])=true ) then consolewrite("Java Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1]) endif EndIf Next EndFunc func highLightAC($vmid, $ac) Local $acInfo = DllStructCreate($tagAccessibleContextInfo) $sName = _JAB_getName($vmid, $ac) __getAccessibleContextInfo($vmid, $ac, $acInfo) $acX = DllStructGetData($acInfo, "x") $acY = DllStructGetData($acInfo, "y") $acW = DllStructGetData($acInfo, "width") $acH = DllStructGetData($acInfo, "height") ConsoleWrite("Name:" & $sName & @CRLF) ConsoleWrite("rect:" & $acX & $acX+$acW & $acy & $acY+$acH & @CRLF) ;~ _JAB_singleAction($vmId, $re_ac) ; for type button there is only 1 action _UIA_DrawRect($acX, $acX+$acW, $acy,$acY+$acH) printDescription($acInfo) __releaseJavaObject($vmid, $acInfo) EndFunc Edited September 10, 2019 by junkew September 10th updated source funkey, mLipok, Danyfirex and 2 others 5 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Stimpak Posted January 17, 2015 Share Posted January 17, 2015 Amazing. Thank you for sharing this. Link to comment Share on other sites More sharing options...
automaterk Posted June 10, 2015 Share Posted June 10, 2015 Thank you for putting this together! I am having trouble getting it to work. Your other simplespy GUI worked without any issues!I have updated the JRE to point to "C:\Program Files\Java\jre1.8.0_45\bin\javacpl.exe" instead of 25. I have also enabled the JAB switch, however I did this with instruction through the Ease of Access menu.Is there something I am missing? The GUI launches without any error, but CTRL+W doesn't do anything when trying to select an object.I realize this is an older post, but there doesn't seem to be any other semi-current information on running AutoIT with a java application.Thanks in advance! Link to comment Share on other sites More sharing options...
junkew Posted June 12, 2015 Author Share Posted June 12, 2015 I will validate if it still is working (no reason to be broken)try if you get it working with NVDA or JavaMonkeyyou could add this to see if you get a windowconsolewrite("The window number is " & $hWND)$tGetMousePos = _WinAPI_GetMousePos() $hWnd = _WinAPI_WindowFromPoint($tGetMousePos) consolewrite("The window number is " & $hWND) $result =dllcall($accessBridgeDll,"BOOL:cdecl", "isJavaWindow", "hwnd", $hWnd) if @error=0 Then FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
junkew Posted June 12, 2015 Author Share Posted June 12, 2015 Still works also with version 45 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
automaterk Posted June 16, 2015 Share Posted June 16, 2015 Thanks for the update. I actually tried it with another application and it is working. At the time of posting, I was under the impression that this application was running in Java, but it wasn't.Thanks again for all the work you've done on this forum! Link to comment Share on other sites More sharing options...
junkew Posted January 20, 2016 Author Share Posted January 20, 2016 revalidated and still works with 1.8.0.66 and autoit 3.3.15.0 Mouse position is retrieved 1519-331 JAVA window found <> Java Window Title= Handle=0x0000000000040A88 res: 1 Result getAccessibleContextFromHWND is <> ubound: 4 We have a VMid 133784 ac 469679048 Call version info: PASSED VMID found : 133784 VMVersion: <1.8.0_66> bridgeJavaClassVersion: <1.8.0_66> bridgeJavaDLLVersion: <1.8.0_66> bridgeWinDLLVersion: <1.8.0_66> *** getAccessibleContextAT result is <469679016> *** getAccessibleContextAT result is <469679016> About... <html>View information about this version of the JRE</html> push button push button enabled,focusable,visible,showing,opaque enabled,focusable,visible,showing,opaque 0 0 1491 316 73 0 End of getAcceccibleContextAt info argumentum 1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
CR831 Posted January 21, 2016 Share Posted January 21, 2016 This is a great script an is ecactly what i am looking for. I am getting an Error at the dll Call $result =dllcall($accessBridgeDll, "BOOL:cdecl", "getVersionInfo", "long", $vmId, "struct*", DllStructGetPtr($tAccessBridgeVersionInfo)) Mouse position is retrieved 1072-415 JAVA window found <> Java Window Title= Handle=0x00151304 res: 1 Result getAccessibleContextFromHWND is <> ubound: 4 We have a VMid 397076 ac 29949844 getVersionInfo error:1 *** getAccessibleContextAT result is <29949764> Error 1 means "unable to use the DLL file" My Environment Settings: I have to Use Java Version 1.7.0_76-b13 jabswitch is enabled javaferret.exe and JavaMonkey-32.exe are working properly with the same Java Window For testing I modified $accessBridgeDLL to the path of WindowsAccessBridge-32.dll matching Java Version 1.7.0_76 . I got the same Error. Why do I get an "unable to use DLL file" error when calling "getVersionInfo" and some code lines up the call "getAccessibleContextFromHWND" is working correct? Thanks for any ideas? Link to comment Share on other sites More sharing options...
mLipok Posted January 21, 2016 Share Posted January 21, 2016 When I trying to is it I mean CTRL+W then i get: Quote --> Press Ctrl+F11 to Restart or Ctrl+Break -or- F11 to Stop We are using X64 at cpu X64 Autoit 64 bit version 0 Windows accessbridge 32 opened 1 0 initializeAccessBridge is finishedWindows_run passed : 0hello!>11:17:08 AutoIt3.exe ended.rc:-1073741819 +>11:17:08 AutoIt3Wrapper Finished. >Exit code: 3221225477 Time: 27.99 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
junkew Posted January 21, 2016 Author Share Posted January 21, 2016 @mlipok not sure but seems to load 32 bits dll instead of 64 bits. Try to reference the 64 bits dll. @cr381 download later version or.download separately the accessibiliy bridge package. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
junkew Posted January 21, 2016 Author Share Posted January 21, 2016 updated the source in top post with some dynamic Java location determination. When problems double check the locations of WindowsAccessBridge-32.dll and WindowsAccessBridge-64.dll FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
mLipok Posted January 21, 2016 Share Posted January 21, 2016 (edited) In case of @AutoItX64=0 how about this: Const $c_JOBJECT64 = "UINT64" ;~ JOBJECT64 Const $cP_JOBJECT64 = "UINT64*" ;~ POINTER(JOBJECT64) ?? EDIT: like this: Const $c_JOBJECT64 = (@AutoItX64) ? ("UINT64") : ("UINT") ;~ JOBJECT64 Const $cP_JOBJECT64 = (@AutoItX64) ? ("UINT64*") : ("UINT*") ;~ POINTER(JOBJECT64) ?? EDIT2: other proposal: Global $sWow64 = (@AutoItX64) ? ("\Wow6432Node") : ("") Global $sJavaVersion = RegRead("HKLM\SOFTWARE" & $sWow64 & "\JavaSoft\Java Runtime Environment", "CurrentVersion") Global $sJavaHome = RegRead("HKLM\SOFTWARE" & $sWow64 & "\JavaSoft\Java Runtime Environment\" & $sJavaVersion, "JavaHome") EDIT2: some further changes: expandcollapse popup#AutoIt3Wrapper_UseX64=N #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <constants.au3> #include <WinAPI.au3> #include <WinAPIEx.au3> #include <debug.au3> #include <memory.au3> #include <Misc.au3> HotKeySet("{ESC}", "Close") ; Set ESC as a hotkey to exit the script. HotKeySet("^w", "GetElementInfo") ; Set Hotkey Ctrl+W to get some basic information in the GUI Global $hAccessBridgeDll ;~ reference to the accessbridge dll Const $tagAccessBridgeVersionInfo = "WCHAR VMversion[256];WCHAR bridgeJavaClassVersion[256];WCHAR bridgeJavaDLLVersion[256];WCHAR bridgeWinDLLVersion[256]" Const $c_JOBJECT64 = (@AutoItX64) ? ("UINT64") : ("UINT") ;~ JOBJECT64 Const $cP_JOBJECT64 = (@AutoItX64) ? ("UINT64*") : ("UINT*") ;~ POINTER(JOBJECT64) Local $tAccessBridgeVersionInfo = DllStructCreate($tagAccessBridgeVersionInfo) Const $tagAccessibleContextInfo = "WCHAR name[1024];WCHAR description[1024];WCHAR role[256];WCHAR role_en_US[256];WCHAR states[256];WCHAR states_en_US[256];INT indexInParent;INT childrenCount;INT x;INT y;INT width;INT height;BOOL accessibleComponent;BOOL accessibleAction;BOOL accessibleSelection;BOOL accessibleText;BOOL accessibleInterfaces" Local $tAccessibleContextInfo = DllStructCreate($tagAccessibleContextInfo) ;~ struct AccessibleTextInfo { ;~ jint charCount; // # of characters in this text object ;~ jint caretIndex; // index of caret ;~ jint indexAtPoint; // index at the passsed in point ;~ }; Const $tagAccessibleTextInfo = "INT charCount;INT caretIndex;INT indexAtPoint" Const $AutoSpy = 0 ;2000 ; SPY about every 2000 milliseconds automatically, 0 is turn of use only ctrl+w ;~ global $oldUIElement ; To keep track of latest referenced element Global $frmSimpleSpy, $edtCtrlInfo, $lblCapture, $lblEscape, $lblRecord, $edtCtrlRecord, $msg Global $i ; Just a simple counter to measure time expired in main loop ;~ Determine java location Global $sWow64 = (@AutoItX64) ? ("\Wow6432Node") : ("") Global $sJavaVersion = RegRead("HKLM\SOFTWARE" & $sWow64 & "\JavaSoft\Java Runtime Environment", "CurrentVersion") Global $sJavaHome = RegRead("HKLM\SOFTWARE" & $sWow64 & "\JavaSoft\Java Runtime Environment\" & $sJavaVersion, "JavaHome") ConsoleWrite($sJavaHome & @CRLF) ShellExecute($sJavaHome & "\bin\javacpl.exe") Sleep(3000) _JABInit() ;~ _Example1_IterateJavaWindows() #Region ### START Koda GUI section ### Form= $frmSimpleSpy = GUICreate("Simple UIA Spy", 801, 601, 181, 4) $edtCtrlInfo = GUICtrlCreateEdit("", 18, 18, 512, 580) GUICtrlSetData(-1, "") $lblCapture = GUICtrlCreateLabel("Ctrl+W to capture information", 544, 10, 528, 17) $lblEscape = GUICtrlCreateLabel("Escape to exit", 544, 53, 528, 17) $edtCtrlRecord = GUICtrlCreateEdit("", 544, 72, 233, 520) GUICtrlSetData(-1, "//TO DO edtCtrlRecord") ;~ $lblRecord = GUICtrlCreateLabel("Ctrl + R to record code", 544, 32, 527, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ _UIA_Init() ;~ loadCodeTemplates() ; //TODO: To use templates per class/controltype ; Run the GUI until the dialog is closed While True $msg = GUIGetMsg() Sleep(100) ;~ if _ispressed(01) Then ;~ getelementinfo() ;~ endif ;Just to show anyway the information about every n ms so ctrl+w is not interfering / removing window as unwanted side effects $i = $i + 100 If ($AutoSpy <> 0) And ($i >= $AutoSpy) Then $i = 0 GetElementInfo() EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd _JABShutDown() Func GetElementInfo() Local $acParent = 0 Local $vmID = 0 Local $tStruct = DllStructCreate($tagPOINT) Local $description $description = "" $xMouse = MouseGetPos(0) $yMouse = MouseGetPos(1) DllStructSetData($tStruct, "x", $xMouse) DllStructSetData($tStruct, "y", $yMouse) $tGetMousePos = _WinAPI_GetMousePos() $hwnd = _WinAPI_WindowFromPoint($tGetMousePos) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "isJavaWindow", "hwnd", $hwnd) If @error = 0 Then If $result[0] = 1 Then $description = "Mouse position is retrieved " & $xMouse & "-" & $yMouse & @CRLF ;~ GUICtrlSetData($edtCtrlInfo, "Mouse position is retrieved " & $xMouse & "-" & $yMouse & @CRLF) $description = $description & (" JAVA window found <" & "> Java Window Title=" & " Handle=" & $hwnd & @TAB & " res: " & $result[0] & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $hwnd, "long*", $vmID, $cP_JOBJECT64, $acParent) If @error = 0 Then $description = $description & ("Result getAccessibleContextFromHWND is <" & $result & "> ubound: " & UBound($result) & @CRLF) $vmID = $result[2] $acParent = $result[3] $description = $description & (" We have a VMid " & $vmID & " ac " & $acParent & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getVersionInfo", "long", $vmID, "struct*", DllStructGetPtr($tAccessBridgeVersionInfo)) If @error = 0 Then $s1 = DllStructGetData($tAccessBridgeVersionInfo, "VMVersion") $s2 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeJavaClassVersion") $s3 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeJavaDLLVersion") $s4 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeWinDLLVersion") $description = $description & ("Call version info: PASSED VMID found : " & $vmID & @CRLF) $description = $description & (" VMVersion: <" & $s1 & ">" & @CRLF) $description = $description & (" bridgeJavaClassVersion: <" & $s2 & ">" & @CRLF) $description = $description & (" bridgeJavaDLLVersion: <" & $s3 & ">" & @CRLF) $description = $description & (" bridgeWinDLLVersion: <" & $s4 & ">" & @CRLF) Else $description = $description & ("getVersionInfo error:" & @error & @CRLF) EndIf Local $childAT_AC __getAccessibleContextAt($vmID, $acParent, $xmouse, $yMouse, $childAT_AC) $description = $description & (" *** getAccessibleContextAT result is <" & $childAT_AC & "> " & @CRLF) If @error = 0 Then $description = $description & (" *** getAccessibleContextAT result is <" & $childAT_AC & "> " & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $childAT_AC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo = $result[3] $description = $description & (getDescription($AccessibleContextInfo)) $description = $description & ("End of getAcceccibleContextAt info" & @CRLF) EndIf EndIf EndIf EndIf GUICtrlSetData($edtCtrlInfo, $description & @CRLF) EndFunc ;==>GetElementInfo Func Close() _JABShutDown() Exit EndFunc ;==>Close Func _JABInit() ;~ Make sure Java Access Bridge is turned on RunWait($sJavaHome & "\bin\jabswitch /enable", "", @SW_MAXIMIZE) ;~ TODO: Check if it works with both dll's ConsoleWrite("We are using " & @OSArch & " at cpu " & @CPUArch & " Autoit 64 bit version " & @AutoItX64 & @CRLF) If @AutoItX64 = 1 Then $sAccessBridgeDLL = "WindowsAccessBridge-64.dll" Else $sAccessBridgeDLL = "WindowsAccessBridge-32.dll" EndIf ;~ Open the Dll for accessibility $hAccessBridgeDll = DllOpen($sJavaHome & "\bin\" & $sAccessBridgeDLL) If $hAccessBridgeDll = True Then ConsoleWrite(" Windows accessbridge 32 opened " & $hAccessBridgeDll & @CRLF) Else ConsoleWrite(" DLL not found try to change to WindowsAccessBridge-64.dll if you use 64 bits autoit and windows") EndIf ;~ TODO: Handle messages received from initialize $result = __Windows_run() ConsoleWrite($result & " " & @error & " initializeAccessBridge is finished") Sleep(250) ConsoleWrite("Windows_run passed :" & $result & @CRLF) EndFunc ;==>_JABInit ;~ _fixBridgeFunc(None,'Windows_run') Func __Windows_run() $result = DllCall($hAccessBridgeDll, "NONE", "Windows_run") If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;==>__Windows_run ;~ _fixBridgeFunc(None,'setFocusGainedFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyStateChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyCaretChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyActiveDescendentChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'releaseJavaObject',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getVersionInfo',POINTER(AccessBridgeVersionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'isJavaWindow',HWND) ;~ _fixBridgeFunc(BOOL,'isSameObject',c_long,JOBJECT64,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextFromHWND',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(HWND,'getHWNDFromAccessibleContext',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextAt',c_long,JOBJECT64,jint,jint,POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextWithFocus',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextInfo',c_long,JOBJECT64,POINTER(AccessibleContextInfo),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleParentFromContext',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleRelationSet',c_long,JOBJECT64,POINTER(AccessibleRelationSetInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextInfo',c_long,JOBJECT64,POINTER(AccessibleTextInfo),jint,jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextItems',c_long,JOBJECT64,POINTER(AccessibleTextItemsInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextSelectionInfo',c_long,JOBJECT64,POINTER(AccessibleTextSelectionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextAttributes',c_long,JOBJECT64,jint,POINTER(AccessibleTextAttributesInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextLineBounds',c_long,JOBJECT64,jint,POINTER(jint),POINTER(jint),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextRange',c_long,JOBJECT64,jint,jint,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCurrentAccessibleValueFromContext',c_long,JOBJECT64,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'selectTextRange',c_long,JOBJECT64,c_int,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getTextAttributesInRange',c_long,JOBJECT64,c_int,c_int,POINTER(AccessibleTextAttributesInfo),POINTER(c_short),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(c_int,'getObjectDepth',c_long,JOBJECT64) ;~ _fixBridgeFunc(JOBJECT64,'getActiveDescendent',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'requestFocus',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'setCaretPosition',c_long,JOBJECT64,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCaretLocation',c_long,JOBJECT64,POINTER(AccessibleTextRectInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActions),errcheck=True) ;~ _fixBridgeFunc(BOOL,'doAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActionsToDo),POINTER(jint),errcheck=True) ;~ By inspecting the WindowsAccessBridge-32.dll it reveals some information about the hidden dialogs ;~ So it seems the hidden dialog is shown after you call windows_run() no clue if interaction is needed ;~ ;~ Somehow it sends a message unclear if this is to the JVM to respond to ;~ push SSZ6E73E320_AccessBridge_FromJava_Hello ;~ push SSZ6E73E300_AccessBridge_FromWindows_Hello ;~ db 'AccessBridge-FromWindows-Hello',0 ;~ db 'AccessBridge-FromJava-Hello',0 ;~ JABHANDLER.PY is a usefull source to study on internet ;~ ******* ;~ Every AccessibleContext IntPtr must be replaced by long, including but not limited to getAccessibleContextFromHWND, getAccessibleParentFromContext, getAccessibleChildFromContext, getAccessibleTextInf ;~ JOBJECT64 is defined as jlong on 64-bit systems and jobject on legacy versions of Java Access Bridge. For definitions, see the section ACCESSBRIDGE_ARCH_LEGACY in the AccessBridgePackages.h header file. ;~ #ifdef ACCESSBRIDGE_ARCH_LEGACY ;~ typedef jobject JOBJECT64; ;~ typedef HWND ABHWND64; ;~ #define ABHandleToLong ;~ #define ABLongToHandle ;~ #else ;~ typedef jlong JOBJECT64; ;~ typedef long ABHWND64; ;~ #define ABHandleToLong HandleToLong ;~ #define ABLongToHandle LongToHandle ;~ #endif ;~ a jobject is a 32 bit pointer for 32 bit builds ;~ 'bool' is a built-in C++ type while 'BOOL' is a Microsoft specific type that is defined as an 'int'. You can find it in 'windef.h' ;~ ;~ ** jni_md.h ** ;~ typedef long jint; ;~ typedef __int64 jlong; ;~ typedef signed char jbyte; ;~ ******* ;~ accessbridgecalls.h ;~ typedef JOBJECT64 AccessibleContext; ;~ typedef JOBJECT64 AccessibleText; ;~ typedef JOBJECT64 AccessibleValue; ;~ typedef JOBJECT64 AccessibleSelection; ;~ typedef JOBJECT64 Java_Object; ;~ typedef JOBJECT64 PropertyChangeEvent; ;~ typedef JOBJECT64 FocusEvent; ;~ typedef JOBJECT64 CaretEvent; ;~ typedef JOBJECT64 MouseEvent; ;~ typedef JOBJECT64 MenuEvent; ;~ typedef JOBJECT64 AccessibleTable; ;~ typedef JOBJECT64 AccessibleHyperlink; ;~ typedef JOBJECT64 AccessibleHypertext; ;~ #Appropriately set the return and argument types of all the access bridge dll functions ;~ if bridgeDll: ;~ _fixBridgeFunc(None,'Windows_run') ;~ _fixBridgeFunc(None,'setFocusGainedFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyStateChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyCaretChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyActiveDescendentChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'releaseJavaObject',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getVersionInfo',POINTER(AccessBridgeVersionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'isJavaWindow',HWND) ;~ _fixBridgeFunc(BOOL,'isSameObject',c_long,JOBJECT64,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextFromHWND',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(HWND,'getHWNDFromAccessibleContext',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextAt',c_long,JOBJECT64,jint,jint,POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextWithFocus',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextInfo',c_long,JOBJECT64,POINTER(AccessibleContextInfo),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleParentFromContext',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleRelationSet',c_long,JOBJECT64,POINTER(AccessibleRelationSetInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextInfo',c_long,JOBJECT64,POINTER(AccessibleTextInfo),jint,jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextItems',c_long,JOBJECT64,POINTER(AccessibleTextItemsInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextSelectionInfo',c_long,JOBJECT64,POINTER(AccessibleTextSelectionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextAttributes',c_long,JOBJECT64,jint,POINTER(AccessibleTextAttributesInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextLineBounds',c_long,JOBJECT64,jint,POINTER(jint),POINTER(jint),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextRange',c_long,JOBJECT64,jint,jint,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCurrentAccessibleValueFromContext',c_long,JOBJECT64,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'selectTextRange',c_long,JOBJECT64,c_int,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getTextAttributesInRange',c_long,JOBJECT64,c_int,c_int,POINTER(AccessibleTextAttributesInfo),POINTER(c_short),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(c_int,'getObjectDepth',c_long,JOBJECT64) ;~ _fixBridgeFunc(JOBJECT64,'getActiveDescendent',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'requestFocus',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'setCaretPosition',c_long,JOBJECT64,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCaretLocation',c_long,JOBJECT64,POINTER(AccessibleTextRectInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActions),errcheck=True) ;~ _fixBridgeFunc(BOOL,'doAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActionsToDo),POINTER(jint),errcheck=True) ;~ Primitive Types and Native Equivalents ;~ Java Type Native Type Description ;~ boolean jboolean unsigned 8 bits ;~ byte jbyte signed 8 bits ;~ char jchar unsigned 16 bits ;~ short jshort signed 16 bits ;~ int jint signed 32 bits ;~ long jlong signed 64 bits ;~ float jfloat 32 bits ;~ double jdouble 64 bits ;~ void void not applicable ;~ Copied from this NVDA reference and translated to AutoIT ;~ http://www.webbie.org.uk/nvda/api/JABHandler-pysrc.html ;~ ;~ def initialize(): ;~ global isRunning ;~ if not bridgeDll: ;~ raise NotImplementedError("dll not available") ;~ bridgeDll.Windows_run() ;~ #Accept wm_copydata and any wm_user messages from other processes even if running with higher privilages ;~*** ChangeWindowMessageFilter=getattr(windll.user32,'ChangeWindowMessageFilter',None) ;~*** if ChangeWindowMessageFilter: ;~*** if not ChangeWindowMessageFilter(winUser.WM_COPYDATA,1): ;~*** raise WinError() ;~*** for msg in xrange(winUser.WM_USER+1,65535): ;~*** if not ChangeWindowMessageFilter(msg,1): ;~*** raise WinError() ;~ #Register java events ;~ bridgeDll.setFocusGainedFP(internal_event_focusGained) ;~ bridgeDll.setPropertyActiveDescendentChangeFP(internal_event_activeDescendantChange) ;~ bridgeDll.setPropertyNameChangeFP(event_nameChange) ;~ bridgeDll.setPropertyDescriptionChangeFP(event_descriptionChange) ;~ bridgeDll.setPropertyValueChangeFP(event_valueChange) ;~ bridgeDll.setPropertyStateChangeFP(internal_event_stateChange) ;~ bridgeDll.setPropertyCaretChangeFP(internal_event_caretChange) ;~ isRunning=True ;create the structs ;~ ;~ http://docs.oracle.com/javase/accessbridge/2.0.2/api.htm ;~ ;~ #define MAX_STRING_SIZE 1024 ;~ #define SHORT_STRING_SIZE 256 ;~ struct AccessBridgeVersionInfo { ;~ wchar_t VMversion[SHORT_STRING_SIZE]; // version of the Java VM ;~ wchar_t bridgeJavaClassVersion[SHORT_STRING_SIZE]; // version of the AccessBridge.class ;~ wchar_t bridgeJavaDLLVersion[SHORT_STRING_SIZE]; // version of JavaAccessBridge.dll ;~ wchar_t bridgeWinDLLVersion[SHORT_STRING_SIZE]; // version of WindowsAccessBridge.dll ;~ }; ;~ struct AccessibleContextInfo { ;~ wchar_ name[MAX_STRING_SIZE]; // the AccessibleName of the object ;~ wchar_ description[MAX_STRING_SIZE]; // the AccessibleDescription of the object ;~ wchar_ role[SHORT_STRING_SIZE]; // localized AccesibleRole string ;~ wchar_ states[SHORT_STRING_SIZE]; // localized AccesibleStateSet string ;~ // (comma separated) ;~ jint indexInParent // index of object in parent ;~ jint childrenCount // # of children, if any ;~ jint x; // screen x-axis co-ordinate in pixels ;~ jint y; // screen y-axis co-ordinate in pixels ;~ jint width; // pixel width of object ;~ jint height; // pixel height of object ;~ BOOL accessibleComponent; // flags for various additional ;~ BOOL accessibleAction; // Java Accessibility interfaces ;~ BOOL accessibleSelection; // FALSE if this object doesn't ;~ BOOL accessibleText; // implement the additional interface ;~ BOOL accessibleInterfaces; // new bitfield containing additional ;~ // interface flags ;~ }; ;~ typedef struct AccessibleContextInfoTag { ;~ wchar_t name[MAX_STRING_SIZE]; // the AccessibleName of the object ;~ wchar_t description[MAX_STRING_SIZE]; // the AccessibleDescription of the object ;~ wchar_t role[SHORT_STRING_SIZE]; // localized AccesibleRole string ;~ wchar_t role_en_US[SHORT_STRING_SIZE]; // AccesibleRole string in the en_US locale ;~ wchar_t states[SHORT_STRING_SIZE]; // localized AccesibleStateSet string (comma separated) ;~ wchar_t states_en_US[SHORT_STRING_SIZE]; // AccesibleStateSet string in the en_US locale (comma separated) ;~ jint indexInParent; // index of object in parent ;~ jint childrenCount; // # of children, if any ;~ jint x; // screen coords in pixels ;~ jint y; // " ;~ jint width; // pixel width of object ;~ jint height; // pixel height of object ;~ BOOL accessibleComponent; // flags for various additional ;~ BOOL accessibleAction; // Java Accessibility interfaces ;~ BOOL accessibleSelection; // FALSE if this object doesn't ;~ BOOL accessibleText; // implement the additional interface ;~ // in question ;~ // BOOL accessibleValue; // old BOOL indicating whether AccessibleValue is supported ;~ BOOL accessibleInterfaces; // new bitfield containing additional interface flags ;~ } AccessibleContextInfo; Local $hwnd Local $i Local $result Local $vmID Local $ac ;~ //TODO: Check if needed ;~ Make messages elevated ;~ _ChangeWindowMessageFilter($WM_COPYDATA,1) ;~ for $i=$WM_USER to $WM_USER+65536 ;~ _ChangeWindowMessageFilter($i, 1) ;~ Next ;~ Func _ChangeWindowMessageFilter($iMsg, $iAction) ;~ Local $aCall = DllCall("user32.dll", "bool", "ChangeWindowMessageFilter", "dword", $iMsg, "dword", $iAction) ;~ If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) ;~ Return 1 ;~ EndFunc ;~ typedef AccessibleContext (*getTopLevelObjectFP) (const long vmID, const AccessibleContext ac); ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) Func __getTopLevelObject($vmID, $ac) ;~ Seems not to be allowed to call with null so passing $acParent $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getTopLevelObject", "long", $vmID, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;==>__getTopLevelObject ;~ typedef AccessibleContext (*GetAccessibleChildFromContextFP) (long vmID, AccessibleContext ac, jint i); ;~ typedef AccessibleContext (*GetAccessibleParentFromContextFP) (long vmID, AccessibleContext ac); ;~ typedef AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint index); ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ Returns an AccessibleContext object that represents the nth child of the object ac, where n is specified by the value index. Func __getAccessibleChildFromContext($vmID, $ac, $index) ;~ Seems not to be allowed to call with null so passing $acParent $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getAccessibleChildFromContext", "long", $vmID, $c_JOBJECT64, $ac, "int", $index) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;==>__getAccessibleChildFromContext ;~ _fixBridgeFunc(JOBJECT64,'getActiveDescendent',c_long,JOBJECT64) Func __getActiveDescendent($vmID, $ac) ;~ Seems not to be allowed to call with null so passing $acParent $result = DllCall($hAccessBridgeDll, "ptr:cdecl", "getActiveDescendent", "long", $vmID, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;==>__getActiveDescendent ;~ _fixBridgeFunc(BOOL,'getAccessibleContextAt',c_long,JOBJECT64,jint,jint,POINTER(JOBJECT64),errcheck=True) ;~ BOOL GetAccessibleContextAt(long vmID, AccessibleContext acParent, jint x, jint y, AccessibleContext *ac) Func __getAccessibleContextAt($vmID, $acParent, $x, $y, ByRef $ac) ;~ Seems not to be allowed to call with null so passing $acParent $result = DllCall($hAccessBridgeDll, "bool:cdecl", "getAccessibleContextAt", "long", $vmID, $c_JOBJECT64, $acParent, "int", $x, "int", $y, $cP_JOBJECT64, $ac) ConsoleWrite(@error) If @error Then Return SetError(1, 0, 0) ConsoleWrite("hello") $ac = $result[5] Return $result[0] EndFunc ;==>__getAccessibleContextAt Func _Example1_IterateJavaWindows() ;~ Just check all windows if its a java window Local $var = WinList() ConsoleWrite("Before checking all Windows: " & $var[0][0] & @CRLF) For $i = 1 To $var[0][0] ; Only display visble windows that have a title If IsVisible($var[$i][1]) Then Local $handle = WinGetHandle($var[$i][0]) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "isJavaWindow", "hwnd", $handle) If @error = 0 Then If $result[0] = 1 Then ConsoleWrite(" JAVA window found <" & $i & "> Java Window Title=" & $var[$i][0] & " Handle=" & $var[$i][1] & @TAB & " res: " & $result[0] & @CRLF) Local $acParent = 0 Local $vmID = 0 ;~AccessibilityContext (acParent above), which I had incorrectly mapped as an IntPtr, is actually an Int32 when using the "legacy" WindowsAccessBridge.dll library (used under x86), ;~and an Int64 when using the WOW64 WindowsAccessBridge-32.dll library. ;~WindowsAccessBridge-32.dll bool getAccessibleContextFromHWND(IntPtr hwnd, out Int32 vmID, out Int64 acParent); ;~WindowsAccessBridge.dll bool _getAccessibleContextFromHWND(IntPtr hwnd, out Int32 vmID, out Int32 acParent); ;~ _fixBridgeFunc(BOOL,'getAccessibleContextFromHWND',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $handle, "long*", $vmID, $c_JOBJECT64, $acParent) ;~ $result =dllcall($hAccessBridgeDll,"BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $handle, "long*", $vmID, "ptr*", $acParent) ;~ $result =dllcall($hAccessBridgeDll,"BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $handle, "long*", $vmID, "INT64*", $acParent) If @error = 0 Then ConsoleWrite("Result getAccessibleContextFromHWND is <" & $result & "> ubound: " & UBound($result) & @CRLF) $vmID = $result[2] $acParent = $result[3] ConsoleWrite(" We have a VMid " & $vmID & " ac " & $acParent & @CRLF) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getVersionInfo", "long", $vmId, "struct", $AccessBridgeVersionInfo) ;~ typedef BOOL (*GetVersionInfoFP) (long vmID, AccessBridgeVersionInfo *info); $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getVersionInfo", "long", $vmID, "struct*", DllStructGetPtr($tAccessBridgeVersionInfo)) If @error = 0 Then $s1 = DllStructGetData($tAccessBridgeVersionInfo, "VMVersion") $s2 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeJavaClassVersion") $s3 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeJavaDLLVersion") $s4 = DllStructGetData($tAccessBridgeVersionInfo, "bridgeWinDLLVersion") ConsoleWrite("Call version info: PASSED VMID found : " & $vmID & @CRLF) ConsoleWrite(" VMVersion: <" & $s1 & ">" & @CRLF) ConsoleWrite(" bridgeJavaClassVersion: <" & $s2 & ">" & @CRLF) ConsoleWrite(" bridgeJavaDLLVersion: <" & $s3 & ">" & @CRLF) ConsoleWrite(" bridgeWinDLLVersion: <" & $s4 & ">" & @CRLF) Else ConsoleWrite("getVersionInfo error:" & @error & @CRLF) EndIf ;~ /** ;~ * Returns the Accessible Context for the top level object in ;~ * a Java Window. This is same Accessible Context that is obtained ;~ * from GetAccessibleContextFromHWND for that window. Returns ;~ * (AccessibleContext)0 on error. ;~ */ ;~ AccessibleContext getTopLevelObject (const long vmID, const AccessibleContext accessibleContext); ;~ typedef AccessibleContext (*getTopLevelObjectFP) (const long vmID, const AccessibleContext ac); ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) Local $topAC = __getTopLevelObject($vmID, $acParent) If @error = 0 Then ConsoleWrite(" *** getTopLevelObject Result is <" & $topAC & "> " & @CRLF) ;~ $vmID=$result[1] ;~ local $tPtr = DllStructCreate( "ptr", $result[0] ) ;~ local $ptr = DllStructGetData( $tPtr,1 ) ;~ local $topAC = $result ;~ DllStructCreate( $tagAccessibleContextInfo, $ptr ) ;~ Local $topAC=DllStructCreate($tagAccessibleContextInfo,DllStructGetPtr($result[0])) ;~ Local $topAC=DllStructCreate($tagAccessibleContextInfo,$result[0]) ;~ dllstructsetdata($topAC,-1,$result[0] ConsoleWrite("We have a VMid " & $vmID & " toplevel object ac " & $topAC & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $topAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo = $result[3] ConsoleWrite(getDescription($AccessibleContextInfo)) ConsoleWrite("End of top level object info" & @CRLF) $childAC = __getAccessibleChildFromContext($vmID, $topAC, 0) ConsoleWrite(" *** getAccessibleChildFromContext Result is <" & $childAC & "> " & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $childAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo = $result[3] ConsoleWrite(getDescription($AccessibleContextInfo)) ConsoleWrite("End of getAccessibleChild object info" & @CRLF) $descentAC = __getActiveDescendent($vmID, $topAC) ConsoleWrite(" *** getActiveDescendent Result is <" & $descentAC & "> " & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $descentAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo = $result[3] ConsoleWrite(getDescription($AccessibleContextInfo)) ConsoleWrite("End of getActiveDescendent object info" & @CRLF) Else ConsoleWrite("getTopLevelObjecterror:" & @error & @CRLF) _WinAPI_DisplayStruct($topAC, $tagAccessibleContextInfo) EndIf ConsoleWrite(" We still have a VMid " & $vmID & " acParent " & $acParent & @CRLF) ;~ Retrieves an AccessibleContextInfo object of the AccessibleContext object ac. ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "ptr", $ac, "ptr", DllStructGetPtr($AccessibleContextInfo)) ;~ typedef BOOL (*GetAccessibleContextInfoFP) (long vmID, AccessibleContext ac, AccessibleContextInfo *info); ;~ _fixBridgeFunc(BOOL,'getAccessibleContextInfo',c_long,JOBJECT64,POINTER(AccessibleContextInfo),errcheck=True) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","INT64", $vmId, "int", $ac, "ptr*", DllStructGetPtr($AccessibleContextInfo)) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "long", $ac, "ptr", DllStructGetPtr($AccessibleContextInfo),DllStructGetSize($AccessibleContextInfo)) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "INT64", $acParent, "struct*", DllStructGetPtr($AccessibleContextInfo)) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $acParent, "struct*", $tAccessibleContextInfo) If @error <> 0 Then ConsoleWrite("We have an error " & @error & @CRLF) EndIf ;~ We should pass it by reference ;~ Exception code c0000005 is an access violation, also known as general protection fault. The program is reading from, or writing to, an address which is not part of the virtual address space. ;~ A very common cause is that you are de-referencing a stale pointer. In other words, the pointer was once valid, but you have subsequently freed it. Then later when you attempt to access it, ;~ an exception is raised. ;~ The problem is don't use out parameter. Use the IntPtr. ;~ So it should be getAccessibleContextInfo(Int32 vmID, IntPtr accessibleContext, IntPtr acInfo) ConsoleWrite("Result is <" & $result & "> ubound: " & UBound($result) & @CRLF) $AccessibleContextInfo = $result[3] _WinAPI_DisplayStruct($tAccessibleContextInfo, $tagAccessibleContextInfo) ConsoleWrite(getDescription($AccessibleContextInfo)) $s9 = DllStructGetData($AccessibleContextInfo, "x") $s10 = DllStructGetData($AccessibleContextInfo, "y") $s11 = DllStructGetData($AccessibleContextInfo, "width") $s12 = DllStructGetData($AccessibleContextInfo, "height") ConsoleWrite(" We still have before getAccessible Child FromContext a VMid " & $vmID & " acParent " & $acParent & @CRLF) ConsoleWrite("rect:" & $s9 & $s9 + $s11 & $s10 & $s10 + $s12) _UIA_DrawRect($s9, $s9 + $s11, $s10, $s10 + $s12) Sleep(3000) ;~ AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint index); ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ Returns an AccessibleContext object that represents the nth child of the object ac, where n is specified by the value index. $childAC = __getAccessibleChildFromContext($vmID, $topAC, 0) ConsoleWrite(" *** getAccessibleChildFromContext Result is <" & $childAC & "> " & @CRLF) $result = DllCall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo", "long", $vmID, "long", $childAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo = $result[3] ConsoleWrite(getDescription($AccessibleContextInfo)) ConsoleWrite("End of getAccessibleChild object info" & @CRLF) _WinAPI_DisplayStruct($tAccessibleContextInfo, $tagAccessibleContextInfo) ;~ memcpy(tData->ResponceHTML, m_pResponse, INT_BUFFERSIZE); ConsoleWrite(getDescription($AccessibleContextInfo)) Else ConsoleWrite(@error & " No context found" & @CRLF) EndIf EndIf Else EndIf EndIf Next EndFunc ;==>_Example1_IterateJavaWindows ;~ http://www.autohotkey.com/board/topic/95343-how-to-send-to-unseen-controls-in-a-java-app/ Func _JABShutDown() Local $result $result = DllCall($hAccessBridgeDll, "BOOL", "shutdownAccessBridge") EndFunc ;==>_JABShutDown Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible ; Draw rectangle on screen. Func _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4) Local $hDC, $hPen, $obj_orig, $x1, $x2, $y1, $y2 $x1 = $tLeft $x2 = $tRight $y1 = $tTop $y2 = $tBottom $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $PenWidth, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1) ; horizontal to right _WinAPI_DrawLine($hDC, $x2, $y1, $x2, $y2) ; vertical down on right _WinAPI_DrawLine($hDC, $x2, $y2, $x1, $y2) ; horizontal to left right _WinAPI_DrawLine($hDC, $x1, $y2, $x1, $y1) ; vertical up on left ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>_UIA_DrawRect Func getDescription($ac) $s1 = DllStructGetData($ac, "name") $s2 = DllStructGetData($ac, "description") $s3 = DllStructGetData($ac, "role") $s4 = DllStructGetData($ac, "role_en_US") $s5 = DllStructGetData($ac, "states") $s6 = DllStructGetData($ac, "states_en_US") $s7 = DllStructGetData($ac, "indexInParent") $s8 = DllStructGetData($ac, "childrenCount") $s9 = DllStructGetData($ac, "x") $s10 = DllStructGetData($ac, "y") $s11 = DllStructGetData($ac, "width") $s12 = DllStructGetData($ac, "heigth") ConsoleWrite(" name: <" & $s1 & ">" & @CRLF) ConsoleWrite(" description: <" & $s2 & ">" & @CRLF) ConsoleWrite(" role: <" & $s3 & ">" & @CRLF) ConsoleWrite(" role_en_US: <" & $s4 & ">" & @CRLF) ConsoleWrite(" states: <" & $s5 & ">" & @CRLF) ConsoleWrite(" states_en_US: <" & $s6 & ">" & @CRLF) ConsoleWrite(" indexInParent: <" & $s7 & ">" & @CRLF) ConsoleWrite(" childrenCount: <" & $s8 & ">" & @CRLF) ConsoleWrite(" x: <" & $s9 & ">" & @CRLF) ConsoleWrite(" y: <" & $s10 & ">" & @CRLF) ConsoleWrite(" width: <" & $s11 & ">" & @CRLF) ConsoleWrite(" height: <" & $s12 & ">" & @CRLF) Return $s1 & @CRLF & $s2 & @CRLF & $s3 & @CRLF & $s4 & @CRLF & $s5 & @CRLF & $s6 & @CRLF & $s7 & @CRLF & $s8 & @CRLF & $s9 & @CRLF & $s10 & @CRLF & $s11 & @CRLF & $s12 & @CRLF EndFunc ;==>getDescription btw. I'm DllCall .... beginner. Edited January 21, 2016 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
CR831 Posted January 22, 2016 Share Posted January 22, 2016 (edited) Thanks for updating your script and your quick reply junkew. I had no luck with the newer script Version. It throws the same error. Some more about my Environment: The Java tool i would like to spy only runs in an separate JRE which isnt installed and registered in windows. I cant use an newer Version of JavaAccessBridge. So i had to modify the JavaHomePath to use the correct dll: ;Local $sJavaHome =RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\" & $sJavaVersion , "JavaHome") $sJavaHome = "C:\MyFolder\jre" Heres the error again with some further logging Information (JavaHomePath an dll-Path) to be sure to use the correct dll: JAVAHOME C:\MyFolder\jre We are using X86 at cpu X64 Autoit 64 bit version 0 Windows accessbridge 32 opened C:\MyFolder\WindowsAccessBridge-32.dll 1 0 initializeAccessBridge is finishedWindows_run passed : 0helloC:\MyFolder\JavaSpy.au3 (145) : ==> Subscript used with non-Array variable.: $AccessibleContextInfo=$result[3] $AccessibleContextInfo=$result^ ERROR >Exit code: 1 Time: 6.985 I can trace the error down to the dllcall function throwing the error 1 unable to use the DLL file. Afterwards i tried to use the WindowsAccessBridge.dll instead of WindowsAccessbridge-32.dll. The same error. The accessibility.properties file looks like and jabswith is enabled: assistive_technologies=com.sun.java.accessibility.AccessBridge screen_magnifier_present=true Edited January 25, 2016 by CR831 Link to comment Share on other sites More sharing options...
CR831 Posted January 22, 2016 Share Posted January 22, 2016 Sorry, i couldnt find de edit option of an post. Now with correct PATH: Heres the error again with some further logging Information (JavaHomePath an dll-Path) to be sure to use the correct dll: JAVAHOME C:\MyFolder\jre We are using X86 at cpu X64 Autoit 64 bit version 0 Windows accessbridge 32 opened C:\MyFolder\jre\bin\WindowsAccessBridge-32.dll 1 0 initializeAccessBridge is finishedWindows_run passed : 0helloC:\MyFolder\jre\bin\JavaSpy.au3 (145) : ==> Subscript used with non-Array variable.: $AccessibleContextInfo=$result[3] $AccessibleContextInfo=$result^ ERROR >Exit code: 1 Time: 6.985 Link to comment Share on other sites More sharing options...
mLipok Posted January 22, 2016 Share Posted January 22, 2016 1 hour ago, CR831 said: Sorry, i couldnt find de edit option of an post. Near to "Quote" , on the left with relation to "Like this" Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
junkew Posted January 22, 2016 Author Share Posted January 22, 2016 try it on a different machine maybe even temporarily with another version (lower or higher) post version /size of dll. I do not have a clue. Step 1 is to spy on the java config window ShellExecute($sJavaHome & "\bin\javacpl.exe") step 2 is to spy on your application FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
sherek Posted December 16, 2017 Share Posted December 16, 2017 On 16/01/2015 at 7:14 PM, junkew said: As a starter and far from perfect and real messy code a simple spy for Java Accessibility Bridge Based on the information in general help and support '?do=embed' frameborder='0' data-embedContent>> Many functions still to make and enhance but I would call at a 0.1 version for automating Java from within AutoIT and Java accessibility Spy detects based on mouse position make sure you have JABSWITCH /ENABLE Childs start counting from 0 Hover mouse over your Java Element and press Ctrl+W and you will get some basic information Prerequisites 1. Only Java Runtime needed (no need for samples / JDK to install) from JRE 1.7 and higher (for 1.6 you need to install accessibility bridge 2.0.2 yourself)2. JABSWITCH /ENABLE should have been run from commandline3. Then script can be run (will run JavaCPL with shellexecute("C:Program FilesJavajre1.8.0_25binjavacpl.exe")) so needs change if other JRE versionOptional (mainly for definitions in header files but main info copied in au3 script in comments)4. Java Accessibility Bridge 2.0.2. for CPP source and headers and javamonkey (java spy tool) 5. JDK installed for other JAVA sample applications6. NVDA screen reader source JABHANDLER.PY as a reference Please enhance / help in extending by posting small helper functions / translating the definitions (at the moment I have little time but the start is promising) Unfortunately there is not much documented on Java Accessibility Bridge Output example Mouse position is retrieved 1490-415 JAVA window found <> Java Window Title= Handle=0x00000000000E098C res: 1 Result getAccessibleContextFromHWND is <> ubound: 4 We have a VMid 133566 ac 1530827472 Call version info: PASSED VMID found : 133566 VMVersion: <1.8.0_25> bridgeJavaClassVersion: <1.8.0_25> bridgeJavaDLLVersion: <1.8.0_25> bridgeWinDLLVersion: <1.8.0_25> *** getAccessibleContextAT result is <1530827448> *** getAccessibleContextAT result is <1530827448> Network Settings... <html>Modify Internet connection settings</html> push button push button enabled,focusable,visible,showing,opaque enabled,focusable,visible,showing,opaque 0 0 1424 406 127 0 End of getAcceccibleContextAt info Source JABSimpleSpy expandcollapse popup#AutoIt3Wrapper_UseX64=Y #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <constants.au3> #include <WinAPI.au3> #include <WinAPIEx.au3> #include <debug.au3> #include <memory.au3> #include <Misc.au3> HotKeySet("{ESC}", "Close") ; Set ESC as a hotkey to exit the script. HotKeySet("^w", "GetElementInfo") ; Set Hotkey Ctrl+W to get some basic information in the GUI Global $hAccessBridgeDll ;~ reference to the accessbridge dll Const $tagAccessBridgeVersionInfo="WCHAR VMversion[256];WCHAR bridgeJavaClassVersion[256];WCHAR bridgeJavaDLLVersion[256];WCHAR bridgeWinDLLVersion[256]" const $c_JOBJECT64="UINT64" ;~ JOBJECT64 const $cP_JOBJECT64="UINT64*" ;~ POINTER(JOBJECT64) Local $tAccessBridgeVersionInfo=DllStructCreate($tagAccessBridgeVersionInfo) const $tagAccessibleContextInfo="WCHAR name[1024];WCHAR description[1024];WCHAR role[256];WCHAR role_en_US[256];WCHAR states[256];WCHAR states_en_US[256];INT indexInParent;INT childrenCount;INT x;INT y;INT width;INT height;BOOL accessibleComponent;BOOL accessibleAction;BOOL accessibleSelection;BOOL accessibleText;BOOL accessibleInterfaces" Local $tAccessibleContextInfo=DllStructCreate($tagAccessibleContextInfo) ;~ struct AccessibleTextInfo { ;~ jint charCount; // # of characters in this text object ;~ jint caretIndex; // index of caret ;~ jint indexAtPoint; // index at the passsed in point ;~ }; const $tagAccessibleTextInfo="INT charCount;INT caretIndex;INT indexAtPoint" const $AutoSpy=0 ;2000 ; SPY about every 2000 milliseconds automatically, 0 is turn of use only ctrl+w ;~ global $oldUIElement ; To keep track of latest referenced element global $frmSimpleSpy, $edtCtrlInfo , $lblCapture, $lblEscape, $lblRecord, $edtCtrlRecord, $msg global $i ; Just a simple counter to measure time expired in main loop ;~ Determine java location Local $sJavaVersion = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment", "CurrentVersion") Local $sJavaHome =RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\" & $sJavaVersion , "JavaHome") consolewrite($sJavaHome & @CRLF) shellexecute($sJavaHome & "\bin\javacpl.exe") sleep(3000) _JABInit() ;~ _Example1_IterateJavaWindows() #Region ### START Koda GUI section ### Form= $frmSimpleSpy = GUICreate("Simple UIA Spy", 801, 601, 181, 4) $edtCtrlInfo = GUICtrlCreateEdit("", 18, 18, 512, 580) GUICtrlSetData(-1, "") $lblCapture = GUICtrlCreateLabel("Ctrl+W to capture information", 544, 10, 528, 17) $lblEscape = GUICtrlCreateLabel("Escape to exit", 544, 53, 528, 17) $edtCtrlRecord = GUICtrlCreateEdit("", 544, 72, 233, 520) GUICtrlSetData(-1, "//TO DO edtCtrlRecord") ;~ $lblRecord = GUICtrlCreateLabel("Ctrl + R to record code", 544, 32, 527, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ _UIA_Init() ;~ loadCodeTemplates() ; //TODO: To use templates per class/controltype ; Run the GUI until the dialog is closed While true $msg = GUIGetMsg() sleep(100) ;~ if _ispressed(01) Then ;~ getelementinfo() ;~ endif ;Just to show anyway the information about every n ms so ctrl+w is not interfering / removing window as unwanted side effects $i=$i+100 if ($autoSpy<>0) and ($i>= $autoSpy) then $i=0 getelementinfo() EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd _JABShutDown() Func GetElementInfo() local $acParent=0 local $vmID=0 Local $tStruct = DllStructCreate($tagPOINT) local $description $description="" $xMouse=MouseGetPos(0) $yMouse=MouseGetPos(1) DllStructSetData($tStruct, "x", $xMouse) DllStructSetData($tStruct, "y", $yMouse) $tGetMousePos = _WinAPI_GetMousePos() $hWnd = _WinAPI_WindowFromPoint($tGetMousePos) $result =dllcall($hAccessBridgeDll,"BOOL:cdecl", "isJavaWindow", "hwnd", $hWnd) if @error=0 Then if $result[0]=1 Then $description = "Mouse position is retrieved " & $xMouse & "-" & $yMouse & @CRLF ;~ GUICtrlSetData($edtCtrlInfo, "Mouse position is retrieved " & $xMouse & "-" & $yMouse & @CRLF) $description = $description & ( " JAVA window found <" & "> Java Window Title=" & " Handle=" & $hWnd & @TAB & " res: " & $result[0] & @CRLF) $result =dllcall($hAccessBridgeDll,"BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $hWnd, "long*", $vmID, "UINT64*", $acParent) if @error=0 Then $description = $description & ("Result getAccessibleContextFromHWND is <" & $result & "> ubound: " & ubound($result) & @crlf) $vmID=$result[2] $acParent=$result[3] $description = $description & (" We have a VMid " & $vmID & " ac " & $acParent & @CRLF) $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getVersionInfo", "long", $vmId, "struct*", DllStructGetPtr($tAccessBridgeVersionInfo)) if @error=0 Then $s1=dllstructgetdata($tAccessBridgeVersionInfo, "VMVersion") $s2=dllstructgetdata($tAccessBridgeVersionInfo, "bridgeJavaClassVersion") $s3=dllstructgetdata($tAccessBridgeVersionInfo, "bridgeJavaDLLVersion") $s4=dllstructgetdata($tAccessBridgeVersionInfo, "bridgeWinDLLVersion") $description = $description & ("Call version info: PASSED VMID found : " & $vmID & @CRLF) $description = $description & (" VMVersion: <" & $s1 & ">" & @CRLF) $description = $description & (" bridgeJavaClassVersion: <" & $s2 & ">" & @CRLF) $description = $description & (" bridgeJavaDLLVersion: <" & $s3 & ">" & @CRLF) $description = $description & (" bridgeWinDLLVersion: <" & $s4 & ">" & @CRLF) Else $description = $description & ("getVersionInfo error:" & @error & @CRLF) EndIf local $childAT_AC __getAccessibleContextAt($vmid,$acparent,$xmouse, $yMouse,$childAT_AC) $description = $description & (" *** getAccessibleContextAT result is <" & $childAT_AC & "> " & @crlf) if @error=0 Then $description = $description & (" *** getAccessibleContextAT result is <" & $childAT_AC & "> " & @crlf) $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "long", $childAT_AC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo=$result[3] $description = $description & (getDescription($AccessibleContextInfo)) $description = $description & ("End of getAcceccibleContextAt info" & @CRLF) endif EndIf EndIf EndIf GUICtrlSetData($edtCtrlInfo, $description & @CRLF) EndFunc Func Close() _JABShutDown() Exit EndFunc ;==>Close Func _JABInit() ;~ Make sure Java Access Bridge is turned on runwait($sJavaHome & "\bin\jabswitch /enable","",@SW_MAXIMIZE) ;~ TODO: Check if it works with both dll's consolewrite("We are using " & @OSArch & " at cpu " & @CPUArch & " Autoit 64 bit version "& @AutoItX64 & @CRLF) if @AutoItX64 = 1 then $sAccessBridgeDLL="WindowsAccessBridge-64.dll" Else $sAccessBridgeDLL="WindowsAccessBridge-32.dll" EndIf ;~ Open the Dll for accessibility $hAccessBridgeDll=DLLOPEN($sJavaHome & "\bin\" & $sAccessBridgeDLL) If $hAccessBridgeDll=true Then consolewrite(" Windows accessbridge 32 opened " & $hAccessBridgeDll & @CRLF) Else consolewrite(" DLL not found try to change to WindowsAccessBridge-64.dll if you use 64 bits autoit and windows") endIf ;~ TODO: Handle messages received from initialize $result = __Windows_run() consolewrite($result & " " & @error & " initializeAccessBridge is finished") sleep(250) consolewrite("Windows_run passed :" & $result & @CRLF) EndFunc ;~ _fixBridgeFunc(None,'Windows_run') func __Windows_run() $result =dllcall($hAccessBridgeDll,"NONE", "Windows_run") If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ _fixBridgeFunc(None,'setFocusGainedFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyStateChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyCaretChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyActiveDescendentChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'releaseJavaObject',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getVersionInfo',POINTER(AccessBridgeVersionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'isJavaWindow',HWND) ;~ _fixBridgeFunc(BOOL,'isSameObject',c_long,JOBJECT64,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextFromHWND',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(HWND,'getHWNDFromAccessibleContext',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextAt',c_long,JOBJECT64,jint,jint,POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextWithFocus',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextInfo',c_long,JOBJECT64,POINTER(AccessibleContextInfo),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleParentFromContext',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleRelationSet',c_long,JOBJECT64,POINTER(AccessibleRelationSetInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextInfo',c_long,JOBJECT64,POINTER(AccessibleTextInfo),jint,jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextItems',c_long,JOBJECT64,POINTER(AccessibleTextItemsInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextSelectionInfo',c_long,JOBJECT64,POINTER(AccessibleTextSelectionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextAttributes',c_long,JOBJECT64,jint,POINTER(AccessibleTextAttributesInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextLineBounds',c_long,JOBJECT64,jint,POINTER(jint),POINTER(jint),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextRange',c_long,JOBJECT64,jint,jint,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCurrentAccessibleValueFromContext',c_long,JOBJECT64,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'selectTextRange',c_long,JOBJECT64,c_int,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getTextAttributesInRange',c_long,JOBJECT64,c_int,c_int,POINTER(AccessibleTextAttributesInfo),POINTER(c_short),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(c_int,'getObjectDepth',c_long,JOBJECT64) ;~ _fixBridgeFunc(JOBJECT64,'getActiveDescendent',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'requestFocus',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'setCaretPosition',c_long,JOBJECT64,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCaretLocation',c_long,JOBJECT64,POINTER(AccessibleTextRectInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActions),errcheck=True) ;~ _fixBridgeFunc(BOOL,'doAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActionsToDo),POINTER(jint),errcheck=True) ;~ By inspecting the WindowsAccessBridge-32.dll it reveals some information about the hidden dialogs ;~ So it seems the hidden dialog is shown after you call windows_run() no clue if interaction is needed ;~ ;~ Somehow it sends a message unclear if this is to the JVM to respond to ;~ push SSZ6E73E320_AccessBridge_FromJava_Hello ;~ push SSZ6E73E300_AccessBridge_FromWindows_Hello ;~ db 'AccessBridge-FromWindows-Hello',0 ;~ db 'AccessBridge-FromJava-Hello',0 ;~ JABHANDLER.PY is a usefull source to study on internet ;~ ******* ;~ Every AccessibleContext IntPtr must be replaced by long, including but not limited to getAccessibleContextFromHWND, getAccessibleParentFromContext, getAccessibleChildFromContext, getAccessibleTextInf ;~ JOBJECT64 is defined as jlong on 64-bit systems and jobject on legacy versions of Java Access Bridge. For definitions, see the section ACCESSBRIDGE_ARCH_LEGACY in the AccessBridgePackages.h header file. ;~ #ifdef ACCESSBRIDGE_ARCH_LEGACY ;~ typedef jobject JOBJECT64; ;~ typedef HWND ABHWND64; ;~ #define ABHandleToLong ;~ #define ABLongToHandle ;~ #else ;~ typedef jlong JOBJECT64; ;~ typedef long ABHWND64; ;~ #define ABHandleToLong HandleToLong ;~ #define ABLongToHandle LongToHandle ;~ #endif ;~ a jobject is a 32 bit pointer for 32 bit builds ;~ 'bool' is a built-in C++ type while 'BOOL' is a Microsoft specific type that is defined as an 'int'. You can find it in 'windef.h' ;~ ;~ ** jni_md.h ** ;~ typedef long jint; ;~ typedef __int64 jlong; ;~ typedef signed char jbyte; ;~ ******* ;~ accessbridgecalls.h ;~ typedef JOBJECT64 AccessibleContext; ;~ typedef JOBJECT64 AccessibleText; ;~ typedef JOBJECT64 AccessibleValue; ;~ typedef JOBJECT64 AccessibleSelection; ;~ typedef JOBJECT64 Java_Object; ;~ typedef JOBJECT64 PropertyChangeEvent; ;~ typedef JOBJECT64 FocusEvent; ;~ typedef JOBJECT64 CaretEvent; ;~ typedef JOBJECT64 MouseEvent; ;~ typedef JOBJECT64 MenuEvent; ;~ typedef JOBJECT64 AccessibleTable; ;~ typedef JOBJECT64 AccessibleHyperlink; ;~ typedef JOBJECT64 AccessibleHypertext; ;~ #Appropriately set the return and argument types of all the access bridge dll functions ;~ if bridgeDll: ;~ _fixBridgeFunc(None,'Windows_run') ;~ _fixBridgeFunc(None,'setFocusGainedFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyStateChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyCaretChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'setPropertyActiveDescendentChangeFP',c_void_p) ;~ _fixBridgeFunc(None,'releaseJavaObject',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getVersionInfo',POINTER(AccessBridgeVersionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'isJavaWindow',HWND) ;~ _fixBridgeFunc(BOOL,'isSameObject',c_long,JOBJECT64,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextFromHWND',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(HWND,'getHWNDFromAccessibleContext',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextAt',c_long,JOBJECT64,jint,jint,POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextWithFocus',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleContextInfo',c_long,JOBJECT64,POINTER(AccessibleContextInfo),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleParentFromContext',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'getAccessibleRelationSet',c_long,JOBJECT64,POINTER(AccessibleRelationSetInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextInfo',c_long,JOBJECT64,POINTER(AccessibleTextInfo),jint,jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextItems',c_long,JOBJECT64,POINTER(AccessibleTextItemsInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextSelectionInfo',c_long,JOBJECT64,POINTER(AccessibleTextSelectionInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextAttributes',c_long,JOBJECT64,jint,POINTER(AccessibleTextAttributesInfo),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextLineBounds',c_long,JOBJECT64,jint,POINTER(jint),POINTER(jint),errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleTextRange',c_long,JOBJECT64,jint,jint,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCurrentAccessibleValueFromContext',c_long,JOBJECT64,POINTER(c_wchar),c_short,errcheck=True) ;~ _fixBridgeFunc(BOOL,'selectTextRange',c_long,JOBJECT64,c_int,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getTextAttributesInRange',c_long,JOBJECT64,c_int,c_int,POINTER(AccessibleTextAttributesInfo),POINTER(c_short),errcheck=True) ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(c_int,'getObjectDepth',c_long,JOBJECT64) ;~ _fixBridgeFunc(JOBJECT64,'getActiveDescendent',c_long,JOBJECT64) ;~ _fixBridgeFunc(BOOL,'requestFocus',c_long,JOBJECT64,errcheck=True) ;~ _fixBridgeFunc(BOOL,'setCaretPosition',c_long,JOBJECT64,c_int,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getCaretLocation',c_long,JOBJECT64,POINTER(AccessibleTextRectInfo),jint,errcheck=True) ;~ _fixBridgeFunc(BOOL,'getAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActions),errcheck=True) ;~ _fixBridgeFunc(BOOL,'doAccessibleActions',c_long,JOBJECT64,POINTER(AccessibleActionsToDo),POINTER(jint),errcheck=True) ;~ Primitive Types and Native Equivalents ;~ Java Type Native Type Description ;~ boolean jboolean unsigned 8 bits ;~ byte jbyte signed 8 bits ;~ char jchar unsigned 16 bits ;~ short jshort signed 16 bits ;~ int jint signed 32 bits ;~ long jlong signed 64 bits ;~ float jfloat 32 bits ;~ double jdouble 64 bits ;~ void void not applicable ;~ Copied from this NVDA reference and translated to AutoIT ;~ http://www.webbie.org.uk/nvda/api/JABHandler-pysrc.html ;~ ;~ def initialize(): ;~ global isRunning ;~ if not bridgeDll: ;~ raise NotImplementedError("dll not available") ;~ bridgeDll.Windows_run() ;~ #Accept wm_copydata and any wm_user messages from other processes even if running with higher privilages ;~*** ChangeWindowMessageFilter=getattr(windll.user32,'ChangeWindowMessageFilter',None) ;~*** if ChangeWindowMessageFilter: ;~*** if not ChangeWindowMessageFilter(winUser.WM_COPYDATA,1): ;~*** raise WinError() ;~*** for msg in xrange(winUser.WM_USER+1,65535): ;~*** if not ChangeWindowMessageFilter(msg,1): ;~*** raise WinError() ;~ #Register java events ;~ bridgeDll.setFocusGainedFP(internal_event_focusGained) ;~ bridgeDll.setPropertyActiveDescendentChangeFP(internal_event_activeDescendantChange) ;~ bridgeDll.setPropertyNameChangeFP(event_nameChange) ;~ bridgeDll.setPropertyDescriptionChangeFP(event_descriptionChange) ;~ bridgeDll.setPropertyValueChangeFP(event_valueChange) ;~ bridgeDll.setPropertyStateChangeFP(internal_event_stateChange) ;~ bridgeDll.setPropertyCaretChangeFP(internal_event_caretChange) ;~ isRunning=True ;create the structs ;~ ;~ http://docs.oracle.com/javase/accessbridge/2.0.2/api.htm ;~ ;~ #define MAX_STRING_SIZE 1024 ;~ #define SHORT_STRING_SIZE 256 ;~ struct AccessBridgeVersionInfo { ;~ wchar_t VMversion[SHORT_STRING_SIZE]; // version of the Java VM ;~ wchar_t bridgeJavaClassVersion[SHORT_STRING_SIZE]; // version of the AccessBridge.class ;~ wchar_t bridgeJavaDLLVersion[SHORT_STRING_SIZE]; // version of JavaAccessBridge.dll ;~ wchar_t bridgeWinDLLVersion[SHORT_STRING_SIZE]; // version of WindowsAccessBridge.dll ;~ }; ;~ struct AccessibleContextInfo { ;~ wchar_ name[MAX_STRING_SIZE]; // the AccessibleName of the object ;~ wchar_ description[MAX_STRING_SIZE]; // the AccessibleDescription of the object ;~ wchar_ role[SHORT_STRING_SIZE]; // localized AccesibleRole string ;~ wchar_ states[SHORT_STRING_SIZE]; // localized AccesibleStateSet string ;~ // (comma separated) ;~ jint indexInParent // index of object in parent ;~ jint childrenCount // # of children, if any ;~ jint x; // screen x-axis co-ordinate in pixels ;~ jint y; // screen y-axis co-ordinate in pixels ;~ jint width; // pixel width of object ;~ jint height; // pixel height of object ;~ BOOL accessibleComponent; // flags for various additional ;~ BOOL accessibleAction; // Java Accessibility interfaces ;~ BOOL accessibleSelection; // FALSE if this object doesn't ;~ BOOL accessibleText; // implement the additional interface ;~ BOOL accessibleInterfaces; // new bitfield containing additional ;~ // interface flags ;~ }; ;~ typedef struct AccessibleContextInfoTag { ;~ wchar_t name[MAX_STRING_SIZE]; // the AccessibleName of the object ;~ wchar_t description[MAX_STRING_SIZE]; // the AccessibleDescription of the object ;~ wchar_t role[SHORT_STRING_SIZE]; // localized AccesibleRole string ;~ wchar_t role_en_US[SHORT_STRING_SIZE]; // AccesibleRole string in the en_US locale ;~ wchar_t states[SHORT_STRING_SIZE]; // localized AccesibleStateSet string (comma separated) ;~ wchar_t states_en_US[SHORT_STRING_SIZE]; // AccesibleStateSet string in the en_US locale (comma separated) ;~ jint indexInParent; // index of object in parent ;~ jint childrenCount; // # of children, if any ;~ jint x; // screen coords in pixels ;~ jint y; // " ;~ jint width; // pixel width of object ;~ jint height; // pixel height of object ;~ BOOL accessibleComponent; // flags for various additional ;~ BOOL accessibleAction; // Java Accessibility interfaces ;~ BOOL accessibleSelection; // FALSE if this object doesn't ;~ BOOL accessibleText; // implement the additional interface ;~ // in question ;~ // BOOL accessibleValue; // old BOOL indicating whether AccessibleValue is supported ;~ BOOL accessibleInterfaces; // new bitfield containing additional interface flags ;~ } AccessibleContextInfo; local $hwnd local $i local $result local $vmID local $ac ;~ //TODO: Check if needed ;~ Make messages elevated ;~ _ChangeWindowMessageFilter($WM_COPYDATA,1) ;~ for $i=$WM_USER to $WM_USER+65536 ;~ _ChangeWindowMessageFilter($i, 1) ;~ Next ;~ Func _ChangeWindowMessageFilter($iMsg, $iAction) ;~ Local $aCall = DllCall("user32.dll", "bool", "ChangeWindowMessageFilter", "dword", $iMsg, "dword", $iAction) ;~ If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) ;~ Return 1 ;~ EndFunc ;~ typedef AccessibleContext (*getTopLevelObjectFP) (const long vmID, const AccessibleContext ac); ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) func __getTopLevelObject($vmId,$ac) ;~ Seems not to be allowed to call with null so passing $acParent $result=dllcall($hAccessBridgeDll, "ptr:cdecl", "getTopLevelObject", "long", $vmId, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ typedef AccessibleContext (*GetAccessibleChildFromContextFP) (long vmID, AccessibleContext ac, jint i); ;~ typedef AccessibleContext (*GetAccessibleParentFromContextFP) (long vmID, AccessibleContext ac); ;~ typedef AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint index); ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ Returns an AccessibleContext object that represents the nth child of the object ac, where n is specified by the value index. func __getAccessibleChildFromContext($vmId, $ac, $index) ;~ Seems not to be allowed to call with null so passing $acParent $result=dllcall($hAccessBridgeDll, "ptr:cdecl", "getAccessibleChildFromContext", "long", $vmId, $c_JOBJECT64, $ac, "int", $index) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ _fixBridgeFunc(JOBJECT64,'getActiveDescendent',c_long,JOBJECT64) func __getActiveDescendent($vmId, $ac) ;~ Seems not to be allowed to call with null so passing $acParent $result=dllcall($hAccessBridgeDll, "ptr:cdecl", "getActiveDescendent", "long", $vmId, $c_JOBJECT64, $ac) If @error Then Return SetError(1, 0, 0) Return $result[0] EndFunc ;~ _fixBridgeFunc(BOOL,'getAccessibleContextAt',c_long,JOBJECT64,jint,jint,POINTER(JOBJECT64),errcheck=True) ;~ BOOL GetAccessibleContextAt(long vmID, AccessibleContext acParent, jint x, jint y, AccessibleContext *ac) func __getAccessibleContextAt($vmId, $acParent, $x, $y, byref $ac) ;~ Seems not to be allowed to call with null so passing $acParent $result=dllcall($hAccessBridgeDll, "bool:cdecl", "getAccessibleContextAt", "long", $vmId, $c_JOBJECT64, $acParent, "int", $x, "int", $y, $cP_JOBJECT64, $ac) consolewrite(@error) If @error Then Return SetError(1, 0, 0) consolewrite("hello") $ac=$result[5] Return $result[0] EndFunc func _Example1_IterateJavaWindows() ;~ Just check all windows if its a java window Local $var = WinList() consolewrite("Before checking all Windows: " & $var[0][0] & @CRLF) For $i = 1 To $var[0][0] ; Only display visble windows that have a title If IsVisible($var[$i][1]) Then local $handle=wingethandle($var[$i][0]) $result =dllcall($hAccessBridgeDll,"BOOL:cdecl", "isJavaWindow", "hwnd", $handle) if @error=0 Then if $result[0]=1 Then consolewrite( " JAVA window found <" & $i & "> Java Window Title=" & $var[$i][0] & " Handle=" & $var[$i][1] & @TAB & " res: " & $result[0] & @CRLF) local $acParent=0 local $vmID=0 ;~AccessibilityContext (acParent above), which I had incorrectly mapped as an IntPtr, is actually an Int32 when using the "legacy" WindowsAccessBridge.dll library (used under x86), ;~and an Int64 when using the WOW64 WindowsAccessBridge-32.dll library. ;~WindowsAccessBridge-32.dll bool getAccessibleContextFromHWND(IntPtr hwnd, out Int32 vmID, out Int64 acParent); ;~WindowsAccessBridge.dll bool _getAccessibleContextFromHWND(IntPtr hwnd, out Int32 vmID, out Int32 acParent); ;~ _fixBridgeFunc(BOOL,'getAccessibleContextFromHWND',HWND,POINTER(c_long),POINTER(JOBJECT64),errcheck=True) $result =dllcall($hAccessBridgeDll,"BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $handle, "long*", $vmID, "UINT64*", $acParent) ;~ $result =dllcall($hAccessBridgeDll,"BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $handle, "long*", $vmID, "ptr*", $acParent) ;~ $result =dllcall($hAccessBridgeDll,"BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $handle, "long*", $vmID, "INT64*", $acParent) if @error=0 Then consolewrite("Result getAccessibleContextFromHWND is <" & $result & "> ubound: " & ubound($result) & @crlf) $vmID=$result[2] $acParent=$result[3] consolewrite(" We have a VMid " & $vmID & " ac " & $acParent & @CRLF) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getVersionInfo", "long", $vmId, "struct", $AccessBridgeVersionInfo) ;~ typedef BOOL (*GetVersionInfoFP) (long vmID, AccessBridgeVersionInfo *info); $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getVersionInfo", "long", $vmId, "struct*", DllStructGetPtr($tAccessBridgeVersionInfo)) if @error=0 Then $s1=dllstructgetdata($tAccessBridgeVersionInfo, "VMVersion") $s2=dllstructgetdata($tAccessBridgeVersionInfo, "bridgeJavaClassVersion") $s3=dllstructgetdata($tAccessBridgeVersionInfo, "bridgeJavaDLLVersion") $s4=dllstructgetdata($tAccessBridgeVersionInfo, "bridgeWinDLLVersion") consolewrite("Call version info: PASSED VMID found : " & $vmID & @CRLF) consolewrite(" VMVersion: <" & $s1 & ">" & @CRLF) consolewrite(" bridgeJavaClassVersion: <" & $s2 & ">" & @CRLF) consolewrite(" bridgeJavaDLLVersion: <" & $s3 & ">" & @CRLF) consolewrite(" bridgeWinDLLVersion: <" & $s4 & ">" & @CRLF) Else consolewrite("getVersionInfo error:" & @error & @CRLF) EndIf ;~ /** ;~ * Returns the Accessible Context for the top level object in ;~ * a Java Window. This is same Accessible Context that is obtained ;~ * from GetAccessibleContextFromHWND for that window. Returns ;~ * (AccessibleContext)0 on error. ;~ */ ;~ AccessibleContext getTopLevelObject (const long vmID, const AccessibleContext accessibleContext); ;~ typedef AccessibleContext (*getTopLevelObjectFP) (const long vmID, const AccessibleContext ac); ;~ _fixBridgeFunc(JOBJECT64,'getTopLevelObject',c_long,JOBJECT64,errcheck=True) local $topAC=__getTopLevelObject($vmId, $acparent) if @error=0 Then consolewrite(" *** getTopLevelObject Result is <" & $topAC & "> " & @crlf) ;~ $vmID=$result[1] ;~ local $tPtr = DllStructCreate( "ptr", $result[0] ) ;~ local $ptr = DllStructGetData( $tPtr,1 ) ;~ local $topAC = $result ;~ DllStructCreate( $tagAccessibleContextInfo, $ptr ) ;~ Local $topAC=DllStructCreate($tagAccessibleContextInfo,DllStructGetPtr($result[0])) ;~ Local $topAC=DllStructCreate($tagAccessibleContextInfo,$result[0]) ;~ dllstructsetdata($topAC,-1,$result[0] consolewrite("We have a VMid " & $vmID & " toplevel object ac " & $topAC & @CRLF) $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "long", $topAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo=$result[3] consolewrite(getDescription($AccessibleContextInfo)) consolewrite("End of top level object info" & @CRLF) $childAC=__getAccessibleChildFromContext($vmId, $topAC, 0) consolewrite(" *** getAccessibleChildFromContext Result is <" & $childAC & "> " & @crlf) $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "long", $childAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo=$result[3] consolewrite(getDescription($AccessibleContextInfo)) consolewrite("End of getAccessibleChild object info" & @CRLF) $descentAC=__getActiveDescendent($vmId, $topAC) consolewrite(" *** getActiveDescendent Result is <" & $descentAC & "> " & @crlf) $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "long", $descentAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo=$result[3] consolewrite(getDescription($AccessibleContextInfo)) consolewrite("End of getActiveDescendent object info" & @CRLF) Else consolewrite("getTopLevelObjecterror:" & @error & @CRLF) _WinAPI_DisplayStruct($topAC, $tagAccessibleContextInfo) endif consolewrite(" We still have a VMid " & $vmID & " acParent " & $acParent & @CRLF) ;~ Retrieves an AccessibleContextInfo object of the AccessibleContext object ac. ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "ptr", $ac, "ptr", DllStructGetPtr($AccessibleContextInfo)) ;~ typedef BOOL (*GetAccessibleContextInfoFP) (long vmID, AccessibleContext ac, AccessibleContextInfo *info); ;~ _fixBridgeFunc(BOOL,'getAccessibleContextInfo',c_long,JOBJECT64,POINTER(AccessibleContextInfo),errcheck=True) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","INT64", $vmId, "int", $ac, "ptr*", DllStructGetPtr($AccessibleContextInfo)) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "long", $ac, "ptr", DllStructGetPtr($AccessibleContextInfo),DllStructGetSize($AccessibleContextInfo)) ;~ $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "INT64", $acParent, "struct*", DllStructGetPtr($AccessibleContextInfo)) $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "long", $acParent, "struct*", $tAccessibleContextInfo) if @error<>0 Then consolewrite("We have an error " & @error & @CRLF) EndIf ;~ We should pass it by reference ;~ Exception code c0000005 is an access violation, also known as general protection fault. The program is reading from, or writing to, an address which is not part of the virtual address space. ;~ A very common cause is that you are de-referencing a stale pointer. In other words, the pointer was once valid, but you have subsequently freed it. Then later when you attempt to access it, ;~ an exception is raised. ;~ The problem is don't use out parameter. Use the IntPtr. ;~ So it should be getAccessibleContextInfo(Int32 vmID, IntPtr accessibleContext, IntPtr acInfo) consolewrite("Result is <" & $result & "> ubound: " & ubound($result) & @crlf) $AccessibleContextInfo=$result[3] _WinAPI_DisplayStruct($tAccessibleContextInfo, $tagAccessibleContextInfo) consolewrite(getDescription($AccessibleContextInfo)) $s9=dllstructgetdata($AccessibleContextInfo, "x") $s10=dllstructgetdata($AccessibleContextInfo, "y") $s11=dllstructgetdata($AccessibleContextInfo, "width") $s12=dllstructgetdata($AccessibleContextInfo, "height") consolewrite(" We still have before getAccessible Child FromContext a VMid " & $vmID & " acParent " & $acParent & @CRLF) consolewrite("rect:" &$s9 & $s9+$s11 & $s10 & $s10+$s12) _UIA_DrawRect($s9, $s9+$s11, $s10, $s10+$s12) sleep(3000) ;~ AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint index); ;~ _fixBridgeFunc(JOBJECT64,'getAccessibleChildFromContext',c_long,JOBJECT64,jint,errcheck=True) ;~ Returns an AccessibleContext object that represents the nth child of the object ac, where n is specified by the value index. $childAC=__getAccessibleChildFromContext($vmId, $topAC, 0) consolewrite(" *** getAccessibleChildFromContext Result is <" & $childAC & "> " & @crlf) $result =dllcall($hAccessBridgeDll, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "long", $childAC, "struct*", $tAccessibleContextInfo) $AccessibleContextInfo=$result[3] consolewrite(getDescription($AccessibleContextInfo)) consolewrite("End of getAccessibleChild object info" & @CRLF) _WinAPI_DisplayStruct($tAccessibleContextInfo, $tagAccessibleContextInfo) ;~ memcpy(tData->ResponceHTML, m_pResponse, INT_BUFFERSIZE); consolewrite(getDescription($AccessibleContextInfo)) Else consolewrite( @error & " No context found" & @CRLF) endif EndIf Else EndIf endif Next EndFunc ;~ http://www.autohotkey.com/board/topic/95343-how-to-send-to-unseen-controls-in-a-java-app/ func _JABShutDown() local $result $result=dllcall($hAccessBridgeDll,"BOOL", "shutdownAccessBridge") EndFunc Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible ; Draw rectangle on screen. Func _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4) Local $hDC, $hPen, $obj_orig, $x1, $x2, $y1, $y2 $x1 = $tLeft $x2 = $tRight $y1 = $tTop $y2 = $tBottom $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $PenWidth, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1) ; horizontal to right _WinAPI_DrawLine($hDC, $x2, $y1, $x2, $y2) ; vertical down on right _WinAPI_DrawLine($hDC, $x2, $y2, $x1, $y2) ; horizontal to left right _WinAPI_DrawLine($hDC, $x1, $y2, $x1, $y1) ; vertical up on left ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>_UIA_DrawRect func getDescription($ac) $s1=dllstructgetdata($ac, "name") $s2=dllstructgetdata($ac, "description") $s3=dllstructgetdata($ac, "role") $s4=dllstructgetdata($ac, "role_en_US") $s5=dllstructgetdata($ac, "states") $s6=dllstructgetdata($ac, "states_en_US") $s7=dllstructgetdata($ac, "indexInParent") $s8=dllstructgetdata($ac, "childrenCount") $s9=dllstructgetdata($ac, "x") $s10=dllstructgetdata($ac, "y") $s11=dllstructgetdata($ac, "width") $s12=dllstructgetdata($ac, "heigth") consolewrite(" name: <" & $s1 & ">" & @CRLF) consolewrite(" description: <" & $s2 & ">" & @CRLF) consolewrite(" role: <" & $s3 & ">" & @CRLF) consolewrite(" role_en_US: <" & $s4 & ">" & @CRLF) consolewrite(" states: <" & $s5 & ">" & @CRLF) consolewrite(" states_en_US: <" & $s6 & ">" & @CRLF) consolewrite(" indexInParent: <" & $s7 & ">" & @CRLF) consolewrite(" childrenCount: <" & $s8 & ">" & @CRLF) consolewrite(" x: <" & $s9 & ">" & @CRLF) consolewrite(" y: <" & $s10 & ">" & @CRLF) consolewrite(" width: <" & $s11 & ">" & @CRLF) consolewrite(" height: <" & $s12 & ">" & @CRLF) return $s1 & @crlf & $s2 & @crlf & $s3 & @crlf & $s4 & @crlf & $s5 & @crlf & $s6 & @crlf & $s7 & @crlf & $s8 & @crlf & $s9 & @crlf & $s10 & @crlf & $s11 & @crlf & $s12 & @crlf EndFunc hello, congratulations by the work I can only run through AutoItDebugger - Run Script option, otherwise gives an error and closes the .au3 file in the java window. Any suggestion? Would an example read value of a JTextField? The error log is attached. I'm a beginner, sorry if the questions are very basic ... Thank you! hs_err_pid5076.log Link to comment Share on other sites More sharing options...
BatMan22 Posted April 24, 2018 Share Posted April 24, 2018 Mouse position is retrieved 968-488 JAVA window found <> Java Window Title= Handle=0x00000000002A0652 res: 1 Result getAccessibleContextFromHWND is <> ubound: 4 We have a VMid 1704850 ac 988271572 Call version info: PASSED VMID found : 1704850 VMVersion: <1.8.0_25> bridgeJavaClassVersion: <1.8.0_25> bridgeJavaDLLVersion: <1.8.0_25> bridgeWinDLLVersion: <1.8.0_25> *** getAccessibleContextAT result is <988271552> *** getAccessibleContextAT result is <988271552> text text enabled,focusable,visible,showing,opaque,editable,single line enabled,focusable,visible,showing,opaque,editable,single line 8 0 931 476 81 0 End of getAcceccibleContextAt info So this seems to work perfectly.. but does anyone have any examples on how to combine it with autoit? Can I control set text with the info above? Or control Click? Link to comment Share on other sites More sharing options...
junkew Posted April 24, 2018 Author Share Posted April 24, 2018 (edited) Yes you can but you have to read examples in other languages BOOL setTextContents (const long vmID, const AccessibleContext accessibleContext, const wchar_t *text); https://docs.oracle.com/javase/9/access/jaapi.htm#JSACC-GUID-C79D9A13-0922-49DC-A28B-DFECDCFA79DD https://github.com/JetBrains/jdk8u_jdk/blob/master/src/windows/native/sun/bridge/AccessBridgeCalls.h Edited April 24, 2018 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
BatMan22 Posted April 25, 2018 Share Posted April 25, 2018 Thanks @junkew Has anyone done this? Anyone have any examples? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now