├── JAB Swingset3 Demo.ahk ├── JABTest.ahk ├── JCWGUIStrings.ini ├── JControlWriter.ahk ├── JavaAccessBridge.ahk ├── JavaAccessBridge_class.ahk ├── License.txt └── README.md /JAB Swingset3 Demo.ahk: -------------------------------------------------------------------------------- 1 | sleep, 500 2 | WinActivate, SwingSet3 3 | sleep, 1000 4 | JavaControlDoAction(0, "GridBagLayout ", "toggle button", "Demonstrates GridBagLayout, a layout which allows to arrange components in containers.", "1", "left click") 5 | ; the action "left click" for clicking with the mouse is used as the SwingSet demo sometimes does not react to the direct "click action" 6 | 7 | sleep, 2000 8 | JavaControlDoAction(0, "JSplitPane ", "toggle button", "Demonstrates JSplitPane, a container which lays out two components in an adjustable split view (horizontal or vertical)", "1", "left click") 9 | sleep, 3000 10 | JavaControlDoAction(0, "Vertical Split", "radio button", "", "1", "click") 11 | sleep, 2000 12 | JavaControlDoAction(0, "Horizontal Split", "radio button", "", "1", "click") 13 | sleep, 2000 14 | JavaControlDoAction(0, "JList ", "toggle button", "Demonstrates JList, a component which supports display/editing of a data list", "1", "left click") 15 | sleep, 2000 16 | JavaControlDoAction(0, "Tera", "check box", "", "1", "click") 17 | sleep, 2000 18 | JavaControlDoAction(0, "Tera", "check box", "", "1", "click") 19 | msgbox, Done! 20 | return 21 | 22 | #Include JavaAccessBridge.ahk 23 | -------------------------------------------------------------------------------- /JABTest.ahk: -------------------------------------------------------------------------------- 1 | #Include JavaAccessBridge.ahk 2 | #Include ObjectHandling.ahk 3 | 4 | JAB:=new JavaAccessBridge() 5 | return 6 | 7 | F11:: 8 | main:=JAB.GetAccessibleContextFromHWND(WinExist("A")) 9 | ccount:=main.GetVisibleChildrenCount() 10 | Children:=main.GetVisibleChildren() 11 | Gui, New 12 | Gui, Add, ListView, r20 w700, Number|Name|Role 13 | for index, child in Children 14 | { 15 | Info:=child.GetAccessibleContextInfo() 16 | LV_Add("", index, Info.Name, Info.Role) 17 | } 18 | 19 | LV_ModifyCol() ; Auto-size each column to fit its contents. 20 | LV_ModifyCol(1, "Integer") ; For sorting purposes, indicate that column 2 is an integer. 21 | Gui, Show 22 | return 23 | 24 | F12:: 25 | main:=JAB.GetAccessibleContextWithFocus(WinExist("A")) 26 | Info:=main.GetAccessibleContextInfo() 27 | ToolTip, % Info.Name ";" Info.Role 28 | return -------------------------------------------------------------------------------- /JCWGUIStrings.ini: -------------------------------------------------------------------------------- 1 | [English] 2 | 3 | ButtonSaveChanges=&Save changes 4 | ButtonCancel=Cancel 5 | ButtonClose=Close 6 | 7 | 13JControlTitle=Java Contol Browser - 8 | 13JControlListHeader=Index|Occurrence|Role|Name|Description|Actions 9 | 13JControlWriteCommandsFileButton=Write commands &file 10 | 13JControlCopyCommandButton=&Copy command 11 | 13JControlSearchLabel=&Search: 12 | 13JControlFindNextButton=Find &next -------------------------------------------------------------------------------- /JControlWriter.ahk: -------------------------------------------------------------------------------- 1 | OnExit, CleanUp 2 | #Persistent 3 | 4 | global JCWSettings 5 | 6 | FileCreateDir, %A_AppData%\JCW\ 7 | JCWSettings:=new ApplicationSettingsClass(A_AppData "\JCW\JControlWriter.ini", "JControlWriter") 8 | 9 | fileinstall, JCWGUIStrings.ini, %A_AppData%\JCW\JCWGUIStrings.ini 10 | LoadResourceStrings(A_AppData "\JCW\JCWGUIStrings.ini", JCWSettings, "English") 11 | 12 | if !InitJavaAccessBridge() 13 | { 14 | msgbox, JAB not loaded! 15 | } 16 | return 17 | 18 | #Include JavaAccessBridge.ahk 19 | 20 | ; shows the list of all visible controls 21 | ^!F10:: 22 | OpenJControlDlg("A") 23 | return 24 | 25 | ; shows the list of all visible and invisible controls 26 | ^!F11:: 27 | OpenJControlDlg("A", 0) 28 | return 29 | 30 | ; test function 31 | ^!F12:: 32 | JavaControlDoAction(0, "File", "menu", "", "1", "click") 33 | sleep, 1000 34 | msgbox, done 35 | return 36 | 37 | CleanUp: 38 | ExitJavaAccessBridge() 39 | ExitApp 40 | 41 | OpenJControlDlg(hwnd, visible:=1) 42 | { 43 | global 13JCtrlLVVar, 13Searchfield, 13GuiHwnd 44 | if (hwnd="A") 45 | { 46 | currwin:=WinExist("A") 47 | JCWSettings.13hwnd:=currwin 48 | if (!IsJavaWindow(currwin)) 49 | { 50 | ControlGetFocus, currctrl, ahk_id %currwin% 51 | ControlGet, currwin, Hwnd, , %currctrl%, ahk_id %currwin% 52 | } 53 | } 54 | if (IsJavaWindow(currwin)) 55 | { 56 | JCWSettings.13JWinVmId:=1 57 | ac:=0 58 | Info:= 59 | getAccessibleContextFromHWND(currwin, vmid, ac) 60 | JCWSettings.13JWinVmId:=vmid 61 | rac:=GetAccessibleChildFromContext(VmId, ac, 0) 62 | if (visible) 63 | JCWSettings.13JWinVisibleChildren:=GetVisibleChildrenFromTree(VmId, rac) 64 | else 65 | JCWSettings.13JWinVisibleChildren:=GetAllChildrenFromTree(VmId, rac) 66 | Gui, 13: Destroy 67 | Gui, 13: +Resize +MaximizeBox +MinimizeBox +Hwnd13GuiHwnd 68 | Gui, 13: Add, ListView, r10 w500 AltSubmit -Multi v13JCtrlLVVar g13JVisItLVLAb, % JCWSettings.ResourceString.13JControlListHeader 69 | GuiControlGet, CSize, 13:Pos, 13JCtrlLVVar 70 | JCWSettings["13cMargin"]:=cSizeX 71 | Gui, 13: Add, Button, xm g13WriteCommandsFile, % JCWSettings.ResourceString.13JControlWriteCommandsFileButton 72 | Gui, 13: Add, Button, x+10 section g13CopyCommand, % JCWSettings.ResourceString.13JControlCopyCommandButton 73 | Gui, 13: Add, Text, x+30 yp+5, % JCWSettings.ResourceString.13JControlSearchLabel 74 | Gui, 13: Add, Edit, x+10 ys v13Searchfield g13SearchFieldLabel, 75 | Gui, 13: Add, Button, x+10 g13FindNextLabel, % JCWSettings.ResourceString.13JControlFindNextButton 76 | Gui, 13: Add, Button, x+30 g13Cancel, % JCWSettings.ResourceString.ButtonClose 77 | GuiControlGet, CSize, 13:Pos, % JCWSettings.ResourceString.ButtonClose 78 | JCWSettings["13cMinSizeH"]:=CSizeY+CSizeH+JCWSettings["13cMargin"] 79 | JCWSettings["13cSizeButH"]:=CSizeH+2*JCWSettings["13cMargin"] 80 | JCWSettings["13cSizeCButW"]:=CSizeW+JCWSettings["13cMargin"] 81 | GuiControlGet, CSize, 13:Pos, % JCWSettings.ResourceString.ButtonClose 82 | JCWSettings["13cMinSizeW"]:=CSizeX+CSizeW+JCWSettings["13cMargin"] 83 | Gui, 13: Default 84 | Gui, 13: ListView, 13JCtrlLVVar 85 | OBJCounter:= 86 | OBJCounter:=Object() 87 | For index, value in JCWSettings.13JWinVisibleChildren 88 | { 89 | Info:= 90 | Info:=getAccessibleContextInfo(VmId, value) 91 | act:="" 92 | if (Instr(Info["States"],"focusable")) 93 | act:="focus, " 94 | if (Info["Accessible action"]<>0) 95 | { 96 | Actions:=getAccessibleActions(VmId, value) 97 | act:="" 98 | for ind2, val2 in Actions 99 | { 100 | act.= val2 ", " 101 | } 102 | } 103 | oident:="R:" Info["Role"] "N:" Info["Name"] "D:" Info["Description"] 104 | if (OBJCounter[oident]<1) 105 | { 106 | OBJCounter.Insert(oident,"0") 107 | } 108 | OBJCounter[oident]:=1+OBJCounter[oident] 109 | LV_Add("",index,OBJCounter[oident],Info["Role"],Info["Name"],Info["Description"],act,value) 110 | } 111 | LV_ModifyCol() 112 | str:="+MinSize" JCWSettings["13cMinSizeW"] "x" JCWSettings["13cMinSizeH"] 113 | Gui, 13: %str% 114 | x:=JCWSettings.SetIni("13GuiX","empty") 115 | y:=JCWSettings.SetIni("13GuiY","empty") 116 | w:=JCWSettings.SetIni("13GuiW","empty") 117 | h:=JCWSettings.SetIni("13GuiH","empty") 118 | JCWSettings.SetIni("13FileSavePath","") 119 | WinGetTitle, title 120 | if x is integer 121 | if y is integer 122 | if h is integer 123 | if w is integer 124 | { 125 | Gui, 13: Show, % "X" x " Y" y " W" w " H" h, % JCWSettings.ResourceString.13JControlTitle " " title 126 | } 127 | else 128 | Gui, 13: Show, Center, % JCWSettings.ResourceString.13JControlTitle " " title 129 | else 130 | Gui, 13: Show, Center, % JCWSettings.ResourceString.13JControlTitle " " title 131 | else 132 | Gui, 13: Show, Center, % JCWSettings.ResourceString.13JControlTitle " " title 133 | else 134 | Gui, 13: Show, Center, % JCWSettings.ResourceString.13JControlTitle " " title 135 | LV_Modify(1,"Select Focus Vis") 136 | } 137 | else 138 | { 139 | WinGetTitle, title 140 | msgbox, %hwnd%, %currctrl%, %currwin%, %title% 141 | } 142 | } 143 | 144 | 13GuiSize: 145 | 13GuiResize(A_GuiWidth, A_GuiHeight) 146 | return 147 | 148 | 13GuiResize(GuiWidth, GuiHeight) 149 | { 150 | GuiControl, 13:MoveDraw, 13JCtrlLVVar, % "w" GuiWidth-2*JCWSettings["13cMargin"] "h" GuiHeight-JCWSettings["13cSizeButH"] 151 | GuiControlGet, CSize, 13:Pos, 13JCtrlLVVar 152 | GuiControl, 13:MoveDraw, % JCWSettings.ResourceString.13JControlWriteSpeechFileButton, % "y" CSizeY+CSizeH+JCWSettings["13cMargin"] 153 | GuiControl, 13:MoveDraw, % JCWSettings.ResourceString.13JControlWriteCommandsFileButton, % "y" CSizeY+CSizeH+JCWSettings["13cMargin"] 154 | GuiControl, 13:MoveDraw, % JCWSettings.ResourceString.13JControlCopyCommandButton, % "y" CSizeY+CSizeH+JCWSettings["13cMargin"] 155 | GuiControl, 13:MoveDraw, % JCWSettings.ResourceString.13JControlSearchLabel, % "y" CSizeY+CSizeH+JCWSettings["13cMargin"]+5 156 | GuiControl, 13:MoveDraw, 13Searchfield, % "y" CSizeY+CSizeH+JCWSettings["13cMargin"] 157 | GuiControl, 13:MoveDraw, % JCWSettings.ResourceString.13JControlFindNextButton, % "y" CSizeY+CSizeH+JCWSettings["13cMargin"] 158 | GuiControl, 13:MoveDraw, % JCWSettings.ResourceString.ButtonClose, % "x" GuiWidth-JCWSettings["13cSizeCButW"] "y" CSizeY+CSizeH+JCWSettings["13cMargin"] 159 | if GuiWidth is integer 160 | JCWSettings["13GuiW"]:=GuiWidth 161 | if GuiHeight is integer 162 | JCWSettings["13GuiH"]:=GuiHeight 163 | } 164 | 165 | 13JVisItLVLAb: 166 | if (A_GuiEvent="I") 167 | { 168 | DisplayBorder() 169 | } 170 | return 171 | 172 | 13FindNextLabel: 173 | 13FindText(1) 174 | return 175 | 176 | 13SearchFieldLabel: 177 | 13FindText(0) 178 | return 179 | 180 | 13FindText(addline:=1) 181 | { 182 | global 13Searchfield 183 | Gui, 13: Default 184 | Gui, 13: ListView, 13JCtrlLVVar 185 | Gui, 13: Submit, NoHide 186 | fr:=LV_GetNext(0, "Focused") 187 | frs:=fr+addline 188 | cn:=LV_GetCount() 189 | found:=0 190 | while (frs<=cn) 191 | { 192 | LV_GetText(Output, frs , 3) 193 | if (InStr(Output, 13Searchfield)) 194 | { 195 | found:=1 196 | break 197 | } 198 | LV_GetText(Output, frs , 4) 199 | if (InStr(Output, 13Searchfield)) 200 | { 201 | found:=1 202 | break 203 | } 204 | LV_GetText(Output, frs , 5) 205 | if (InStr(Output, 13Searchfield)) 206 | { 207 | found:=1 208 | break 209 | } 210 | frs++ 211 | } 212 | if (!found) 213 | { 214 | frs:=1 215 | while (frs<=fr) 216 | { 217 | LV_GetText(Output, frs , 3) 218 | if (InStr(Output, 13Searchfield)) 219 | { 220 | found:=1 221 | break 222 | } 223 | LV_GetText(Output, frs , 4) 224 | if (InStr(Output, 13Searchfield)) 225 | { 226 | found:=1 227 | break 228 | } 229 | LV_GetText(Output, frs , 5) 230 | if (InStr(Output, 13Searchfield)) 231 | { 232 | found:=1 233 | break 234 | } 235 | frs++ 236 | } 237 | } 238 | if (found) 239 | { 240 | LV_Modify(frs,"Select Focus Vis") 241 | } 242 | } 243 | 244 | DisplayBorder() 245 | { 246 | Gui, 13: Default 247 | Gui, 13: ListView, 13JCtrlLVVar 248 | fr:=LV_GetNext(0, "Focused") 249 | LV_GetText(Output, fr , 1) 250 | Info:=getAccessibleContextInfo(JCWSettings.13JWinVmId, JCWSettings["13JWinVisibleChildren"][Output]) 251 | x:=Info["X"] 252 | y:=Info["Y"] 253 | w:=Info["Width"] 254 | h:=Info["Height"] 255 | Gui, 14: Destroy 256 | border_thickness:= 10 257 | Gui, 14: +Lastfound +AlwaysOnTop +Toolwindow 258 | iw:= w+border_thickness 259 | ih:= h+border_thickness 260 | w:=w+border_thickness*2 261 | h:=h+border_thickness*2 262 | x:= x -border_thickness 263 | y:= y -border_thickness 264 | Gui, 14: Color, 00FF00 265 | Gui, 14: -Caption 266 | WinSet, Region, 0-0 %w%-0 %w%-%h% 0-%h% 0-0 %border_thickness%-%border_thickness% %iw%-%border_thickness% %iw%-%ih% %border_thickness%-%ih% %border_thickness%-%border_thickness% 267 | Gui, 14: Show, w%w% h%h% x%x% y%y% NoActivate, 268 | } 269 | 270 | 13WriteCommandsFile: 271 | WriteCommandsFile() 272 | return 273 | 274 | WriteCommandsFile() 275 | { 276 | WinGetTitle, WinTitle, % "ahk_id " JCWSettings.13hwnd 277 | FileSelectFile, filename, S 18, % JCWSettings["13FileSavePath"] WinTitle ".ahk" 278 | If (filename<>"") 279 | { 280 | SplitPath, filename, , OutDir 281 | JCWSettings["13FileSavePath"]:=OutDir "\" 282 | file:=FileOpen(filename,"w `n") 283 | OBJCounter:= 284 | OBJCounter:=Object() 285 | For index, value in JCWSettings.13JWinVisibleChildren 286 | { 287 | Info:= 288 | Info:=getAccessibleContextInfo(JCWSettings.13JWinVmId, value) 289 | If (Info["Role"]<>"panel" and Info["Role"]<>"filler" and Info["Role"]<>"root pane" and Info["Role"]<>"layered pane" and Info["Role"]<>"menu bar" and Info["Role"]<>"tool bar" and Info["Role"]<>"separator" and Info["Role"]<>"split pane" and Info["Role"]<>"viewport" and Info["Role"]<>"scroll bar" and Info["Role"]<>"scroll pane") 290 | { 291 | Action:="" 292 | if (Info["Accessible action"]<>0) 293 | { 294 | Actions:=getAccessibleActions(JCWSettings.13JWinVmId, value) 295 | Action:="" 296 | for ind2, val2 in Actions 297 | { 298 | Action.= val2 ", " 299 | } 300 | } 301 | Action:=Trim(Trim(Action),",") 302 | if (Instr(Info["States"],"focusable") and act="") 303 | act:="focus" 304 | oident:="R:" Info["Role"] "N:" Info["Name"] "D:" Info["Description"] 305 | if (OBJCounter[oident]<1) 306 | { 307 | OBJCounter.Insert(oident,"0") 308 | } 309 | OBJCounter[oident]:=1+OBJCounter[oident] 310 | if (Action<>"") 311 | { 312 | c:="JavaControlDoAction(0, """ . Info["name"] . """, """ Info["Role"] . """, """ . Info["Description"] . """, """ . OBJCounter[oident] . """, """ . Action . """)" 313 | file.WriteLine(c) 314 | } 315 | } 316 | } 317 | file.Close() 318 | } 319 | } 320 | 321 | 13CopyCommand: 322 | CopyJCommand() 323 | return 324 | 325 | CopyJCommand() 326 | { 327 | global 13JCtrlLVVar 328 | Gui, 13: Default 329 | Gui, 13: ListView, 13JCtrlLVVar 330 | fr:=LV_GetNext(0, "Focused") 331 | LV_GetText(Output, fr , 1) 332 | Info:=getAccessibleContextInfo(JCWSettings.13JWinVmId, JCWSettings["13JWinVisibleChildren"][Output]) 333 | LV_GetText(Output, fr , 6) 334 | Action:=Trim(Trim(Output),",") 335 | LV_GetText(Output, fr , 2) 336 | s:="JavaControlDoAction(0, """ . Info["Name"] . """, """ Info["Role"] . """, """ . Info["Description"] . """, """ . Output . """, """ . Action . """)" . Chr(13) Chr(10) 337 | ClipBoard:=s 338 | } 339 | 340 | 13SaveGuiPos() 341 | { 342 | global 13GuiHwnd 343 | WinGetPos, x, y, , , ahk_id %13GuiHwnd% 344 | JCWSettings["13GuiX"]:=x 345 | JCWSettings["13GuiY"]:=y 346 | } 347 | 348 | 13GuiEscape: 349 | 13GuiClose: 350 | 14GuiEscape: 351 | 14GuiClose: 352 | 13Cancel: 353 | 13SaveGuiPos() 354 | Gui, 13: Destroy 355 | Gui, 14: Destroy 356 | JCWSettings.13JWinVisibleChildren:= 357 | return 358 | 359 | LoadResourceStrings(ResourceFile, byref BaseObject, Language:="English") 360 | { 361 | If (IsObject(BaseObject)) 362 | { 363 | If (BaseObject.HasKey("ResourceString")) 364 | ObjRelease(BaseObject.ResourceString) 365 | BaseObject.ResourceString:=Object() 366 | IniRead, ResStrings, %ResourceFile%, %Language% 367 | Loop, Parse, ResStrings, `n, `r 368 | { 369 | cnt:=Instr(A_LoopField,"=")-1 370 | StringLeft, Left, A_LoopField, %cnt% 371 | BaseObject["ResourceString"][Left]:=UnEscapeLiteralStr(SubStr(A_LoopField,cnt+2)) 372 | } 373 | } 374 | } 375 | 376 | UnEscapeLiteralStr(Line) 377 | { 378 | tline:=Line 379 | StringReplace, tline, tline, ```,, `,, All 380 | StringReplace, tline, tline, ```%, `%, All 381 | StringReplace, tline, tline, ```;, `;, All 382 | StringReplace, tline, tline, ``n, `n, All 383 | StringReplace, tline, tline, ``r, `r, All 384 | StringReplace, tline, tline, ``b, `b, All 385 | StringReplace, tline, tline, ``t, `t, All 386 | StringReplace, tline, tline, ``v, `v, All 387 | StringReplace, tline, tline, ``a, `a, All 388 | StringReplace, tline, tline, ``f, `f, All 389 | Return, tline 390 | } 391 | 392 | class ApplicationSettingsClass 393 | { 394 | 395 | __New(IniFile:="", Section:="Main") 396 | { 397 | ApplicationSettingsClass.hidden[this]:= { ASVars: [], ASConsts: [], ASInis: []} 398 | ApplicationSettingsClass.hidden[this].IniFilePath:=IniFile 399 | ApplicationSettingsClass.hidden[this].IniSection:=Section 400 | } 401 | 402 | __Get(VarName) 403 | { 404 | If (ApplicationSettingsClass.hidden[this].ASConsts.HasKey(VarName)) 405 | return, ApplicationSettingsClass.hidden[this].ASConsts[VarName] 406 | else If (ApplicationSettingsClass.hidden[this].ASInis.HasKey(VarName)) 407 | return, ApplicationSettingsClass.hidden[this].ASInis[VarName] 408 | else If (ApplicationSettingsClass.hidden[this].ASVars.HasKey(VarName)) 409 | return, ApplicationSettingsClass.hidden[this].ASVars[VarName] 410 | else MsgBox, Read from undefined variable: %VarName% 411 | } 412 | 413 | __Set(VarName, byref Value) 414 | { 415 | If (ApplicationSettingsClass.hidden[this].ASConsts.HasKey(VarName)) 416 | { 417 | MsgBox, Attempt to write to constant: %VarName% 418 | return 419 | } 420 | else If (ApplicationSettingsClass.hidden[this].ASInis.HasKey(VarName)) 421 | { 422 | ApplicationSettingsClass.hidden[this].ASInis[VarName]:=Value 423 | If ApplicationSettingsClass.hidden[this].IniFilePath<>"" 424 | { 425 | IniWrite, %Value%, % ApplicationSettingsClass.hidden[this].IniFilePath, % ApplicationSettingsClass.hidden[this].IniSection, %VarName% 426 | } 427 | return 428 | } 429 | else 430 | return ApplicationSettingsClass.hidden[this].ASVars[VarName]:=Value 431 | } 432 | 433 | SetConstant(VarName, byref Value) 434 | { 435 | If (ApplicationSettingsClass.hidden[this].ASConsts.HasKey(VarName)) 436 | { 437 | MsgBox, Attempt to write to constant: %VarName% 438 | return 439 | } 440 | else 441 | { 442 | ApplicationSettingsClass.hidden[this].ASConsts[VarName]:=Value 443 | return, value 444 | } 445 | } 446 | 447 | SetIni(VarName, DefaultValue:="") 448 | { 449 | If (ApplicationSettingsClass.hidden[this].ASConsts.HasKey(VarName)) 450 | { 451 | MsgBox, Attempt to overload constant: %VarName% 452 | return 453 | } 454 | else 455 | { 456 | If ApplicationSettingsClass.hidden[this].IniFilePath<>"" 457 | { 458 | IniRead, Value, % ApplicationSettingsClass.hidden[this].IniFilePath, % ApplicationSettingsClass.hidden[this].IniSection, %VarName%, EMPTYVALUE 459 | If (Value="EMPTYVALUE") 460 | { 461 | Value:=DefaultValue 462 | IniWrite, %Value%, % ApplicationSettingsClass.hidden[this].IniFilePath, % ApplicationSettingsClass.hidden[this].IniSection, %VarName% 463 | } 464 | ApplicationSettingsClass.hidden[this].ASInis[VarName]:=Value 465 | } 466 | return, value 467 | } 468 | } 469 | 470 | GetIniFilePath() 471 | { 472 | return, ApplicationSettingsClass.hidden[this].IniFilePath 473 | } 474 | 475 | __Delete() 476 | { 477 | this.Remove("ASVars") 478 | this.Remove("ASConsts") 479 | this.Remove("ASInis") 480 | } 481 | } -------------------------------------------------------------------------------- /JavaAccessBridge.ahk: -------------------------------------------------------------------------------- 1 | GetTextInfo() 2 | { 3 | global JABVariables 4 | txt:="" 5 | if (!JABVariables["JABInitialised"]) 6 | InitJavaAccessBridge() 7 | if (JABVariables["JABInitialised"]) 8 | { 9 | hwnd:=WinExist("A") 10 | if (!IsJavaWindow(hwnd)) 11 | { 12 | ControlGetFocus, currctrl, ahk_id %hwnd% 13 | ControlGet, currwin, Hwnd, , %currctrl%, ahk_id %hwnd% 14 | } 15 | else currwin:=hwnd 16 | vmID:=0 17 | ac:=0 18 | if (IsJavaWindow(currwin)) 19 | { 20 | GetAccessibleContextWithFocus(currwin, vmID, ac) 21 | } 22 | If (ac<>0) 23 | { 24 | res:=GetAccessibleContextInfo(vmID, ac) 25 | If (res["Accessible text interface"]) 26 | { 27 | res:=GetCaretLocation(vmID, ac) 28 | caretmx:=res["X"]+res["Width"]//2 29 | caretmy:=res["Y"]+res["Height"]/2 30 | txt.="GetCaretLocation`n" 31 | txt.="X: " res["X"] " Y: " res["Y"] " Width: " res["Width"] " Height: " res["Height"] "`n" 32 | res:=GetAccessibleTextInfo(vmID, ac, caretmx, caretmy) 33 | txt.="GetAccessibleTextInfo`n" 34 | txt.="CharCount: " res["CharCount"] " CaretIndex: " res["CaretIndex"] " IndexAtPoint (mid cursor): " res["IndexAtPoint"] "`n" 35 | caretindex:=res["CaretIndex"] 36 | res:=GetAccessibleTextItems(vmID, ac, caretindex) 37 | txt.="GetAccessibleTextItems`n" 38 | txt.="letter: " res["letter"] " word: " res["word"] " sentence: " res["sentence"] "`n" 39 | res:=GetAccessibleTextSelectionInfo(vmID, ac) 40 | txt.="GetAccessibleTextSelectionInfo`n" 41 | txt.="SelectionStartIndex: " res["SelectionStartIndex"] " SelectionEndIndex: " res["SelectionEndIndex"] " SelectedText: " res["SelectedText"] "`n" 42 | res:=GetAccessibleTextRange(vmID, ac, caretindex-5, caretindex+5) 43 | txt.="GetAccessibleTextRange`n" 44 | txt.="Text: " res "`n" 45 | res:=GetAccessibleTextRect(vmID, ac, caretindex) 46 | txt.="GetAccessibleTextRect`n" 47 | txt.="X: " res["X"] " Y: " res["Y"] " Width: " res["Width"] " Height: " res["Height"] "`n" 48 | res:=GetAccessibleTextLineBounds(vmID, ac, caretindex) 49 | txt.="GetAccessibleTextLineBounds`n" 50 | txt.="StartPos: " res["StartPos"] " EndPos: " res["EndPos"] "`n" 51 | 52 | ;~ ; retrieves the text attributes as an object with the keys: 53 | ;~ ; bold, italic, underline, strikethrough, superscript, subscript, 54 | ;~ ; backgroundColor, foregroundColor, fontFamily, fontSize, 55 | ;~ ; alignment, bidiLevel, firstLineIndent, leftIndent, rightIndent, 56 | ;~ ; lineSpacing, spaceAbove, spaceBelow, fullAttributesString 57 | ;~ GetAccessibleTextAttributes(vmID, ac) 58 | ;~ txt.=" : " " : " " : " "`n" 59 | ;~ ; retrieves the text attributes as an object with the keys: 60 | ;~ ; bold, italic, underline, strikethrough, superscript, subscript, 61 | ;~ ; backgroundColor, foregroundColor, fontFamily, fontSize, 62 | ;~ ; alignment, bidiLevel, firstLineIndent, leftIndent, rightIndent, 63 | ;~ ; lineSpacing, spaceAbove, spaceBelow, fullAttributesString 64 | ;~ GetTextAttributesInRange(vmID, ac, startc:=0, endc:=0) 65 | ;~ txt.=" : " " : " " : " "`n" 66 | 67 | } 68 | else txt:="Current accessible context does not have an accessible text interface." 69 | } 70 | else txt:="No valid accessible context with focus found." 71 | } 72 | else txt:="Java Access Bridge not initialized." 73 | return, txt 74 | } 75 | 76 | ; The function JavaControlDoAction searches for the -instance of a Java-control that fits in , and and performs -times 77 | ; actions can be all actions provided by the control itself or: 78 | ; - focus: attempts to focus the control and left clicks it if focusing fails 79 | ; - check pos: tries if the object has a valid screen location 80 | ; - left/double/right/middle click; wheel up/down: performs the respective mouse action in the center of the control 81 | 82 | JavaControlDoAction(hwnd:=0, name:="", role:="", description:="", occurrence:="", action:="", times:=1, parentcontext:=0) 83 | { 84 | global JABVariables 85 | rval:=JavaControlGet(hwnd, name, role, description, occurrence, parentcontext) 86 | If (IsObject(rval)) 87 | { 88 | Info:=getAccessibleContextInfo(rval["vmid"], rval["ac"]) 89 | Loop, %times% 90 | { 91 | if (action="check pos") 92 | { 93 | If !(Info["X"]=-1 and Info["Width"]=-1 and Info["Y"]=-1 and Info["Height"]=-1) 94 | return, 0 95 | else 96 | return, -3 97 | } 98 | if (action="focus") 99 | { 100 | If (Instr(Info["States"],"focusable")) 101 | { 102 | failure:= RequestFocus(rval["vmid"], rval["ac"]) 103 | if (failure<>0) 104 | { 105 | rval:=MouseClickJControl(Info) 106 | } 107 | } 108 | else return, -2 109 | } 110 | else if (action="left click") 111 | { 112 | rval:=MouseClickJControl(Info) 113 | } 114 | else if (action="double click") 115 | { 116 | rval:=MouseClickJControl(Info,"left",2) 117 | } 118 | else if (action="right click") 119 | { 120 | rval:=MouseClickJControl(Info,"right") 121 | } 122 | else if (action="middle click") 123 | { 124 | rval:=MouseClickJControl(Info,"middle") 125 | } 126 | else if (action="wheel up") 127 | { 128 | rval:=MouseClickJControl(Info,"wheel up") 129 | } 130 | else if (action="wheel down") 131 | { 132 | rval:=MouseClickJControl(Info,"wheel down") 133 | } 134 | else 135 | { 136 | rval:=DoAccessibleActions(rval["vmid"], rval["ac"], action) 137 | } 138 | } 139 | If (times>A_Index) 140 | Sleep, 50 141 | return, rval 142 | } 143 | else 144 | return, rval 145 | } 146 | 147 | JavaControlGet(hwnd:=0, name:="", role:="", description:="", occurrence:="", parentcontext:=0) 148 | { 149 | global JABVariables 150 | if (!JABVariables["JABInitialised"]) 151 | InitJavaAccessBridge() 152 | if (JABVariables["JABInitialised"]) 153 | { 154 | If (IsObject(parentcontext)) 155 | { 156 | ac:=parentcontext["ac"] 157 | vmid:=parentcontext["vmid"] 158 | } 159 | else 160 | { 161 | if (hwnd=0) 162 | { 163 | hwnd:=WinExist("A") 164 | if (!IsJavaWindow(hwnd)) 165 | { 166 | ControlGetFocus, currctrl, ahk_id %hwnd% 167 | ControlGet, currwin, Hwnd, , %currctrl%, ahk_id %hwnd% 168 | } 169 | else currwin:=hwnd 170 | } 171 | else currwin:=hwnd 172 | vmID:=0 173 | ac:=0 174 | if (IsJavaWindow(currwin)) 175 | { 176 | getAccessibleContextFromHWND(currwin, vmID, ac) 177 | } 178 | } 179 | If (ac<>0) 180 | { 181 | If (occurrence>1) 182 | { 183 | Loop, 2 184 | { 185 | Info:= 186 | If (JABVariables["CachedParentAc"]=ac) 187 | { 188 | Children:=JABVariables["CachedChildren"] 189 | } 190 | else 191 | { 192 | Children:=GetVisibleChildrenFromTree(vmID, ac) 193 | JABVariables["CachedChildren"] :=Children 194 | JABVariables["CachedParentAc"] :=ac 195 | } 196 | occurcnt:=0 197 | For index, value in Children 198 | { 199 | Info:=getAccessibleContextInfo(vmID, value) 200 | if ((name="" or RegExMatch(Info["Name"],name)) 201 | and (role="" or role=Info["Role"]) 202 | and (description="" or RegExMatch(Info["Description"],description))) 203 | { 204 | occurcnt++ 205 | if (Occurrence=occurcnt or Occurrence=0 or Occurrence="") 206 | { 207 | return, CreateContext(vmid, value) 208 | } 209 | } 210 | } 211 | JABVariables["CachedParentAc"] :=0 212 | } 213 | } 214 | else 215 | { 216 | retval:=FindVisibleChild(vmID, ac, name, role, description) 217 | if (retval<>"") 218 | return, retval 219 | else 220 | return, -3 221 | } 222 | } 223 | } 224 | else 225 | { 226 | return, -1 227 | } 228 | } 229 | 230 | FindVisibleChild(vmID, ac, name:="", role:="", description:="") 231 | { 232 | global JABVariables 233 | retval:="" 234 | Info:=getAccessibleContextInfo(vmID,ac) 235 | If (Instr(Info["States"],"visible")) 236 | { 237 | if ((name="" or RegExMatch(Info["Name"],name)) 238 | and (role="" or role=Info["Role"]) 239 | and (description="" or RegExMatch(Info["Description"],description))) 240 | { 241 | retval:=CreateContext(vmid, ac) 242 | } 243 | if (retval="") 244 | { 245 | Loop, % Info["Children count"] 246 | { 247 | rac:=GetAccessibleChildFromContext(vmID, ac, A_Index-1) 248 | retval:=FindVisibleChild(vmID, rac, name, role, description) 249 | if (retval<>"") 250 | break 251 | } 252 | } 253 | } 254 | return, retval 255 | } 256 | 257 | CreateContext(vmid, ac) 258 | { 259 | rval:=Object() 260 | rval["vmid"]:=vmid 261 | rval["ac"]:=ac 262 | rval["AccessMode"]:="JAB" 263 | return, rval 264 | } 265 | 266 | SplitContext(context, byref vmid, byref ac) 267 | { 268 | If (IsObject(context)) 269 | { 270 | vmid:=context["vmid"] 271 | ac:=context["ac"] 272 | return, 0 273 | } 274 | else 275 | return, -1 276 | } 277 | 278 | ; used to retrieve an object with all visible children of the input control 279 | GetVisibleChildrenFromTree(vmID, ac) 280 | { 281 | global JABVariables 282 | Children:=Object() 283 | if (JABVariables["JABInitialised"]) 284 | { 285 | RecurseVisibleChildren(vmID, ac, Children) 286 | } 287 | Return, Children 288 | } 289 | 290 | RecurseVisibleChildren(vmID, ac, byref Children) 291 | { 292 | global JABVariables 293 | Info:=getAccessibleContextInfo(vmID,ac) 294 | If (Instr(Info["States"],"visible")) 295 | { 296 | If (Children.MaxIndex()="") 297 | Children[1]:=ac 298 | else 299 | Children[Children.MaxIndex()+1]:=ac 300 | Loop, % Info["Children count"] 301 | { 302 | rac:=GetAccessibleChildFromContext(vmID, ac, A_Index-1) 303 | RecurseVisibleChildren(vmID, rac, Children) 304 | } 305 | } 306 | } 307 | 308 | GetControlTree(vmID, ac, Invisible:=0) 309 | { 310 | global JABVariables 311 | RetObj:=Object() 312 | Info:=getAccessibleContextInfo(vmID,ac) 313 | If (Instr(Info["States"],"visible") or invisible) 314 | { 315 | RetObj["ac"]:=ac 316 | RetObj["Children"]:=Object() 317 | Loop, % Info["Children count"] 318 | { 319 | rac:=GetAccessibleChildFromContext(vmID, ac, A_Index-1) 320 | RetObj["Children"][A_Index-1]:=GetControlTree(vmID, rac, Invisible) 321 | } 322 | } 323 | return, RetObj 324 | } 325 | 326 | ; used to retrieve an object with all children that are likely to be controlled 327 | GetControllableChildrenFromTree(vmID, ac) 328 | { 329 | global JABVariables 330 | Children:=Object() 331 | if (JABVariables["JABInitialised"]) 332 | { 333 | RecurseControllableChildren(vmID, ac, Children) 334 | } 335 | Return, Children 336 | } 337 | 338 | RecurseControllableChildren(vmID, ac, byref Children) 339 | { 340 | global JABVariables 341 | Info:=getAccessibleContextInfo(vmID,ac) 342 | If (Instr(Info["States"],"visible")) 343 | { 344 | blockedroles:=JABVariables["BlockedRoles"] 345 | role:=Info["Role"] 346 | If role not in %blockedroles% 347 | Children.Insert(ac) 348 | ;~ If (Children.MaxIndex()="") 349 | ;~ Children[1]:=ac 350 | ;~ else 351 | ;~ Children[Children.MaxIndex()+1]:=ac 352 | Loop, % Info["Children count"] 353 | { 354 | rac:=GetAccessibleChildFromContext(vmID, ac, A_Index-1) 355 | RecurseControllableChildren(vmID, rac, Children) 356 | } 357 | } 358 | } 359 | 360 | ; used to retrieve an object with all children of the input control 361 | GetAllChildrenFromTree(vmID, ac) 362 | { 363 | global JABVariables 364 | Children:=Object() 365 | if (JABVariables["JABInitialised"]) 366 | { 367 | RecurseAllChildren(vmID, ac, Children) 368 | } 369 | Return, Children 370 | } 371 | 372 | RecurseAllChildren(vmID, ac, byref Children) 373 | { 374 | global JABVariables 375 | Info:=getAccessibleContextInfo(vmID,ac) 376 | If (Children.MaxIndex()="") 377 | Children[1]:=ac 378 | else 379 | Children[Children.MaxIndex()+1]:=ac 380 | Loop, % Info["Children count"] 381 | { 382 | rac:=GetAccessibleChildFromContext(vmID, ac, A_Index-1) 383 | RecurseAllChildren(vmID, rac, Children) 384 | } 385 | } 386 | 387 | ; performs mouse clicks in the center of the specified control 388 | MouseClickJControl(byref Info, action:="left", count:=1) 389 | { 390 | If !(Info["X"]=-1 and Info["Width"]=-1 and Info["Y"]=-1 and Info["Height"]=-1) 391 | { 392 | xp:=Floor(Info["X"]+Info["Width"]/2) 393 | yp:=Floor(Info["Y"]+Info["Height"]/2) 394 | CoordMode, Mouse, Screen 395 | SetMouseDelay, 0 396 | SetDefaultMouseSpeed, 0 397 | BlockInput On 398 | MouseGetPos, MouseX, MouseY 399 | ;~ sleep, 50 400 | MouseClick, %action%, %xp%, %yp%, %count% 401 | If (action<>"right") 402 | { 403 | sleep, 100 404 | MouseMove, %MouseX%, %MouseY% 405 | } 406 | BlockInput Off 407 | return, 0 408 | ;~ msgbox, %action% 409 | } 410 | else 411 | return, -1 412 | } 413 | 414 | ; Java Access Bridge functions; see Access Bridge documentation for details 415 | 416 | ; Initialises the bridge access 417 | InitJavaAccessBridge(ForceLegacy:=0) 418 | { 419 | global JABVariables 420 | JABVariables:= Object() 421 | JABVariables["JABInitialised"]:=False 422 | JABVariables["JAB_DLLVersion"] :="" 423 | JABVariables["JAB_DLL"] :="" 424 | JABVariables["acType"] :="Int64" 425 | JABVariables["acPType"] :="Int64*" 426 | JABVariables["acSize"] :=8 427 | 428 | JABVariables["MAX_BUFFER_SIZE"] := 10240 429 | JABVariables["MAX_STRING_SIZE"] := 1024 430 | JABVariables["SHORT_STRING_SIZE"] := 256 431 | 432 | JABVariables["ACCESSIBLE_ALERT"] := "alert" 433 | JABVariables["ACCESSIBLE_COLUMN_HEADER"] := "column header" 434 | JABVariables["ACCESSIBLE_CANVAS"] := "canvas" 435 | JABVariables["ACCESSIBLE_COMBO_BOX"] := "combo box" 436 | JABVariables["ACCESSIBLE_DESKTOP_ICON"] := "desktop icon" 437 | JABVariables["ACCESSIBLE_INTERNAL_FRAME"] := "internal frame" 438 | JABVariables["ACCESSIBLE_DESKTOP_PANE"] := "desktop pane" 439 | JABVariables["ACCESSIBLE_OPTION_PANE"] := "option pane" 440 | JABVariables["ACCESSIBLE_WINDOW"] := "window" 441 | JABVariables["ACCESSIBLE_FRAME"] := "frame" 442 | JABVariables["ACCESSIBLE_DIALOG"] := "dialog" 443 | JABVariables["ACCESSIBLE_COLOR_CHOOSER"] := "color chooser" 444 | JABVariables["ACCESSIBLE_DIRECTORY_PANE"] := "directory pane" 445 | JABVariables["ACCESSIBLE_FILE_CHOOSER"] := "file chooser" 446 | JABVariables["ACCESSIBLE_FILLER"] := "filler" 447 | JABVariables["ACCESSIBLE_HYPERLINK"] := "hyperlink" 448 | JABVariables["ACCESSIBLE_ICON"] := "icon" 449 | JABVariables["ACCESSIBLE_LABEL"] := "label" 450 | JABVariables["ACCESSIBLE_ROOT_PANE"] := "root pane" 451 | JABVariables["ACCESSIBLE_GLASS_PANE"] := "glass pane" 452 | JABVariables["ACCESSIBLE_LAYERED_PANE"] := "layered pane" 453 | JABVariables["ACCESSIBLE_LIST"] := "list" 454 | JABVariables["ACCESSIBLE_LIST_ITEM"] := "list item" 455 | JABVariables["ACCESSIBLE_MENU_BAR"] := "menu bar" 456 | JABVariables["ACCESSIBLE_POPUP_MENU"] := "popup menu" 457 | JABVariables["ACCESSIBLE_MENU"] := "menu" 458 | JABVariables["ACCESSIBLE_MENU_ITEM"] := "menu item" 459 | JABVariables["ACCESSIBLE_SEPARATOR"] := "separator" 460 | JABVariables["ACCESSIBLE_PAGE_TAB_LIST"] := "page tab list" 461 | JABVariables["ACCESSIBLE_PAGE_TAB"] := "page tab" 462 | JABVariables["ACCESSIBLE_PANEL"] := "panel" 463 | JABVariables["ACCESSIBLE_PROGRESS_BAR"] := "progress bar" 464 | JABVariables["ACCESSIBLE_PASSWORD_TEXT"] := "password text" 465 | JABVariables["ACCESSIBLE_PUSH_BUTTON"] := "push button" 466 | JABVariables["ACCESSIBLE_TOGGLE_BUTTON"] := "toggle button" 467 | JABVariables["ACCESSIBLE_CHECK_BOX"] := "check box" 468 | JABVariables["ACCESSIBLE_RADIO_BUTTON"] := "radio button" 469 | JABVariables["ACCESSIBLE_ROW_HEADER"] := "row header" 470 | JABVariables["ACCESSIBLE_SCROLL_PANE"] := "scroll pane" 471 | JABVariables["ACCESSIBLE_SCROLL_BAR"] := "scroll bar" 472 | JABVariables["ACCESSIBLE_VIEWPORT"] := "viewport" 473 | JABVariables["ACCESSIBLE_SLIDER"] := "slider" 474 | JABVariables["ACCESSIBLE_SPLIT_PANE"] := "split pane" 475 | JABVariables["ACCESSIBLE_TABLE"] := "table" 476 | JABVariables["ACCESSIBLE_TEXT"] := "text" 477 | JABVariables["ACCESSIBLE_TREE"] := "tree" 478 | JABVariables["ACCESSIBLE_TOOL_BAR"] := "tool bar" 479 | JABVariables["ACCESSIBLE_TOOL_TIP"] := "tool tip" 480 | JABVariables["ACCESSIBLE_AWT_COMPONENT"] := "awt component" 481 | JABVariables["ACCESSIBLE_SWING_COMPONENT"] := "swing component" 482 | JABVariables["ACCESSIBLE_UNKNOWN"] := "unknown" 483 | JABVariables["ACCESSIBLE_STATUS_BAR"] := "status bar" 484 | JABVariables["ACCESSIBLE_DATE_EDITOR"] := "date editor" 485 | JABVariables["ACCESSIBLE_SPIN_BOX"] := "spin box" 486 | JABVariables["ACCESSIBLE_FONT_CHOOSER"] := "font chooser" 487 | JABVariables["ACCESSIBLE_GROUP_BOX"] := "group box" 488 | JABVariables["ACCESSIBLE_HEADER"] := "header" 489 | JABVariables["ACCESSIBLE_FOOTER"] := "footer" 490 | JABVariables["ACCESSIBLE_PARAGRAPH"] := "paragraph" 491 | JABVariables["ACCESSIBLE_RULER"] := "ruler" 492 | JABVariables["ACCESSIBLE_EDITBAR"] := "editbar" 493 | JABVariables["PROGRESS_MONITOR"] := "progress monitor" 494 | JABVariables["CachedParentAc"] :=0 495 | JABVariables["CachedChildren"] := 496 | JABVariables["BlockedRoles"] := "panel,filler,root pane,layered pane,menu bar,tool bar,separator,split pane,viewport,scroll bar,scroll pane" 497 | JABVariables["HandledDefaultActions"] := "focus|check pos|left click|double click|right click|middle click|wheel up|wheel down" 498 | if (ForceLegacy=1) 499 | { 500 | JABVariables["JAB_DLLVersion"]:="WindowsAccessBridge" 501 | JABVariables["JAB_DLL"]:=DllCall("LoadLibrary", "Str", JABVariables["JAB_DLLVersion"] ".dll") 502 | JABVariables["acType"]:="Int" 503 | JABVariables["acPType"]:="Int*" 504 | JABVariables["acSize"]:=4 505 | } 506 | else 507 | if (A_PtrSize=8) 508 | { 509 | JABVariables["JAB_DLLVersion"]:="WindowsAccessBridge-64" 510 | JABVariables["JAB_DLL"]:=DllCall("LoadLibrary", "Str", JABVariables["JAB_DLLVersion"] ".dll") 511 | } 512 | else 513 | { 514 | JABVariables["JAB_DLLVersion"]:="WindowsAccessBridge-32" 515 | JABVariables["JAB_DLL"]:=DllCall("LoadLibrary", "Str", JABVariables["JAB_DLLVersion"] ".dll") 516 | if (JABVariables["JAB_DLL"]=0) 517 | { 518 | JABVariables["JAB_DLLVersion"]:="WindowsAccessBridge" 519 | JABVariables["JAB_DLL"]:=DllCall("LoadLibrary", "Str", JABVariables["JAB_DLLVersion"] ".dll") 520 | JABVariables["acType"]:="Int" 521 | JABVariables["acPType"]:="Int*" 522 | JABVariables["acSize"]:=4 523 | } 524 | } 525 | ; it is necessary to preload the DLL 526 | ; otherwise none of the calls suceed 527 | 528 | ; start up the access bridge 529 | JABVariables["JABInitialised"]:=DllCall(JABVariables["JAB_DLLVersion"] "\Windows_run", "Cdecl Int") 530 | ; it is necessary to give the application a few message cycles time before calling access bridge function 531 | ; otherwise all calls will fail 532 | Sleep, 200 ; minimum 100 for all machines? 533 | Return, JABVariables["JABInitialised"] 534 | } 535 | 536 | ; shuts down the access bridge 537 | ExitJavaAccessBridge() 538 | { 539 | global JABVariables 540 | if (JABVariables["JABInitialised"]) 541 | { 542 | DllCall("FreeLibrary", "Ptr", JABVariables["JAB_DLL"]) 543 | } 544 | } 545 | 546 | IsJavaWindow(hwnd) 547 | { 548 | global JABVariables 549 | if (JABVariables["JABInitialised"]) 550 | { 551 | Return DllCall(JABVariables["JAB_DLLVersion"] "\isJavaWindow", "Int", hWnd, "Cdecl Int") 552 | } 553 | else 554 | { 555 | Return 0 556 | } 557 | } 558 | 559 | ; returns JAB version information as object containing the keys: VMversion, bridgeJavaClassVersion, bridgeJavaDLLVersion, bridgeWinDLLVersion 560 | GetVersionInfo(vmID) 561 | { 562 | global JABVariables 563 | Info:=Object() 564 | if (JABVariables["JABInitialised"]) 565 | { 566 | VarSetCapacity(TempInfo, 2048,0) 567 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getVersionInfo", "Int", vmID, "UInt", &TempInfo, "Cdecl Int")) 568 | { 569 | verstr:="" 570 | Loop, % JABVariables["SHORT_STRING_SIZE"] 571 | { 572 | offset:=(A_Index-1)*2 573 | jver:=Chr(NumGet(TempInfo,offset,"UChar")) 574 | if (jver=Chr(0)) 575 | { 576 | break 577 | } 578 | verstr.=jver 579 | } 580 | Info["VMversion"]:=verstr 581 | verstr:="" 582 | Loop, % JABVariables["SHORT_STRING_SIZE"] 583 | { 584 | offset:=((A_Index-1)*2)+JABVariables["SHORT_STRING_SIZE"]*2 585 | jver:=Chr(NumGet(&TempInfo,offset,"UChar")) 586 | if (jver=Chr(0)) 587 | { 588 | break 589 | } 590 | verstr.=jver 591 | } 592 | Info["bridgeJavaClassVersion"]:=verstr 593 | verstr:="" 594 | Loop, % JABVariables["SHORT_STRING_SIZE"] 595 | { 596 | offset:=(A_Index-1)*2+JABVariables["SHORT_STRING_SIZE"]*4 597 | jver:=Chr(NumGet(&TempInfo,offset,"UChar")) 598 | if (jver=Chr(0)) 599 | { 600 | break 601 | } 602 | verstr.=jver 603 | } 604 | Info["bridgeJavaDLLVersion"]:=verstr 605 | verstr:="" 606 | Loop, % JABVariables["SHORT_STRING_SIZE"] 607 | { 608 | offset:=(A_Index-1)*2+JABVariables["SHORT_STRING_SIZE"]*6 609 | jver:=Chr(NumGet(&TempInfo,offset,"UChar")) 610 | if (jver=Chr(0)) 611 | { 612 | break 613 | } 614 | verstr.=jver 615 | } 616 | Info["bridgeWinDLLVersion"]:=verstr 617 | } 618 | } 619 | Return Info 620 | } 621 | 622 | ReleaseJavaObject(vmID, ac) 623 | { 624 | global JABVariables 625 | if (JABVariables["JABInitialised"]) 626 | { 627 | DllCall(JABVariables["JAB_DLLVersion"] "\ReleaseJavaObject", "Int", vmID, JABVariables["acType"], ac, "Cdecl") 628 | } 629 | } 630 | 631 | IsSameObject(vmID, ac1, ac2) 632 | { 633 | global JABVariables 634 | if (JABVariables["JABInitialised"]) 635 | { 636 | Return DllCall(JABVariables["JAB_DLLVersion"] "\isSameObject", "Int", vmID, JABVariables["acType"], ac1, JABVariables["acType"], ac2, "Cdecl Int") 637 | } 638 | else 639 | { 640 | Return 0 641 | } 642 | } 643 | 644 | ; retrieves the root element from a window 645 | GetAccessibleContextFromHWND(hwnd, ByRef vmID, ByRef ac) 646 | { 647 | global JABVariables 648 | if (JABVariables["JABInitialised"]) 649 | { 650 | Return DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleContextFromHWND", "Int", hWnd, "Int*", vmID, JABVariables["acPType"], ac, "Cdecl Int") 651 | } 652 | else 653 | { 654 | Return 0 655 | } 656 | } 657 | 658 | GetHWNDFromAccessibleContext(vmID, ac) 659 | { 660 | global JABVariables 661 | if (JABVariables["JABInitialised"]) 662 | { 663 | Return DllCall(JABVariables["JAB_DLLVersion"] "\getHWNDFromAccessibleContext", "Int", vmID, JABVariables["acType"], ac, "Cdecl UInt") 664 | } 665 | else 666 | { 667 | Return 0 668 | } 669 | } 670 | 671 | GetAccessibleContextAtHWND(hwnd, x, y) 672 | { 673 | global JABVariables 674 | if (JABVariables["JABInitialised"]) 675 | { 676 | GetAccessibleContextFromHWND(hwnd, vmID, Winac) 677 | return, FindContextAt(vmID, Winac, x, y) 678 | } 679 | else 680 | { 681 | Return 0 682 | } 683 | } 684 | 685 | FindContextAt(vmID, ac, x, y) 686 | { 687 | global JABVariables 688 | Info:=getAccessibleContextInfo(vmID,ac) 689 | If (Instr(Info["States"],"visible")) 690 | { 691 | resac:=0 692 | Loop, % Info["Children count"] 693 | { 694 | rac:=GetAccessibleChildFromContext(vmID, ac, A_Index-1) 695 | resact:=FindContextAt(vmID, rac, x, y) 696 | If (resact<>0) 697 | resac:=resact 698 | } 699 | If ((resac=0) and (x>=Info["x"]) and (x<=(Info["x"]+Info["Width"])) and (y>=Info["y"]) and (y<=(Info["y"]+Info["Height"]))) 700 | { 701 | return, ac 702 | } 703 | return, resac 704 | } 705 | else 706 | return, 0 707 | } 708 | 709 | GetAccessibleContextAt(vmID, acParent, x, y, ByRef ac) 710 | { 711 | global JABVariables 712 | if (JABVariables["JABInitialised"]) 713 | { 714 | Return DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleContextAt", "Int", vmID, JABVariables["acType"], acParent, "Int", x, "Int", y, JABVariables["acPType"], ac, "Cdecl Int") 715 | ;~ Return DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleContextAt", "Int", vmID, "Int", acParent, "Int", x, "Int", y, "Ptr", ac, "Cdecl Int") 716 | } 717 | else 718 | { 719 | Return 0 720 | } 721 | } 722 | 723 | GetAccessibleContextWithFocus(hwnd, ByRef vmID, ByRef ac) 724 | { 725 | global JABVariables 726 | if (JABVariables["JABInitialised"]) 727 | { 728 | vmid:=0 729 | ac:=0 730 | Return DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleContextWithFocus", "Int", hwnd, "Int*", vmID, JABVariables["acPType"], ac, "Cdecl Int") 731 | } 732 | else 733 | { 734 | Return 0 735 | } 736 | } 737 | 738 | GetActiveDescendent(vmID, ac) 739 | { 740 | global JABVariables 741 | if (JABVariables["JABInitialised"]) 742 | { 743 | Return DllCall(JABVariables["JAB_DLLVersion"] "\getActiveDescendent", "Int", vmID, JABVariables["acType"], ac, "Cdecl Int") 744 | } 745 | else 746 | { 747 | Return 0 748 | } 749 | } 750 | 751 | GetObjectDepth(vmID, ac) 752 | { 753 | global JABVariables 754 | depth:=0 755 | if (JABVariables["JABInitialised"]) 756 | { 757 | depth:=DllCall(JABVariables["JAB_DLLVersion"] "\getObjectDepth", "Int", vmID, JABVariables["acType"], ac, "Cdecl Int") 758 | } 759 | Return depth 760 | } 761 | 762 | GetAccessibleParentFromContext(vmID, ac) 763 | { 764 | global JABVariables 765 | acparent:=0 766 | if (JABVariables["JABInitialised"]) 767 | { 768 | acparent:=DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleParentFromContext", "Int", vmID, JABVariables["acType"], ac, "Cdecl "JABVariables["acType"]) 769 | } 770 | Return, acparent 771 | } 772 | 773 | GetTopLevelObject(vmID, ac) 774 | { 775 | global JABVariables 776 | acparent:=0 777 | if (JABVariables["JABInitialised"]) 778 | { 779 | acparent:=DllCall(JABVariables["JAB_DLLVersion"] "\getTopLevelObject", "Int", vmID, JABVariables["acType"], ac, "Cdecl "JABVariables["acType"]) 780 | } 781 | Return, acparent 782 | } 783 | 784 | GetAccessibleChildFromContext(vmID, ac, index) 785 | { 786 | global JABVariables 787 | acchild:=0 788 | if (JABVariables["JABInitialised"]) 789 | { 790 | acchild:=DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleChildFromContext", "Int", vmID, JABVariables["acType"], ac, "Int", index, "Cdecl "JABVariables["acType"]) 791 | } 792 | Return, acchild 793 | } 794 | 795 | GetParentWithRole(vmID, ac, byref role) 796 | { 797 | global JABVariables 798 | acparent:=0 799 | if (JABVariables["JABInitialised"]) 800 | { 801 | acparent:=DllCall(JABVariables["JAB_DLLVersion"] "\getParentWithRole", "Int", vmID, JABVariables["acType"], ac, "Ptr", &role, "Cdecl "JABVariables["acType"]) 802 | } 803 | Return, acparent 804 | } 805 | 806 | GetParentWithRoleElseRoot(vmID, ac, byref role) 807 | { 808 | global JABVariables 809 | acparent:=0 810 | if (JABVariables["JABInitialised"]) 811 | { 812 | acparent:=DllCall(JABVariables["JAB_DLLVersion"] "\getParentWithRoleElseRoot", "Int", vmID, JABVariables["acType"], ac, "Ptr", &role, "Cdecl "JABVariables["acType"]) 813 | } 814 | Return, acparent 815 | } 816 | 817 | ; retrieves information about a certain element as an object with the keys: 818 | ; Name, Description, Role_local, Role, States_local, States, Index in parent, 819 | ; Children count, X, Y, Width, Height, Accessible component, Accessible action, 820 | ; Accessible selection, Accessible text, Accessible value interface, 821 | ; Accessible action interface, Accessible component interface, 822 | ; Accessible selection interface, Accessible table interface, 823 | ; Accessible text interface, Accessible hypertext interface 824 | GetAccessibleContextInfo(vmID, ac) 825 | { 826 | global JABVariables 827 | TempInfo:=Object() 828 | if (JABVariables["JABInitialised"]) 829 | { 830 | VarSetCapacity(Info, 6188,0) 831 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleContextInfo", "Int", vmID, JABVariables["acType"], ac, "Ptr", &Info, "Cdecl Int")) 832 | { 833 | verstr:="" 834 | Loop, % JABVariables["MAX_STRING_SIZE"] 835 | { 836 | offset:=(A_Index-1)*2 837 | jver:=Chr(NumGet(&Info,offset,"UChar")) 838 | if (jver=Chr(0)) 839 | { 840 | break 841 | } 842 | verstr.= jver 843 | } 844 | TempInfo["Name"]:=verstr 845 | verstr:="" 846 | Loop, % JABVariables["MAX_STRING_SIZE"] 847 | { 848 | offset:=(A_Index-1)*2+JABVariables["MAX_STRING_SIZE"]*2 849 | jver:=Chr(NumGet(&Info,offset,"UChar")) 850 | if (jver=Chr(0)) 851 | { 852 | break 853 | } 854 | verstr.=jver 855 | } 856 | TempInfo["Description"]:=verstr 857 | verstr:="" 858 | Loop, % JABVariables["SHORT_STRING_SIZE"] 859 | { 860 | offset:=(A_Index-1)*2+JABVariables["MAX_STRING_SIZE"]*4 861 | jver:=Chr(NumGet(&Info,offset,"UChar")) 862 | if (jver=Chr(0)) 863 | { 864 | break 865 | } 866 | verstr:=verstr jver 867 | } 868 | TempInfo["Role_local"]:=verstr 869 | verstr:="" 870 | Loop, % JABVariables["SHORT_STRING_SIZE"] 871 | { 872 | offset:=(A_Index-1)*2+JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*2 873 | jver:=Chr(NumGet(&Info,offset,"UChar")) 874 | if (jver=Chr(0)) 875 | { 876 | break 877 | } 878 | verstr.=jver 879 | } 880 | TempInfo["Role"]:=verstr 881 | verstr:="" 882 | Loop, % JABVariables["SHORT_STRING_SIZE"] 883 | { 884 | offset:=(A_Index-1)*2+JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*4 885 | jver:=Chr(NumGet(&Info,offset,"UChar")) 886 | if (jver=Chr(0)) 887 | { 888 | break 889 | } 890 | verstr.=jver 891 | } 892 | TempInfo["States_local"]:=verstr 893 | verstr:="" 894 | Loop, % JABVariables["SHORT_STRING_SIZE"] 895 | { 896 | offset:=(A_Index-1)*2+JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*6 897 | jver:=Chr(NumGet(&Info,offset,"UChar")) 898 | if (jver=Chr(0)) 899 | { 900 | break 901 | } 902 | verstr.=jver 903 | } 904 | TempInfo["States"]:=verstr 905 | offset:=JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*8 906 | jver:=NumGet(&Info,offset,"Int") 907 | TempInfo["Index in parent"]:=jver 908 | offset:=JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*8+4 909 | jver:=NumGet(&Info,offset,"Int") 910 | TempInfo["Children count"]:=jver 911 | offset:=JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*8+8 912 | jver:=NumGet(&Info,offset,"Int") 913 | TempInfo["X"]:=jver 914 | offset:=JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*8+12 915 | jver:=NumGet(&Info,offset,"Int") 916 | TempInfo["Y"]:=jver 917 | offset:=JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*8+16 918 | jver:=NumGet(&Info,offset,"Int") 919 | TempInfo["Width"]:=jver 920 | offset:=JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*8+20 921 | jver:=NumGet(&Info,offset,"Int") 922 | TempInfo["Height"]:=jver 923 | offset:=JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*8+24 924 | jver:=NumGet(&Info,offset,"Int") 925 | TempInfo["Accessible component"]:=jver 926 | offset:=JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*8+28 927 | jver:=NumGet(&Info,offset,"Int") 928 | TempInfo["Accessible action"]:=jver 929 | offset:=JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*8+32 930 | jver:=NumGet(&Info,offset,"Int") 931 | TempInfo["Accessible selection"]:=jver 932 | offset:=JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*8+36 933 | jver:=NumGet(&Info,offset,"Int") 934 | TempInfo["Accessible text"]:=jver 935 | offset:=JABVariables["MAX_STRING_SIZE"]*4+JABVariables["SHORT_STRING_SIZE"]*8+40 936 | jver:=NumGet(&Info,offset,"Int") 937 | TempInfo["Accessible value interface"]:=jver & 1 938 | TempInfo["Accessible action interface"]:=jver & 2 939 | TempInfo["Accessible component interface"]:=jver & 4 940 | TempInfo["Accessible selection interface"]:=jver & 8 941 | TempInfo["Accessible table interface"]:=jver & 16 942 | TempInfo["Accessible text interface"]:=jver & 32 943 | TempInfo["Accessible hypertext interface"]:=jver & 64 944 | } 945 | else 946 | { 947 | msgbox, Error in GetAccessibleContextInfo vmID: %vmID% ac: %ac% 948 | } 949 | } 950 | Return TempInfo 951 | } 952 | 953 | GetVisibleChildrenCount(vmID, ac) 954 | { 955 | global JABVariables 956 | if (JABVariables["JABInitialised"]) 957 | { 958 | Return DllCall(JABVariables["JAB_DLLVersion"] "\getVisibleChildrenCount", "Int", vmID, JABVariables["acType"], ac, "Cdecl Int") 959 | } 960 | else 961 | { 962 | Return 0 963 | } 964 | } 965 | 966 | ; this function seems to be unreliable under Win7 64bit 967 | ; works fine under WinXP 968 | GetVisibleChildren(vmID, ac) 969 | { 970 | global JABVariables 971 | Children:=Object() 972 | if (JABVariables["JABInitialised"]) 973 | { 974 | NumChild:=getVisibleChildrenCount(vmID, ac) 975 | StartChild:=0 976 | cnt:=0 977 | VarSetCapacity(TempChildren, 257*JABVariables["acSize"],0) 978 | Loop 979 | { 980 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getVisibleChildren", "Int", vmID, JABVariables["acType"], ac, "Int", StartChild, "Ptr", &TempChildren, "Cdecl Int")) 981 | { 982 | retchild:=NumGet(&TempChildren,0,"Int") 983 | str:=retchild ";;" 984 | Loop, %retchild% 985 | { 986 | Children[++cnt]:=Numget(&TempChildren, JABVariables["acSize"]*(A_Index), JABVariables["acType"]) 987 | } 988 | StartChild:=StartChild+retchild 989 | } 990 | else break 991 | } Until StartChild>=NumChild 992 | } 993 | Return Children 994 | } 995 | 996 | GetAccessibleActions(vmID, ac) 997 | { 998 | global JABVariables 999 | Actret:=Object() 1000 | if (JABVariables["JABInitialised"]) 1001 | { 1002 | VarSetCapacity(Actions, 256*256*2+A_PtrSize,0) 1003 | if DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleActions", "Int", vmID, JABVariables["acType"], ac, "Ptr", &Actions, "Cdecl Int") 1004 | { 1005 | retact:=NumGet(&Actions,0,"Int") 1006 | Loop, % retact 1007 | { 1008 | verstr:="" 1009 | lind:=A_Index 1010 | Loop, % JABVariables["SHORT_STRING_SIZE"] 1011 | { 1012 | offset:=(A_Index-1)*2+JABVariables["SHORT_STRING_SIZE"]*2*(lind-1)+4 ; A_PtrSize 1013 | jver:=Chr(NumGet(&Actions,offset,"UChar")) 1014 | if (jver=Chr(0)) 1015 | { 1016 | break 1017 | } 1018 | verstr.= jver 1019 | } 1020 | Actret[A_Index]:=verstr 1021 | } 1022 | } 1023 | } 1024 | Return Actret 1025 | } 1026 | 1027 | DoAccessibleActions(vmID, ac, ByRef actionsToDo) 1028 | ; actionsToDo : comma separated list of actions 1029 | { 1030 | global JABVariables 1031 | if (JABVariables["JABInitialised"]) 1032 | { 1033 | VarSetCapacity(Actions, 256*256*2+A_PtrSize,0) 1034 | Loop, Parse, actionsToDo, `,, %A_Space% 1035 | { 1036 | NumPut(A_Index,&Actions,0,"Int") 1037 | lind:=A_Index 1038 | Loop, Parse, A_LoopField 1039 | { 1040 | offset:=(A_Index-1)*2+JABVariables["SHORT_STRING_SIZE"]*2*(lind-1)+4 ; A_PtrSize 1041 | NumPut(Asc(A_LoopField),&Actions,offset,"UChar") 1042 | } 1043 | } 1044 | failure:=0 1045 | DllCall( JABVariables["JAB_DLLVersion"] "\doAccessibleActions", "Int", vmID , JABVariables["acType"], ac , "Ptr", &Actions , "Int", failure, "Cdecl Int") 1046 | return, failure 1047 | } 1048 | } 1049 | 1050 | RequestFocus(vmID, ac) 1051 | { 1052 | global JABVariables 1053 | if (JABVariables["JABInitialised"]) 1054 | { 1055 | return DllCall(JABVariables["JAB_DLLVersion"] "\requestFocus", "Int", vmID, JABVariables["acType"], ac, "Cdecl Int") 1056 | } 1057 | } 1058 | 1059 | ; retrieves information about a certain text element as an object with the keys: 1060 | ; CharCount, CaretIndex, IndexAtPoint 1061 | GetAccessibleTextInfo(vmID, ac, x:=0, y:=0) 1062 | { 1063 | global JABVariables 1064 | TempInfo:=Object() 1065 | if (JABVariables["JABInitialised"]) 1066 | { 1067 | VarSetCapacity(Info, 12,0) 1068 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTextInfo", "Int", vmID, JABVariables["acType"], ac, "Ptr", &Info, "Int", x, "Int", y, "Cdecl Int")) 1069 | { 1070 | jver:=NumGet(&Info,0,"Int") 1071 | TempInfo["CharCount"]:=jver 1072 | jver:=NumGet(&Info,4,"Int") 1073 | TempInfo["CaretIndex"]:=jver 1074 | jver:=NumGet(&Info,8,"Int") 1075 | TempInfo["IndexAtPoint"]:=jver 1076 | } 1077 | else 1078 | { 1079 | TempInfo:= 1080 | Return, TempInfo 1081 | } 1082 | } 1083 | Return TempInfo 1084 | } 1085 | 1086 | Is64bit(vmID, ac) 1087 | { 1088 | global JABVariables 1089 | if (JABVariables["JABInitialised"]) 1090 | { 1091 | If (A_Is64bitOS) 1092 | { 1093 | ; find out if the JVM is running at 32 or 64 bit to circumvent a bug with the adress length in 32 bit JVMs (JRE 6+7) 1094 | tlo:=GetTopLevelObject(vmID, ac) 1095 | Awin:=GetHWNDFromAccessibleContext(vmID, tlo) 1096 | currwin:=WinExist("A") 1097 | WinGet, ProcID, PID, ahk_id %Awin% 1098 | phandle:=DllCall("OpenProcess", "uint", 0x1000, "uint", 0, "uint", ProcID) 1099 | isWow64process:=0 1100 | DllCall("IsWow64Process", "uint", phandle, "int*", isWow64process) 1101 | if (isWow64process) 1102 | { 1103 | Return, 0 1104 | } 1105 | else 1106 | { 1107 | Return, 1 1108 | } 1109 | } 1110 | else 1111 | { 1112 | Return, 0 1113 | } 1114 | } 1115 | Return, 0 1116 | } 1117 | 1118 | ; retrieves the currently selected text and its start and end index as an object with the keys: 1119 | ; SelectionStartIndex, SelectionEndIndex, SelectedText 1120 | GetAccessibleTextSelectionInfo(vmID, ac) 1121 | { 1122 | global JABVariables 1123 | TempInfo:=Object() 1124 | if (JABVariables["JABInitialised"]) 1125 | { 1126 | VarSetCapacity(Info, JABVariables["MAX_STRING_SIZE"]*2+8,0) 1127 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTextSelectionInfo", "Int", vmID, JABVariables["acType"], ac, "Ptr", &Info, "Cdecl Int")) 1128 | { 1129 | jver:=NumGet(&Info,0,"Int") 1130 | TempInfo["SelectionStartIndex"]:=jver 1131 | jver:=NumGet(&Info,4,"Int") 1132 | TempInfo["SelectionEndIndex"]:=jver 1133 | verstr:="" 1134 | Loop, % JABVariables["MAX_STRING_SIZE"] 1135 | { 1136 | offset:=(A_Index-1)*2+8 1137 | jver:=Chr(NumGet(&Info,offset,"UChar")) 1138 | if (jver=Chr(0)) 1139 | { 1140 | break 1141 | } 1142 | verstr.= jver 1143 | } 1144 | TempInfo["SelectedText"]:=verstr 1145 | Return, TempInfo 1146 | } 1147 | } 1148 | Return, 0 1149 | } 1150 | 1151 | SelectTextRange32(vmID, ac, startIndex, endIndex) 1152 | { 1153 | global JABVariables 1154 | if (JABVariables["JABInitialised"]) 1155 | { 1156 | ; find out if the JVM is running at 32 or 64 bit to circumvent a bug with the adress length in 32 bit JVMs (JRE 6+7) 1157 | ; this workaround seems not be necessary with JRE7update67 or later but seems to causes no trouble either 1158 | ;~ if (Is64bit(vmID, ac)) 1159 | ;~ { 1160 | ;~ msgbox, miep 1161 | ;~ Return, DllCall(JABVariables["JAB_DLLVersion"] "\selectTextRange", "Int", vmID, JABVariables["acType"], ac, "Int", startIndex, "Int", endIndex, "Cdecl Int") 1162 | ;~ } 1163 | ;~ else 1164 | ;~ { 1165 | Return, DllCall(JABVariables["JAB_DLLVersion"] "\selectTextRange", "Int", vmID, "Ptr", ac, "Int", startIndex, "Int", endIndex, "Cdecl Int") 1166 | ;~ } 1167 | } 1168 | Return, 0 1169 | } 1170 | 1171 | SetCaretPosition64(vmID, ac, position) 1172 | { 1173 | global JABVariables 1174 | if (JABVariables["JABInitialised"]) 1175 | { 1176 | ; find out if the JVM is running at 32 or 64 bit to circumvent a bug with the adress length in 32 bit JVMs (JRE 6+7) 1177 | ; this workaround seems not be necessary with JRE7update67 or later but seems to causes no trouble either 1178 | ;~ if (Is64bit(vmID, ac)) 1179 | ;~ { 1180 | Return, DllCall(JABVariables["JAB_DLLVersion"] "\setCaretPosition", "Int", vmID, JABVariables["acType"], ac, "Int", position, "Cdecl Int") 1181 | ;~ } 1182 | ;~ else 1183 | ;~ { 1184 | ;~ Return, DllCall(JABVariables["JAB_DLLVersion"] "\setCaretPosition", "Int", vmID, "Ptr", ac, "Int", position, "Cdecl Int") 1185 | ;~ } 1186 | } 1187 | Return, 0 1188 | } 1189 | 1190 | SelectTextRange64(vmID, ac, startIndex, endIndex) 1191 | { 1192 | global JABVariables 1193 | if (JABVariables["JABInitialised"]) 1194 | { 1195 | ; find out if the JVM is running at 32 or 64 bit to circumvent a bug with the adress length in 32 bit JVMs (JRE 6+7) 1196 | ; this workaround seems not be necessary with JRE7update67 or later but seems to causes no trouble either 1197 | ;~ if (Is64bit(vmID, ac)) 1198 | ;~ { 1199 | ;~ msgbox, miep 1200 | Return, DllCall(JABVariables["JAB_DLLVersion"] "\selectTextRange", "Int", vmID, JABVariables["acType"], ac, "Int", startIndex, "Int", endIndex, "Cdecl Int") 1201 | ;~ } 1202 | ;~ else 1203 | ;~ { 1204 | ;~ Return, DllCall(JABVariables["JAB_DLLVersion"] "\selectTextRange", "Int", vmID, "Ptr", ac, "Int", startIndex, "Int", endIndex, "Cdecl Int") 1205 | ;~ } 1206 | } 1207 | Return, 0 1208 | } 1209 | 1210 | SetCaretPosition32(vmID, ac, position) 1211 | { 1212 | global JABVariables 1213 | if (JABVariables["JABInitialised"]) 1214 | { 1215 | ; find out if the JVM is running at 32 or 64 bit to circumvent a bug with the adress length in 32 bit JVMs (JRE 6+7) 1216 | ; this workaround seems not be necessary with JRE7update67 or later but seems to causes no trouble either 1217 | ;~ if (Is64bit(vmID, ac)) 1218 | ;~ { 1219 | ;~ Return, DllCall(JABVariables["JAB_DLLVersion"] "\setCaretPosition", "Int", vmID, JABVariables["acType"], ac, "Int", position, "Cdecl Int") 1220 | ;~ } 1221 | ;~ else 1222 | ;~ { 1223 | Return, DllCall(JABVariables["JAB_DLLVersion"] "\setCaretPosition", "Int", vmID, "Ptr", ac, "Int", position, "Cdecl Int") 1224 | ;~ } 1225 | } 1226 | Return, 0 1227 | } 1228 | 1229 | ; retrieves the caret location as an object with the keys: 1230 | ; Index, X, Y, Width, Height 1231 | GetCaretLocation(vmID, ac) 1232 | { 1233 | global JABVariables 1234 | TempInfo:=Object() 1235 | if (JABVariables["JABInitialised"]) 1236 | { 1237 | VarSetCapacity(Info, 16,0) 1238 | Index:=0 1239 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getCaretLocation", "Int", vmID, JABVariables["acType"], ac, "Ptr", &Info, "Int", Index, "Cdecl Int")) 1240 | { 1241 | jver:=NumGet(&Info,0,"Int") 1242 | TempInfo["X"]:=jver 1243 | jver:=NumGet(&Info,4,"Int") 1244 | TempInfo["Y"]:=jver 1245 | jver:=NumGet(&Info,8,"Int") 1246 | TempInfo["Width"]:=jver 1247 | jver:=NumGet(&Info,12,"Int") 1248 | TempInfo["Height"]:=jver 1249 | TempInfo["Index"]:=Index 1250 | } 1251 | else 1252 | { 1253 | TempInfo:= 1254 | Return, TempInfo 1255 | } 1256 | } 1257 | Return TempInfo 1258 | } 1259 | 1260 | ; retrieves the location of position Index as an object with the keys: 1261 | ; X, Y, Width, Height 1262 | GetAccessibleTextRect(vmID, ac, Index) 1263 | { 1264 | global JABVariables 1265 | TempInfo:=Object() 1266 | if (JABVariables["JABInitialised"]) 1267 | { 1268 | VarSetCapacity(Info, 16,0) 1269 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTextRect", "Int", vmID, JABVariables["acType"], ac, "Ptr", &Info, "Int", Index, "Cdecl Int")) 1270 | { 1271 | jver:=NumGet(&Info,0,"Int") 1272 | TempInfo["X"]:=jver 1273 | jver:=NumGet(&Info,4,"Int") 1274 | TempInfo["Y"]:=jver 1275 | jver:=NumGet(&Info,8,"Int") 1276 | TempInfo["Width"]:=jver 1277 | jver:=NumGet(&Info,12,"Int") 1278 | TempInfo["Height"]:=jver 1279 | } 1280 | else 1281 | { 1282 | TempInfo:= 1283 | Return, TempInfo 1284 | } 1285 | } 1286 | Return TempInfo 1287 | } 1288 | 1289 | ; retrieves the start and end index of the line containing Index as an object with the keys: 1290 | ; StartPos, EndPos 1291 | GetAccessibleTextLineBounds(vmID, ac, Index) 1292 | { 1293 | global JABVariables 1294 | TempInfo:=Object() 1295 | if (JABVariables["JABInitialised"]) 1296 | { 1297 | StartPos:=0 1298 | EndPos:=0 1299 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTextLineBounds", "Int", vmID, JABVariables["acType"], ac, "Int*", &StartPos, "Int*", &EndPos, "Cdecl Int")) 1300 | { 1301 | TempInfo["StartPos"]:=StartPos 1302 | TempInfo["EndPos"]:=EndPos 1303 | } 1304 | else 1305 | { 1306 | TempInfo:= 1307 | Return, TempInfo 1308 | } 1309 | } 1310 | Return TempInfo 1311 | } 1312 | 1313 | ; retrieves text between start and end index 1314 | GetAccessibleTextRange(vmID, ac, startc:=0, endc:=0) 1315 | { 1316 | global JABVariables 1317 | TempStr:="" 1318 | if (JABVariables["JABInitialised"]) 1319 | { 1320 | maxlen:=10000 ; arbitrary value, larger values tend to fail sometimes 1321 | TInfo:=GetAccessibleTextInfo(vmID, ac) 1322 | If IsObject(TInfo) 1323 | { 1324 | If (startc<0) 1325 | { 1326 | startc:=0 1327 | } 1328 | cnt:=startc 1329 | If (endc=0 or endc>TInfo["CharCount"]) 1330 | { 1331 | endc:=TInfo["CharCount"] 1332 | } 1333 | If (endc>0) 1334 | { 1335 | Loop, 1336 | { 1337 | if (cnt+maxlen>endc) 1338 | { 1339 | cnt2:=endc-1 1340 | } 1341 | else 1342 | { 1343 | cnt2:=cnt+maxlen 1344 | } 1345 | len:=maxlen+1 1346 | VarSetCapacity(Txt, len*2,0) 1347 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTextRange", "Int", vmID, JABVariables["acType"], ac, "Int", cnt, "Int", cnt2, "Ptr", &Txt, "Int", len, "Cdecl Int")) 1348 | { 1349 | NumPut(0,Txt,(cnt2-cnt+1)*2, "UChar") 1350 | if (cnt2>cnt) and (NumGet(Txt,0,"UChar")=0) ; occasionally the first call fails at the end of the text 1351 | { 1352 | DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTextRange", "Int", vmID, JABVariables["acType"], ac, "Int", cnt, "Int", cnt2, "Ptr", &Txt, "Int", len, "Cdecl Int") 1353 | NumPut(0,Txt,(cnt2-cnt+1)*2, "UChar") 1354 | } 1355 | Loop, % maxlen+1 1356 | { 1357 | offset:=(A_Index-1)*2 1358 | jver:=Chr(NumGet(&Txt,offset,"UChar")) 1359 | if (jver=Chr(0)) 1360 | { 1361 | break 1362 | } 1363 | TempStr.=jver 1364 | } 1365 | } 1366 | if (cnt>=cnt2) 1367 | { 1368 | cnt++ 1369 | } 1370 | else 1371 | { 1372 | cnt:=cnt2+1 1373 | } 1374 | if (cnt>=endc-1) 1375 | break 1376 | } 1377 | } 1378 | } 1379 | } 1380 | Return TempStr 1381 | } 1382 | 1383 | SetTextContents(vmID, ac, ntext) ; may not work properly before JRE7 Update 67 1384 | { 1385 | global JABVariables 1386 | if (JABVariables["JABInitialised"]) 1387 | { 1388 | len := StrLen(ntext) 1389 | VarSetCapacity(TempStr, len * 2 + 2, 0) 1390 | Loop, Parse, ntext 1391 | { 1392 | offset:=(A_Index-1)*2 1393 | NumPut(Asc(A_LoopField),TempStr,offset,"UChar") 1394 | } 1395 | Return, DllCall(JABVariables["JAB_DLLVersion"] "\setTextContents", "Int", vmID, JABVariables["acType"], ac, "UInt", &TempStr, "Cdecl Int") 1396 | } 1397 | } 1398 | 1399 | ; retrieves the text attributes as an object with the keys: 1400 | ; bold, italic, underline, strikethrough, superscript, subscript, 1401 | ; backgroundColor, foregroundColor, fontFamily, fontSize, 1402 | ; alignment, bidiLevel, firstLineIndent, leftIndent, rightIndent, 1403 | ; lineSpacing, spaceAbove, spaceBelow, fullAttributesString 1404 | GetAccessibleTextAttributes(vmID, ac) 1405 | { 1406 | global JABVariables 1407 | TempInfo:=Object() 1408 | if (JABVariables["JABInitialised"]) 1409 | { 1410 | VarSetCapacity(Info, 3644,0) 1411 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTextAttributes", "Int", vmID, JABVariables["acType"], ac, "Ptr", &Info, "Cdecl Int")) 1412 | { 1413 | offset:=0 1414 | jver:=NumGet(&Info,offset,"Int") 1415 | TempInfo["bold"]:=jver 1416 | offset:=4 1417 | jver:=NumGet(&Info,offset,"Int") 1418 | TempInfo["italic"]:=jver 1419 | offset:=8 1420 | jver:=NumGet(&Info,offset,"Int") 1421 | TempInfo["underline"]:=jver 1422 | offset:=12 1423 | jver:=NumGet(&Info,offset,"Int") 1424 | TempInfo["strikethrough"]:=jver 1425 | offset:=16 1426 | jver:=NumGet(&Info,offset,"Int") 1427 | TempInfo["superscript"]:=jver 1428 | offset:=20 1429 | jver:=NumGet(&Info,offset,"Int") 1430 | TempInfo["subscript"]:=jver 1431 | verstr:="" 1432 | Loop, % JABVariables["SHORT_STRING_SIZE"] 1433 | { 1434 | offset:=(A_Index-1)*2+24 1435 | jver:=Chr(NumGet(&Info,offset,"UChar")) 1436 | if (jver=Chr(0)) 1437 | { 1438 | break 1439 | } 1440 | verstr.=jver 1441 | } 1442 | TempInfo["backgroundColor"]:=verstr 1443 | verstr:="" 1444 | Loop, % JABVariables["SHORT_STRING_SIZE"] 1445 | { 1446 | offset:=(A_Index-1)*2+24+JABVariables["SHORT_STRING_SIZE"]*2 1447 | jver:=Chr(NumGet(&Info,offset,"UChar")) 1448 | if (jver=Chr(0)) 1449 | { 1450 | break 1451 | } 1452 | verstr.=jver 1453 | } 1454 | TempInfo["foregroundColor"]:=verstr 1455 | verstr:="" 1456 | Loop, % JABVariables["SHORT_STRING_SIZE"] 1457 | { 1458 | offset:=(A_Index-1)*2+24+JABVariables["SHORT_STRING_SIZE"]*4 1459 | jver:=Chr(NumGet(&Info,offset,"UChar")) 1460 | if (jver=Chr(0)) 1461 | { 1462 | break 1463 | } 1464 | verstr.=jver 1465 | } 1466 | TempInfo["fontFamily"]:=verstr 1467 | offset:=24+JABVariables["SHORT_STRING_SIZE"]*6 1468 | jver:=NumGet(&Info,offset,"Int") 1469 | TempInfo["fontSize"]:=jver 1470 | offset:=28+JABVariables["SHORT_STRING_SIZE"]*6 1471 | jver:=NumGet(&Info,offset,"Int") 1472 | TempInfo["alignment"]:=jver 1473 | offset:=32+JABVariables["SHORT_STRING_SIZE"]*6 1474 | jver:=NumGet(&Info,offset,"Int") 1475 | TempInfo["bidiLevel"]:=jver 1476 | offset:=36+JABVariables["SHORT_STRING_SIZE"]*6 1477 | jver:=NumGet(&Info,offset,"Float") 1478 | TempInfo["firstLineIndent"]:=jver 1479 | offset:=40+JABVariables["SHORT_STRING_SIZE"]*6 1480 | jver:=NumGet(&Info,offset,"Float") 1481 | TempInfo["leftIndent"]:=jver 1482 | offset:=44+JABVariables["SHORT_STRING_SIZE"]*6 1483 | jver:=NumGet(&Info,offset,"Float") 1484 | TempInfo["rightIndent"]:=jver 1485 | offset:=48+JABVariables["SHORT_STRING_SIZE"]*6 1486 | jver:=NumGet(&Info,offset,"Float") 1487 | TempInfo["lineSpacing"]:=jver 1488 | offset:=52+JABVariables["SHORT_STRING_SIZE"]*6 1489 | jver:=NumGet(&Info,offset,"Float") 1490 | TempInfo["spaceAbove"]:=jver 1491 | offset:=56+JABVariables["SHORT_STRING_SIZE"]*6 1492 | jver:=NumGet(&Info,offset,"Float") 1493 | TempInfo["spaceBelow"]:=jver 1494 | verstr:="" 1495 | Loop, % JABVariables["MAX_STRING_SIZE"] 1496 | { 1497 | offset:=(A_Index-1)*2+60+JABVariables["SHORT_STRING_SIZE"]*6 1498 | jver:=Chr(NumGet(&Info,offset,"UChar")) 1499 | if (jver=Chr(0)) 1500 | { 1501 | break 1502 | } 1503 | verstr.= jver 1504 | } 1505 | TempInfo["fullAttributesString"]:=verstr 1506 | } 1507 | else 1508 | { 1509 | msgbox, Error in GetAccessibleTextAttributes vmID: %vmID% ac: %ac% 1510 | } 1511 | } 1512 | Return TempInfo 1513 | } 1514 | 1515 | ; retrieves the text items as an object with the keys: 1516 | ; letter, word, sentence 1517 | GetAccessibleTextItems(vmID, ac, Index) 1518 | { 1519 | global JABVariables 1520 | TempInfo:=Object() 1521 | if (JABVariables["JABInitialised"]) 1522 | { 1523 | VarSetCapacity(Info, 2562,0) 1524 | res:=DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTextItems", "Int", vmID, JABVariables["acType"], ac, "Ptr", &Info, "Int", Index, "Cdecl Int") 1525 | if (res) 1526 | { 1527 | jver:=Chr(NumGet(&Info,0,"UChar")) 1528 | TempInfo["letter"]:=jver 1529 | verstr:="" 1530 | Loop, % JABVariables["SHORT_STRING_SIZE"] 1531 | { 1532 | offset:=(A_Index-1)*2+2 1533 | jver:=Chr(NumGet(&Info,offset,"UChar")) 1534 | if (jver=Chr(0)) 1535 | { 1536 | break 1537 | } 1538 | verstr:=verstr jver 1539 | } 1540 | TempInfo["word"]:=verstr 1541 | verstr:="" 1542 | Loop, % JABVariables["MAX_STRING_SIZE"] 1543 | { 1544 | offset:=(A_Index-1)*2+2+JABVariables["SHORT_STRING_SIZE"]*2 1545 | jver:=Chr(NumGet(&Info,offset,"UChar")) 1546 | if (jver=Chr(0)) 1547 | { 1548 | break 1549 | } 1550 | verstr.= jver 1551 | } 1552 | TempInfo["sentence"]:=verstr 1553 | } 1554 | else 1555 | { 1556 | msgbox, Error in GetAccessibleTextItems vmID: %vmID% ac: %ac% 1557 | } 1558 | } 1559 | Return TempInfo 1560 | } 1561 | 1562 | ; retrieves the text attributes as an object with the keys: 1563 | ; bold, italic, underline, strikethrough, superscript, subscript, 1564 | ; backgroundColor, foregroundColor, fontFamily, fontSize, 1565 | ; alignment, bidiLevel, firstLineIndent, leftIndent, rightIndent, 1566 | ; lineSpacing, spaceAbove, spaceBelow, fullAttributesString 1567 | GetTextAttributesInRange(vmID, ac, startc:=0, endc:=0) 1568 | { 1569 | global JABVariables 1570 | TempInfo:=Object() 1571 | if (JABVariables["JABInitialised"]) 1572 | { 1573 | VarSetCapacity(Info, 3644,0) 1574 | len:=endc-startc+1 1575 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getTextAttributesInRange", "Int", vmID, JABVariables["acType"], ac, "Int", startc, "Int", endc, "Ptr", &Info, "Int", len, "Cdecl Int")) 1576 | { 1577 | offset:=0 1578 | jver:=NumGet(&Info,offset,"Int") 1579 | TempInfo["bold"]:=jver 1580 | offset:=4 1581 | jver:=NumGet(&Info,offset,"Int") 1582 | TempInfo["italic"]:=jver 1583 | offset:=8 1584 | jver:=NumGet(&Info,offset,"Int") 1585 | TempInfo["underline"]:=jver 1586 | offset:=12 1587 | jver:=NumGet(&Info,offset,"Int") 1588 | TempInfo["strikethrough"]:=jver 1589 | offset:=16 1590 | jver:=NumGet(&Info,offset,"Int") 1591 | TempInfo["superscript"]:=jver 1592 | offset:=20 1593 | jver:=NumGet(&Info,offset,"Int") 1594 | TempInfo["subscript"]:=jver 1595 | verstr:="" 1596 | Loop, % JABVariables["SHORT_STRING_SIZE"] 1597 | { 1598 | offset:=(A_Index-1)*2+24 1599 | jver:=Chr(NumGet(&Info,offset,"UChar")) 1600 | if (jver=Chr(0)) 1601 | { 1602 | break 1603 | } 1604 | verstr.=jver 1605 | } 1606 | TempInfo["backgroundColor"]:=verstr 1607 | verstr:="" 1608 | Loop, % JABVariables["SHORT_STRING_SIZE"] 1609 | { 1610 | offset:=(A_Index-1)*2+24+JABVariables["SHORT_STRING_SIZE"]*2 1611 | jver:=Chr(NumGet(&Info,offset,"UChar")) 1612 | if (jver=Chr(0)) 1613 | { 1614 | break 1615 | } 1616 | verstr.=jver 1617 | } 1618 | TempInfo["foregroundColor"]:=verstr 1619 | verstr:="" 1620 | Loop, % JABVariables["SHORT_STRING_SIZE"] 1621 | { 1622 | offset:=(A_Index-1)*2+24+JABVariables["SHORT_STRING_SIZE"]*4 1623 | jver:=Chr(NumGet(&Info,offset,"UChar")) 1624 | if (jver=Chr(0)) 1625 | { 1626 | break 1627 | } 1628 | verstr.=jver 1629 | } 1630 | TempInfo["fontFamily"]:=verstr 1631 | offset:=24+JABVariables["SHORT_STRING_SIZE"]*6 1632 | jver:=NumGet(&Info,offset,"Int") 1633 | TempInfo["fontSize"]:=jver 1634 | offset:=28+JABVariables["SHORT_STRING_SIZE"]*6 1635 | jver:=NumGet(&Info,offset,"Int") 1636 | TempInfo["alignment"]:=jver 1637 | offset:=32+JABVariables["SHORT_STRING_SIZE"]*6 1638 | jver:=NumGet(&Info,offset,"Int") 1639 | TempInfo["bidiLevel"]:=jver 1640 | offset:=36+JABVariables["SHORT_STRING_SIZE"]*6 1641 | jver:=NumGet(&Info,offset,"Float") 1642 | TempInfo["firstLineIndent"]:=jver 1643 | offset:=40+JABVariables["SHORT_STRING_SIZE"]*6 1644 | jver:=NumGet(&Info,offset,"Float") 1645 | TempInfo["leftIndent"]:=jver 1646 | offset:=44+JABVariables["SHORT_STRING_SIZE"]*6 1647 | jver:=NumGet(&Info,offset,"Float") 1648 | TempInfo["rightIndent"]:=jver 1649 | offset:=48+JABVariables["SHORT_STRING_SIZE"]*6 1650 | jver:=NumGet(&Info,offset,"Float") 1651 | TempInfo["lineSpacing"]:=jver 1652 | offset:=52+JABVariables["SHORT_STRING_SIZE"]*6 1653 | jver:=NumGet(&Info,offset,"Float") 1654 | TempInfo["spaceAbove"]:=jver 1655 | offset:=56+JABVariables["SHORT_STRING_SIZE"]*6 1656 | jver:=NumGet(&Info,offset,"Float") 1657 | TempInfo["spaceBelow"]:=jver 1658 | verstr:="" 1659 | Loop, % JABVariables["MAX_STRING_SIZE"] 1660 | { 1661 | offset:=(A_Index-1)*2+60+JABVariables["SHORT_STRING_SIZE"]*6 1662 | jver:=Chr(NumGet(&Info,offset,"UChar")) 1663 | if (jver=Chr(0)) 1664 | { 1665 | break 1666 | } 1667 | verstr.= jver 1668 | } 1669 | TempInfo["fullAttributesString"]:=verstr 1670 | } 1671 | else 1672 | { 1673 | msgbox, Error in GetTextAttributesInRange vmID: %vmID% ac: %ac% 1674 | } 1675 | } 1676 | Return TempInfo 1677 | } 1678 | 1679 | ; AccessibleTable 1680 | 1681 | ; retrieves the table information as an object with the keys: 1682 | ; caption (AccesibleContext), summary (AccesibleContext), rowCount, 1683 | ; columnCount, accessibleContext, accessibleTable 1684 | GetAccessibleTableInfo(vmID, ac) 1685 | { 1686 | global JABVariables 1687 | TempInfo:=Object() 1688 | if (JABVariables["JABInitialised"]) 1689 | { 1690 | VarSetCapacity(Info, 40,0) 1691 | len:=endc-startc+1 1692 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableInfo", "Int", vmID, JABVariables["acType"], ac, "Ptr", &Info, "Cdecl Int")) 1693 | { 1694 | offset:=0 1695 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1696 | TempInfo["caption"]:=jver 1697 | offset:=JABVariables["acSize"] 1698 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1699 | TempInfo["summary"]:=jver 1700 | offset+=JABVariables["acSize"] 1701 | jver:=NumGet(&Info,offset,"Int") 1702 | TempInfo["rowCount"]:=jver 1703 | offset+=4 1704 | jver:=NumGet(&Info,offset,"Int") 1705 | TempInfo["columnCount"]:=jver 1706 | offset+=4 1707 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1708 | TempInfo["accessibleContext"]:=jver 1709 | offset+=JABVariables["acSize"] 1710 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1711 | TempInfo["accessibleTable"]:=jver 1712 | } 1713 | else 1714 | { 1715 | msgbox, Error in GetAccessibleTableInfo vmID: %vmID% ac: %ac% 1716 | } 1717 | } 1718 | Return TempInfo 1719 | } 1720 | 1721 | ; retrieves the table cell information as an object with the keys: 1722 | ; accessibleContext, index, row, column, rowExtent, columnExtent, isSelected 1723 | GetAccessibleTableCellInfo(vmID, ac, row, column) 1724 | { 1725 | global JABVariables 1726 | TempInfo:=Object() 1727 | if (JABVariables["JABInitialised"]) 1728 | { 1729 | VarSetCapacity(Info, 28,0) 1730 | len:=endc-startc+1 1731 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableCellInfo", "Int", vmID, JABVariables["acType"], ac, "Int", row, "Int", column, "Ptr", &Info, "Cdecl Int")) 1732 | { 1733 | offset:=0 1734 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1735 | TempInfo["index"]:=jver 1736 | offset:=JABVariables["acSize"] 1737 | jver:=NumGet(&Info,offset,"Int") 1738 | TempInfo["row"]:=jver 1739 | offset+=4 1740 | jver:=NumGet(&Info,offset,"Int") 1741 | TempInfo["column"]:=jver 1742 | offset+=4 1743 | jver:=NumGet(&Info,offset,"Int") 1744 | TempInfo["rowExtent"]:=jver 1745 | offset+=4 1746 | jver:=NumGet(&Info,offset,"Int") 1747 | TempInfo["columnExtent"]:=jver 1748 | offset+=4 1749 | jver:=NumGet(&Info,offset,"Int") 1750 | TempInfo["isSelected"]:=jver 1751 | } 1752 | else 1753 | { 1754 | msgbox, Error in GetAccessibleTableCellInfo vmID: %vmID% ac: %ac% 1755 | } 1756 | } 1757 | Return TempInfo 1758 | } 1759 | 1760 | ; retrieves the table row header information as an object with the keys: 1761 | ; caption (AccesibleContext), summary (AccesibleContext), rowCount, 1762 | ; columnCount, accessibleContext, accessibleTable 1763 | GetAccessibleTableRowHeader(vmID, ac) 1764 | { 1765 | global JABVariables 1766 | TempInfo:=Object() 1767 | if (JABVariables["JABInitialised"]) 1768 | { 1769 | VarSetCapacity(Info, 40,0) 1770 | len:=endc-startc+1 1771 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableRowHeader", "Int", vmID, JABVariables["acType"], ac, "Ptr", &Info, "Cdecl Int")) 1772 | { 1773 | offset:=0 1774 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1775 | TempInfo["caption"]:=jver 1776 | offset:=JABVariables["acSize"] 1777 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1778 | TempInfo["summary"]:=jver 1779 | offset+=JABVariables["acSize"] 1780 | jver:=NumGet(&Info,offset,"Int") 1781 | TempInfo["rowCount"]:=jver 1782 | offset+=4 1783 | jver:=NumGet(&Info,offset,"Int") 1784 | TempInfo["columnCount"]:=jver 1785 | offset+=4 1786 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1787 | TempInfo["accessibleContext"]:=jver 1788 | offset+=JABVariables["acSize"] 1789 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1790 | TempInfo["accessibleTable"]:=jver 1791 | } 1792 | else 1793 | { 1794 | msgbox, Error in GetAccessibleTableRowHeader vmID: %vmID% ac: %ac% 1795 | } 1796 | } 1797 | Return TempInfo 1798 | } 1799 | 1800 | ; retrieves the table column header information as an object with the keys: 1801 | ; caption (AccesibleContext), summary (AccesibleContext), rowCount, 1802 | ; columnCount, accessibleContext, accessibleTable 1803 | GetAccessibleTableColumnHeader(vmID, ac) 1804 | { 1805 | global JABVariables 1806 | TempInfo:=Object() 1807 | if (JABVariables["JABInitialised"]) 1808 | { 1809 | VarSetCapacity(Info, 40,0) 1810 | len:=endc-startc+1 1811 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableColumnHeader", "Int", vmID, JABVariables["acType"], ac, "Ptr", &Info, "Cdecl Int")) 1812 | { 1813 | offset:=0 1814 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1815 | TempInfo["caption"]:=jver 1816 | offset:=JABVariables["acSize"] 1817 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1818 | TempInfo["summary"]:=jver 1819 | offset+=JABVariables["acSize"] 1820 | jver:=NumGet(&Info,offset,"Int") 1821 | TempInfo["rowCount"]:=jver 1822 | offset+=4 1823 | jver:=NumGet(&Info,offset,"Int") 1824 | TempInfo["columnCount"]:=jver 1825 | offset+=4 1826 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1827 | TempInfo["accessibleContext"]:=jver 1828 | offset+=JABVariables["acSize"] 1829 | jver:=NumGet(&Info,offset,JABVariables["acType"]) 1830 | TempInfo["accessibleTable"]:=jver 1831 | } 1832 | else 1833 | { 1834 | msgbox, Error in GetAccessibleTableColumnHeader vmID: %vmID% ac: %ac% 1835 | } 1836 | } 1837 | Return TempInfo 1838 | } 1839 | 1840 | GetAccessibleTableRowDescription(vmID, ac, row) 1841 | { 1842 | global JABVariables 1843 | acchild:=0 1844 | if (JABVariables["JABInitialised"]) 1845 | { 1846 | acchild:=DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableRowDescription", "Int", vmID, JABVariables["acType"], ac, "Int", row, "Cdecl "JABVariables["acType"]) 1847 | } 1848 | Return, acchild 1849 | } 1850 | 1851 | GetAccessibleTableColumnDescription(vmID, ac, column) 1852 | { 1853 | global JABVariables 1854 | acchild:=0 1855 | if (JABVariables["JABInitialised"]) 1856 | { 1857 | acchild:=DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableColumnDescription", "Int", vmID, JABVariables["acType"], ac, "Int", column, "Cdecl "JABVariables["acType"]) 1858 | } 1859 | Return, acchild 1860 | } 1861 | 1862 | GetAccessibleTableRowSelectionCount(vmID, ac) 1863 | { 1864 | global JABVariables 1865 | if (JABVariables["JABInitialised"]) 1866 | { 1867 | cnt:=DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableRowSelectionCount", "Int", vmID, JABVariables["acType"], ac, "Cdecl Int") 1868 | } 1869 | Return, cnt 1870 | } 1871 | 1872 | IsAccessibleTableRowSelected(vmID, ac, row) 1873 | { 1874 | global JABVariables 1875 | if (JABVariables["JABInitialised"]) 1876 | { 1877 | cnt:=DllCall(JABVariables["JAB_DLLVersion"] "\isAccessibleTableRowSelected", "Int", vmID, JABVariables["acType"], ac, "Int", row, "Cdecl Int") 1878 | } 1879 | Return, cnt 1880 | } 1881 | 1882 | GetAccessibleTableRowSelections(vmID, ac) 1883 | { 1884 | global JABVariables 1885 | Children:=Object() 1886 | if (JABVariables["JABInitialised"]) 1887 | { 1888 | NumChild:=GetAccessibleTableRowSelectionCount(vmID, ac) 1889 | cnt:=0 1890 | VarSetCapacity(TempChildren, 64*JABVariables["acSize"],0) 1891 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableRowSelections", "Int", vmID, JABVariables["acType"], ac, "Int", NumChild, "Ptr", &TempChildren, "Cdecl Int")) 1892 | { 1893 | retchild:=NumGet(&TempChildren,0,"Int") 1894 | str:=retchild ";;" 1895 | Loop, %retchild% 1896 | { 1897 | Children[++cnt]:=Numget(&TempChildren, JABVariables["acSize"]*(A_Index), JABVariables["acType"]) 1898 | } 1899 | } 1900 | } 1901 | Return Children 1902 | } 1903 | 1904 | GetAccessibleTableColumnSelectionCount(vmID, ac) 1905 | { 1906 | global JABVariables 1907 | if (JABVariables["JABInitialised"]) 1908 | { 1909 | cnt:=DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableColumnSelectionCount", "Int", vmID, JABVariables["acType"], ac, "Cdecl Int") 1910 | } 1911 | Return, cnt 1912 | } 1913 | 1914 | IsAccessibleTableColumnSelected(vmID, ac, row) 1915 | { 1916 | global JABVariables 1917 | if (JABVariables["JABInitialised"]) 1918 | { 1919 | cnt:=DllCall(JABVariables["JAB_DLLVersion"] "\isAccessibleTableColumnSelected", "Int", vmID, JABVariables["acType"], ac, "Int", row, "Cdecl Int") 1920 | } 1921 | Return, cnt 1922 | } 1923 | 1924 | GetAccessibleTableColumnSelections(vmID, ac) 1925 | { 1926 | global JABVariables 1927 | Children:=Object() 1928 | if (JABVariables["JABInitialised"]) 1929 | { 1930 | NumChild:=GetAccessibleTableColumnSelectionCount(vmID, ac) 1931 | VarSetCapacity(TempChildren, 64*JABVariables["acSize"],0) 1932 | if (DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableColumnSelections", "Int", vmID, JABVariables["acType"], ac, "Int", NumChild, "Ptr", &TempChildren, "Cdecl Int")) 1933 | { 1934 | retchild:=NumGet(&TempChildren,0,"Int") 1935 | str:=retchild ";;" 1936 | Loop, %retchild% 1937 | { 1938 | Children[++cnt]:=Numget(&TempChildren, JABVariables["acSize"]*(A_Index), JABVariables["acType"]) 1939 | } 1940 | } 1941 | } 1942 | Return Children 1943 | } 1944 | 1945 | GetAccessibleTableRow(vmID, ac, index) 1946 | { 1947 | global JABVariables 1948 | if (JABVariables["JABInitialised"]) 1949 | { 1950 | cnt:=DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableRow", "Int", vmID, JABVariables["acType"], ac, "Int", index, "Cdecl Int") 1951 | } 1952 | Return, cnt 1953 | } 1954 | 1955 | GetAccessibleTableColumn(vmID, ac, index) 1956 | { 1957 | global JABVariables 1958 | if (JABVariables["JABInitialised"]) 1959 | { 1960 | cnt:=DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableColumn", "Int", vmID, JABVariables["acType"], ac, "Int", index, "Cdecl Int") 1961 | } 1962 | Return, cnt 1963 | } 1964 | 1965 | GetAccessibleTableIndex(vmID, ac, row, column) 1966 | { 1967 | global JABVariables 1968 | if (JABVariables["JABInitialised"]) 1969 | { 1970 | cnt:=DllCall(JABVariables["JAB_DLLVersion"] "\getAccessibleTableIndex", "Int", vmID, JABVariables["acType"], ac, "Int", row, "Int", column, "Cdecl Int") 1971 | } 1972 | Return, cnt 1973 | } 1974 | 1975 | ; callback set routines 1976 | ; see access bridge documentation for definitions of callback funtions 1977 | ; 1978 | ; usage: 1979 | ; 1980 | ; if InitJavaAccessBridge() 1981 | ; { 1982 | ; Address := RegisterCallback("FocusGained","CDecl") 1983 | ; setFocusGainedFP(Address) 1984 | ; } 1985 | ; ... 1986 | ; Return 1987 | ; 1988 | ; FocusGained(vmID, event, source) 1989 | ; { 1990 | ; DoSomething(vmID, source) 1991 | ; ReleaseJavaObject(vmID,event) 1992 | ; ReleaseJavaObject(vmID,source) 1993 | ; } 1994 | 1995 | setFocusGainedFP(fp) 1996 | { 1997 | global JABVariables 1998 | if (JABVariables["JABInitialised"]) 1999 | { 2000 | DllCall(JABVariables["JAB_DLLVersion"] "\setFocusGainedFP", "UInt", fp, "Cdecl") 2001 | } 2002 | } 2003 | 2004 | setFocusLostFP(fp) 2005 | { 2006 | global JABVariables 2007 | if (JABVariables["JABInitialised"]) 2008 | { 2009 | DllCall(JABVariables["JAB_DLLVersion"] "\setFocusLostFP", "UInt", fp, "Cdecl") 2010 | } 2011 | } 2012 | 2013 | setJavaShutdownFP(fp) 2014 | { 2015 | global JABVariables 2016 | if (JABVariables["JABInitialised"]) 2017 | { 2018 | DllCall(JABVariables["JAB_DLLVersion"] "\setJavaShutdownFP", "UInt", fp, "Cdecl") 2019 | } 2020 | } 2021 | 2022 | setCaretUpdateFP(fp) 2023 | { 2024 | global JABVariables 2025 | if (JABVariables["JABInitialised"]) 2026 | { 2027 | DllCall(JABVariables["JAB_DLLVersion"] "\setCaretUpdateFP", "UInt", fp, "Cdecl") 2028 | } 2029 | } 2030 | 2031 | setMouseClickedFP(fp) 2032 | { 2033 | global JABVariables 2034 | if (JABVariables["JABInitialised"]) 2035 | { 2036 | DllCall(JABVariables["JAB_DLLVersion"] "\setMouseClickedFP", "UInt", fp, "Cdecl") 2037 | } 2038 | } 2039 | 2040 | setMouseEnteredFP(fp) 2041 | { 2042 | global JABVariables 2043 | if (JABVariables["JABInitialised"]) 2044 | { 2045 | DllCall(JABVariables["JAB_DLLVersion"] "\setMouseEnteredFP", "UInt", fp, "Cdecl") 2046 | } 2047 | } 2048 | 2049 | setMouseExitedFP(fp) 2050 | { 2051 | global JABVariables 2052 | if (JABVariables["JABInitialised"]) 2053 | { 2054 | DllCall(JABVariables["JAB_DLLVersion"] "\setMouseExitedFP", "UInt", fp, "Cdecl") 2055 | } 2056 | } 2057 | 2058 | setMousePressedFP(fp) 2059 | { 2060 | global JABVariables 2061 | if (JABVariables["JABInitialised"]) 2062 | { 2063 | DllCall(JABVariables["JAB_DLLVersion"] "\setMousePressedFP", "UInt", fp, "Cdecl") 2064 | } 2065 | } 2066 | 2067 | setMouseReleasedFP(fp) 2068 | { 2069 | global JABVariables 2070 | if (JABVariables["JABInitialised"]) 2071 | { 2072 | DllCall(JABVariables["JAB_DLLVersion"] "\setMouseReleasedFP", "UInt", fp, "Cdecl") 2073 | } 2074 | } 2075 | 2076 | setMenuCanceledFP(fp) 2077 | { 2078 | global JABVariables 2079 | if (JABVariables["JABInitialised"]) 2080 | { 2081 | DllCall(JABVariables["JAB_DLLVersion"] "\setMenuCanceledFP", "UInt", fp, "Cdecl") 2082 | } 2083 | } 2084 | 2085 | setMenuDeselectedFP(fp) 2086 | { 2087 | global JABVariables 2088 | if (JABVariables["JABInitialised"]) 2089 | { 2090 | DllCall(JABVariables["JAB_DLLVersion"] "\setMenuDeselectedFP", "UInt", fp, "Cdecl") 2091 | } 2092 | } 2093 | 2094 | setMenuSelectedFP(fp) 2095 | { 2096 | global JABVariables 2097 | if (JABVariables["JABInitialised"]) 2098 | { 2099 | DllCall(JABVariables["JAB_DLLVersion"] "\setMenuSelectedFP", "UInt", fp, "Cdecl") 2100 | } 2101 | } 2102 | 2103 | setPopupMenuCanceledFP(fp) 2104 | { 2105 | global JABVariables 2106 | if (JABVariables["JABInitialised"]) 2107 | { 2108 | DllCall(JABVariables["JAB_DLLVersion"] "\setPopupMenuCanceledFP", "UInt", fp, "Cdecl") 2109 | } 2110 | } 2111 | 2112 | setPopupMenuWillBecomeInvisibleFP(fp) 2113 | { 2114 | global JABVariables 2115 | if (JABVariables["JABInitialised"]) 2116 | { 2117 | DllCall(JABVariables["JAB_DLLVersion"] "\setPopupMenuWillBecomeInvisibleFP", "UInt", fp, "Cdecl") 2118 | } 2119 | } 2120 | 2121 | setPopupMenuWillBecomeVisibleFP(fp) 2122 | { 2123 | global JABVariables 2124 | if (JABVariables["JABInitialised"]) 2125 | { 2126 | DllCall(JABVariables["JAB_DLLVersion"] "\setPopupMenuWillBecomeVisibleFP", "UInt", fp, "Cdecl") 2127 | } 2128 | } 2129 | 2130 | setPropertyNameChangeFP(fp) 2131 | { 2132 | global JABVariables 2133 | if (JABVariables["JABInitialised"]) 2134 | { 2135 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertyNameChangeFP", "UInt", fp, "Cdecl") 2136 | } 2137 | } 2138 | 2139 | setPropertyDescriptionChangeFP(fp) 2140 | { 2141 | global JABVariables 2142 | if (JABVariables["JABInitialised"]) 2143 | { 2144 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertyDescriptionChangeFP", "UInt", fp, "Cdecl") 2145 | } 2146 | } 2147 | 2148 | setPropertyStateChangeFP(fp) 2149 | { 2150 | global JABVariables 2151 | if (JABVariables["JABInitialised"]) 2152 | { 2153 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertyStateChangeFP", "UInt", fp, "Cdecl") 2154 | } 2155 | } 2156 | 2157 | setPropertyValueChangeFP(fp) 2158 | { 2159 | global JABVariables 2160 | if (JABVariables["JABInitialised"]) 2161 | { 2162 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertyValueChangeFP", "UInt", fp, "Cdecl") 2163 | } 2164 | } 2165 | 2166 | setPropertySelectionChangeFP(fp) 2167 | { 2168 | global JABVariables 2169 | if (JABVariables["JABInitialised"]) 2170 | { 2171 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertySelectionChangeFP", "UInt", fp, "Cdecl") 2172 | } 2173 | } 2174 | 2175 | setPropertyTextChangeFP(fp) 2176 | { 2177 | global JABVariables 2178 | if (JABVariables["JABInitialised"]) 2179 | { 2180 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertyTextChangeFP", "UInt", fp, "Cdecl") 2181 | } 2182 | } 2183 | 2184 | setPropertyCaretChangeFP(fp) 2185 | { 2186 | global JABVariables 2187 | if (JABVariables["JABInitialised"]) 2188 | { 2189 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertyCaretChangeFP", "UInt", fp, "Cdecl") 2190 | } 2191 | } 2192 | 2193 | setPropertyVisibleDataChangeFP(fp) 2194 | { 2195 | global JABVariables 2196 | if (JABVariables["JABInitialised"]) 2197 | { 2198 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertyVisibleDataChangeFP", "UInt", fp, "Cdecl") 2199 | } 2200 | } 2201 | 2202 | setPropertyChangeFP(fp) 2203 | { 2204 | global JABVariables 2205 | if (JABVariables["JABInitialised"]) 2206 | { 2207 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertyChangeFP", "UInt", fp, "Cdecl") 2208 | } 2209 | } 2210 | 2211 | setPropertyChildChangeFP(fp) 2212 | { 2213 | global JABVariables 2214 | if (JABVariables["JABInitialised"]) 2215 | { 2216 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertyChildChangeFP", "UInt", fp, "Cdecl") 2217 | } 2218 | } 2219 | 2220 | setPropertyActiveDescendentChangeFP(fp) 2221 | { 2222 | global JABVariables 2223 | if (JABVariables["JABInitialised"]) 2224 | { 2225 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertyActiveDescendentChangeFP", "UInt", fp, "Cdecl") 2226 | } 2227 | } 2228 | 2229 | setPropertyTableModelChangeFP(fp) 2230 | { 2231 | global JABVariables 2232 | if (JABVariables["JABInitialised"]) 2233 | { 2234 | DllCall(JABVariables["JAB_DLLVersion"] "\setPropertyTableModelChangeFP", "UInt", fp, "Cdecl") 2235 | } 2236 | } 2237 | 2238 | /* 2239 | functions that have not been ported yet 2240 | 2241 | { exported user functions of the Java Access Bridge } 2242 | 2243 | 2244 | { AccessibleRelationSet } 2245 | function getAccessibleRelationSet(vmID: longint; ac: AccessibleContext; relationSetInfo: PAccessibleRelationSetInfo):JBool; 2246 | 2247 | { AccessibleHypertext } 2248 | function getAccessibleHypertext(vmID: longint; ac: AccessibleContext; hypertextInfo: PAccessibleHypertextInfo):JBool; 2249 | function activateAccessibleHyperlink(vmID: longint; ac: AccessibleContext; aH: AccessibleHyperlink):JBool; 2250 | function getAccessibleHyperlinkCount(vmID: longint; ac: AccessibleContext):Jint; 2251 | function getAccessibleHypertextExt(vmID: longint; ac: AccessibleContext; nStartIndex: jint; hypertextInfo: PAccessibleHypertextInfo):JBool; 2252 | function getAccessibleHypertextLinkIndex(vmID: longint; ah: AccessibleHypertext; nIndex: jint):jint; 2253 | function getAccessibleHyperlink(vmID: longint; ah: AccessibleHypertext; nIndex: jint; hyperlinkInfo: PAccessibleHyperlinkInfo):JBool; 2254 | 2255 | { Accessible KeyBindings, Icons and Actions } 2256 | function getAccessibleKeyBindings(vmID: longint; ac: AccessibleContext; keyBindings: PAccessibleKeyBindings):JBool; 2257 | function getAccessibleIcons(vmID: longint; ac: AccessibleContext; icons: PAccessibleIcons):JBool; 2258 | 2259 | { AccessibleText } 2260 | getCurrentAccessibleValueFromContext 2261 | getMaximumAccessibleValueFromContext 2262 | getMinimumAccessibleValueFromContext 2263 | 2264 | function GetCurrentAccessibleValueFromContext(vmID: longint; av: AccessibleValue; value: pwidechar; len: jshort):JBool; 2265 | function GetMaximumAccessibleValueFromContext(vmID: longint; av: AccessibleValue; value: pwidechar; len: jshort):JBool; 2266 | function GetMinimumAccessibleValueFromContext(vmID: longint; av: AccessibleValue; value: pwidechar; len: jshort):JBool; 2267 | 2268 | procedure AddAccessibleSelectionFromContext(vmID: longint; acsel: AccessibleSelection; i: Jint); 2269 | procedure ClearAccessibleSelectionFromContext(vmID: longint; acsel: AccessibleSelection); 2270 | function GetAccessibleSelectionFromContext(vmID: longint; acsel: AccessibleSelection; i: jint):JObject; 2271 | function GetAccessibleSelectionCountFromContext(vmID: longint; acsel: AccessibleSelection):Jint; 2272 | function IsAccessibleChildSelectedFromContext(vmID: longint; acsel: AccessibleSelection; i: Jint):Jbool; 2273 | procedure RemoveAccessibleSelectionFromContext(vmID: longint; acsel: AccessibleSelection; i: Jint); 2274 | procedure SelectAllAccessibleSelectionFromContext(vmID: longint; acsel: AccessibleSelection); 2275 | 2276 | { Utility methods } 2277 | function getVirtualAccessibleName(vmID: longint; ac: AccessibleContext; name: pwidechar; len: integer):JBool; 2278 | function getTextAttributesInRange(vmID: longint; ac: AccessibleContext; startIndex: integer; endIndex: integer; attributes: PAccessibleTextAttributesInfo; len: Jshort): JBool; 2279 | function getEventsWaiting():Jint; 2280 | 2281 | { All unported functions in Windowsaccessbridge32.dll } 2282 | activateAccessibleHyperlink 2283 | getAccessibleHyperlink 2284 | getAccessibleHyperlinkCount 2285 | getAccessibleHypertext 2286 | getAccessibleHypertextExt 2287 | getAccessibleHypertextLinkIndex 2288 | 2289 | addAccessibleSelectionFromContext 2290 | clearAccessibleSelectionFromContext 2291 | getAccessibleSelectionCountFromContext 2292 | getAccessibleSelectionFromContext 2293 | isAccessibleChildSelectedFromContext 2294 | removeAccessibleSelectionFromContex 2295 | selectAllAccessibleSelectionFromContext 2296 | 2297 | getAccessibleIcons 2298 | getAccessibleKeyBindings 2299 | getAccessibleRelationSet 2300 | getEventsWaiting 2301 | getVirtualAccessibleName 2302 | */ 2303 | -------------------------------------------------------------------------------- /JavaAccessBridge_class.ahk: -------------------------------------------------------------------------------- 1 | ; todo: 2 | 3 | ; GetCaretLocation: check if index does anything, else remove 4 | ; Getvisiblechildren test if retchild:=NumGet(&TempChildren, 0, "Int64") works under 64 bit 5 | 6 | class JavaAccessBridge extends JavaAccessBridgeBase 7 | { 8 | ; The function JavaControlDoAction searches for the -instance of a Java-control that fits in , and and performs -times 9 | ; actions can be all actions provided by the control itself or: 10 | ; - focus: attempts to focus the control and left clicks it if focusing fails 11 | ; - check pos: tries if the object has a valid screen location 12 | ; - left/double/right/middle click; wheel up/down: performs the respective mouse action in the center of the control 13 | ControlDoAction(HWND:=0, Name:="", Role:="", Description:="", Occurrence:="", Action:="", Times:=1, ParentContext:=0) 14 | { 15 | control:=this.ControlGet(HWND, Name, Role, Description, Occurrence, ParentContext) 16 | If (control>0) 17 | { 18 | Info:=control.getAccessibleContextInfo() 19 | Loop, %Times% 20 | { 21 | if (Action="check pos") 22 | { 23 | If !(Info.X=-1 and Info.Width=-1 and Info.Y=-1 and Info.Height=-1) 24 | return, 0 25 | else 26 | return, -3 27 | } 28 | if (Action="focus") 29 | { 30 | If (Instr(Info.States,"focusable")) 31 | { 32 | failure:=control.RequestFocus() 33 | if (failure<>0) 34 | { 35 | rval:=control.MouseClick() 36 | } 37 | } 38 | else 39 | return, -2 40 | } 41 | else if Action in % this.MouseClickActions 42 | { 43 | rval:=control.MouseClick(Action) 44 | } 45 | else 46 | { 47 | rval:=control.DoAccessibleActions(Action) 48 | } 49 | If (Times>A_Index) 50 | Sleep, 50 51 | } 52 | return, rval 53 | } 54 | else 55 | return control 56 | } 57 | 58 | ControlGet(HWND:=0, Name:="", Role:="", Description:="", Occurrence:="", ParentContext:=0) 59 | { 60 | root:=0 61 | If (ParentContext__Class()="JavaAccessibleContext")) 62 | { 63 | root:=ParentContext 64 | } 65 | else 66 | { 67 | if (!HWND) 68 | currwin:=this.GetJavaHWNDWithFocus() 69 | else 70 | currwin:=HWND 71 | if (this.IsJavaWindow(currwin)) 72 | { 73 | root:=this.GetAccessibleContextFromHWND(currwin) 74 | } 75 | } 76 | If (root) 77 | { 78 | If (occurrence>1) 79 | { 80 | Loop, 2 81 | { 82 | If (this.IsSameObject(this.CachedParent,root)) 83 | { 84 | Children:=this.CachedChildren 85 | } 86 | else 87 | { 88 | Children:=root.GetVisibleChildrenFromTree() 89 | this.CachedChildren:=Children 90 | this.CachedParent:=root 91 | } 92 | occurcnt:=0 93 | For index, child in Children 94 | { 95 | Info:=child.getAccessibleContextInfo() 96 | if ((Name="" or RegExMatch(Info.Name, Name)) 97 | and (Role="" or Role=Info.Role) 98 | and (Description="" or RegExMatch(Info.Description, Description))) 99 | { 100 | occurcnt++ 101 | if (Occurrence=occurcnt or Occurrence=0 or Occurrence="") 102 | { 103 | return child 104 | } 105 | } 106 | } 107 | this.CachedParent:=0 108 | } 109 | } 110 | else 111 | { 112 | retval:=root.FindVisibleChild(Name, Role, Description) 113 | if (retval) 114 | return retval 115 | else 116 | return -3 117 | } 118 | } 119 | } 120 | 121 | GetAccessibleContextAt(hwnd, x, y) 122 | { 123 | root:=this.GetAccessibleContextFromHWND(hwnd) 124 | return, this.FindContextAt(root, x, y) 125 | } 126 | 127 | ; recursion for GetAccessibleContextAt 128 | ; do not use separately 129 | FindContextAt(root, x, y) 130 | { 131 | Info:=root.getAccessibleContextInfo() 132 | If (Instr(Info.States,"visible")) 133 | { 134 | resac:=0 135 | Loop, % Info.ChildrenCount 136 | { 137 | tmpac:=root.GetAccessibleChildFromContext(A_Index-1) 138 | resrec:=this.FindContextAt(tmpac, x, y) 139 | If (resrec<>0) 140 | resac:=resrec 141 | } 142 | If ((resac=0) and (x>=Info.x) and (x<=(Info.x+Info.Width)) and (y>=Info.y) and (y<=(Info.y+Info.Height))) 143 | { 144 | return, root 145 | } 146 | else 147 | return, resac 148 | } 149 | else 150 | return, 0 151 | } 152 | 153 | ; retrieves HWND of the focused Java window or child window e. g. if embedded in a browser 154 | GetJavaHWNDWithFocus() 155 | { 156 | hwnd:=WinExist("A") 157 | if (!this.IsJavaWindow(hwnd)) 158 | { 159 | ControlGetFocus, currctrl, % "ahk_id " hwnd 160 | ControlGet, currwin2, Hwnd, , %currctrl%, % "ahk_id " hwnd 161 | if (this.IsJavaWindow(currwin2)) 162 | return, currwin2 163 | } 164 | else 165 | return, hwnd 166 | } 167 | 168 | GetTextInfo() 169 | { 170 | txt:="" 171 | currwin:=this.GetJavaHWNDWithFocus() 172 | if (currwin) 173 | { 174 | control:=this.GetAccessibleContextWithFocus(currwin) 175 | } 176 | If (control) 177 | { 178 | Info:=control.GetAccessibleContextInfo() 179 | If (Info.AccessibleTextInterface) 180 | { 181 | res:=control.GetCaretLocation() 182 | caretmx:=res.X+res.Width//2 183 | caretmy:=res.Y+res.Height//2 184 | txt.="GetCaretLocation`n" 185 | txt.="X: " res.X " Y: " res.Y " Width: " res.Width " Height: " res.Height "`n" 186 | res:=control.GetAccessibleTextInfo(caretmx, caretmy) 187 | txt.="GetAccessibleTextInfo`n" 188 | txt.="CharCount: " res.CharCount " CaretIndex: " res.CaretIndex " IndexAtPoint (mid cursor): " res.IndexAtPoint "`n" 189 | caretindex:=res.CaretIndex 190 | res:=control.GetAccessibleTextItems(caretindex) 191 | txt.="GetAccessibleTextItems`n" 192 | txt.="letter: " res.letter " word: " res.word " sentence: " res.sentence "`n" 193 | res:=control.GetAccessibleTextSelectionInfo() 194 | txt.="GetAccessibleTextSelectionInfo`n" 195 | txt.="SelectionStartIndex: " res.SelectionStartIndex " SelectionEndIndex: " res.SelectionEndIndex " SelectedText: " res.SelectedText "`n" 196 | res:=control.GetAccessibleTextRange(caretindex-5, caretindex+5) 197 | txt.="GetAccessibleTextRange`n" 198 | txt.="Text: " res "`n" 199 | res:=control.GetAccessibleTextRect(caretindex) 200 | txt.="GetAccessibleTextRect`n" 201 | txt.="X: " res.X " Y: " res.Y " Width: " res.Width " Height: " res.Height "`n" 202 | res:=control.GetAccessibleTextLineBounds(caretindex) 203 | txt.="GetAccessibleTextLineBounds`n" 204 | txt.="StartPos: " res.StartPos " EndPos: " res.EndPos "`n" 205 | 206 | ;~ ; retrieves the text attributes as an object with the keys: 207 | ;~ ; bold, italic, underline, strikethrough, superscript, subscript, 208 | ;~ ; backgroundColor, foregroundColor, fontFamily, fontSize, 209 | ;~ ; alignment, bidiLevel, firstLineIndent, leftIndent, rightIndent, 210 | ;~ ; lineSpacing, spaceAbove, spaceBelow, fullAttributesString 211 | ;~ GetAccessibleTextAttributes(vmID, ac) 212 | ;~ txt.=" : " " : " " : " "`n" 213 | ;~ ; retrieves the text attributes as an object with the keys: 214 | ;~ ; bold, italic, underline, strikethrough, superscript, subscript, 215 | ;~ ; backgroundColor, foregroundColor, fontFamily, fontSize, 216 | ;~ ; alignment, bidiLevel, firstLineIndent, leftIndent, rightIndent, 217 | ;~ ; lineSpacing, spaceAbove, spaceBelow, fullAttributesString 218 | ;~ GetTextAttributesInRange(vmID, ac, startc=0, endc=0) 219 | ;~ txt.=" : " " : " " : " "`n" 220 | 221 | } 222 | else 223 | txt:="Current accessible context does not have an accessible text interface." 224 | } 225 | else 226 | txt:="No valid accessible context with focus found." 227 | return, txt 228 | } 229 | } 230 | 231 | class JavaAccessBridgeBase 232 | { 233 | DLLVersion:="" 234 | DLLHandle:="" 235 | acType:="Int64" 236 | acPType:="Int64*" 237 | acSize:=8 238 | CachedParent:=0 239 | CachedChildren:= 240 | BlockedRoles:="panel,filler,root pane,layered pane,menu bar,tool bar,separator,split pane,viewport,scroll bar,scroll pane" 241 | HandledDefaultActions:="focus|check pos|left click|double click|right click|middle click|wheel up|wheel down" 242 | MouseClickActions:="left click,double click,right click,middle click,wheel up,wheel down" 243 | 244 | static MAX_BUFFER_SIZE:=10240 245 | static MAX_STRING_SIZE:=1024 246 | static SHORT_STRING_SIZE:=256 247 | 248 | static ACCESSIBLE_ALERT:="alert" 249 | static ACCESSIBLE_COLUMN_HEADER:="column header" 250 | static ACCESSIBLE_CANVAS:="canvas" 251 | static ACCESSIBLE_COMBO_BOX:="combo box" 252 | static ACCESSIBLE_DESKTOP_ICON:="desktop icon" 253 | static ACCESSIBLE_INTERNAL_FRAME:="internal frame" 254 | static ACCESSIBLE_DESKTOP_PANE:="desktop pane" 255 | static ACCESSIBLE_OPTION_PANE:="option pane" 256 | static ACCESSIBLE_WINDOW:="window" 257 | static ACCESSIBLE_FRAME:="frame" 258 | static ACCESSIBLE_DIALOG:="dialog" 259 | static ACCESSIBLE_COLOR_CHOOSER:="color chooser" 260 | static ACCESSIBLE_DIRECTORY_PANE:="directory pane" 261 | static ACCESSIBLE_FILE_CHOOSER:="file chooser" 262 | static ACCESSIBLE_FILLER:="filler" 263 | static ACCESSIBLE_HYPERLINK:="hyperlink" 264 | static ACCESSIBLE_ICON:="icon" 265 | static ACCESSIBLE_LABEL:="label" 266 | static ACCESSIBLE_ROOT_PANE:="root pane" 267 | static ACCESSIBLE_GLASS_PANE:="glass pane" 268 | static ACCESSIBLE_LAYERED_PANE:="layered pane" 269 | static ACCESSIBLE_LIST:="list" 270 | static ACCESSIBLE_LIST_ITEM:="list item" 271 | static ACCESSIBLE_MENU_BAR:="menu bar" 272 | static ACCESSIBLE_POPUP_MENU:="popup menu" 273 | static ACCESSIBLE_MENU:="menu" 274 | static ACCESSIBLE_MENU_ITEM:="menu item" 275 | static ACCESSIBLE_SEPARATOR:="separator" 276 | static ACCESSIBLE_PAGE_TAB_LIST:="page tab list" 277 | static ACCESSIBLE_PAGE_TAB:="page tab" 278 | static ACCESSIBLE_PANEL:="panel" 279 | static ACCESSIBLE_PROGRESS_BAR:="progress bar" 280 | static ACCESSIBLE_PASSWORD_TEXT:="password text" 281 | static ACCESSIBLE_PUSH_BUTTON:="push button" 282 | static ACCESSIBLE_TOGGLE_BUTTON:="toggle button" 283 | static ACCESSIBLE_CHECK_BOX:="check box" 284 | static ACCESSIBLE_RADIO_BUTTON:="radio button" 285 | static ACCESSIBLE_ROW_HEADER:="row header" 286 | static ACCESSIBLE_SCROLL_PANE:="scroll pane" 287 | static ACCESSIBLE_SCROLL_BAR:="scroll bar" 288 | static ACCESSIBLE_VIEWPORT:="viewport" 289 | static ACCESSIBLE_SLIDER:="slider" 290 | static ACCESSIBLE_SPLIT_PANE:="split pane" 291 | static ACCESSIBLE_TABLE:="table" 292 | static ACCESSIBLE_TEXT:="text" 293 | static ACCESSIBLE_TREE:="tree" 294 | static ACCESSIBLE_TOOL_BAR:="tool bar" 295 | static ACCESSIBLE_TOOL_TIP:="tool tip" 296 | static ACCESSIBLE_AWT_COMPONENT:="awt component" 297 | static ACCESSIBLE_SWING_COMPONENT:="swing component" 298 | static ACCESSIBLE_UNKNOWN:="unknown" 299 | static ACCESSIBLE_STATUS_BAR:="status bar" 300 | static ACCESSIBLE_DATE_EDITOR:="date editor" 301 | static ACCESSIBLE_SPIN_BOX:="spin box" 302 | static ACCESSIBLE_FONT_CHOOSER:="font chooser" 303 | static ACCESSIBLE_GROUP_BOX:="group box" 304 | static ACCESSIBLE_HEADER:="header" 305 | static ACCESSIBLE_FOOTER:="footer" 306 | static ACCESSIBLE_PARAGRAPH:="paragraph" 307 | static ACCESSIBLE_RULER:="ruler" 308 | static ACCESSIBLE_EDITBAR:="editbar" 309 | static PROGRESS_MONITOR:="progress monitor" 310 | 311 | __New(ForceLegacy:=0) 312 | { 313 | if (ForceLegacy=1) 314 | { 315 | this.DLLVersion:="WindowsAccessBridge" 316 | this.DLLHandle:=DllCall("LoadLibrary", "Str", this.DLLVersion ".dll") 317 | this.acType:="Int" 318 | this.acPType:="Int*" 319 | this.acSize:=4 320 | } 321 | else 322 | if (A_PtrSize=8) 323 | { 324 | this.DLLVersion:="WindowsAccessBridge-64" 325 | this.DLLHandle:=DllCall("LoadLibrary", "Str", this.DLLVersion ".dll") 326 | } 327 | else 328 | { 329 | this.DLLVersion:="WindowsAccessBridge-32" 330 | this.DLLHandle:=DllCall("LoadLibrary", "Str", this.DLLVersion ".dll") 331 | if (this.DLLHandle=0) 332 | { 333 | this.DLLVersion:="WindowsAccessBridge" 334 | this.DLLHandle:=DllCall("LoadLibrary", "Str", this.DLLVersion ".dll") 335 | this.acType:="Int" 336 | this.acPType:="Int*" 337 | this.acSize:=4 338 | } 339 | } 340 | ; it is necessary to preload the DLL 341 | ; otherwise none of the calls suceed 342 | 343 | ; start up the access bridge 344 | If (!DllCall(this.DLLVersion "\Windows_run", "Cdecl Int")) 345 | { 346 | ; Initialisation failed. Clean up. 347 | DllCall("FreeLibrary", "Ptr", this.DLLHandle) 348 | Return, 0 349 | } 350 | ; it is necessary to give the application a few message cycles time before calling access bridge function 351 | ; otherwise all calls will fail 352 | Sleep, 200 ; minimum 100 for all machines? 353 | } 354 | 355 | __Delete() 356 | { 357 | if (this.Initialised) 358 | { 359 | DllCall("FreeLibrary", "Ptr", this.DLLHandle) 360 | } 361 | } 362 | 363 | ; retrieves the root element from a window 364 | GetAccessibleContextFromHWND(hwnd) 365 | { 366 | vmID:=0 367 | ac:=0 368 | If (DllCall(this.DLLVersion "\getAccessibleContextFromHWND", "Int", hWnd, "Int*", vmID, this.acPType, ac, "Cdecl Int")) 369 | { 370 | return new JavaAccessibleContext(vmID,ac,this) 371 | } 372 | else 373 | return 0 374 | } 375 | 376 | GetAccessibleContextWithFocus(hwnd) 377 | { 378 | vmID:=0 379 | ac:=0 380 | If (DllCall(this.DLLVersion "\getAccessibleContextWithFocus", "Int", hwnd, "Int*", vmID, this.acPType, ac, "Cdecl Int")) 381 | { 382 | return new JavaAccessibleContext(vmID, ac, this) 383 | } 384 | else 385 | return 0 386 | } 387 | 388 | ; returns JAB version information as object containing the keys: 389 | ; VMversion, bridgeJavaClassVersion, bridgeJavaDLLVersion, bridgeWinDLLVersion 390 | GetVersionInfo(vmID) 391 | { 392 | VarSetCapacity(Info, 2048,0) 393 | if (DllCall(this.DLLVersion "\getVersionInfo", "Int", vmID, "UInt", &Info, "Cdecl Int")) 394 | { 395 | TempInfo:=Object() 396 | Offset:=0 397 | TempInfo["VMversion"]:=GetJavaString(Info, Offset, this.SHORT_STRING_SIZE) 398 | TempInfo["bridgeJavaClassVersion"]:=GetJavaString(Info, Offset, this.SHORT_STRING_SIZE) 399 | TempInfo["bridgeJavaDLLVersion"]:=GetJavaString(Info, Offset, this.SHORT_STRING_SIZE) 400 | TempInfo["bridgeWinDLLVersion"]:=GetJavaString(Info, Offset, this.SHORT_STRING_SIZE) 401 | return TempInfo 402 | } 403 | else 404 | return 0 405 | } 406 | 407 | IsJavaWindow(hwnd) 408 | { 409 | return DllCall(this.DLLVersion "\isJavaWindow", "Int", hWnd, "Cdecl Int") 410 | } 411 | 412 | IsSameObject(JAObj1, JAObj2) 413 | { 414 | If (JAObj1.__Class="JavaAccessibleContext" and JAObj2.__Class="JavaAccessibleContext" and JAObj1.vmID=JAObj2.vmID) 415 | { 416 | Return DllCall(this.DLLVersion "\isSameObject", "Int", JAObj1.vmID, this.acType, JAObj1.ac, this.acType, JAObj2.ac, "Cdecl Int") 417 | } 418 | else 419 | return 0 420 | } 421 | 422 | ; callback set routines 423 | ; see access bridge documentation for definitions of callback funtions 424 | ; 425 | ; usage: 426 | ; 427 | ; if InitJavaAccessBridge() 428 | ; { 429 | ; Address := RegisterCallback("FocusGained","CDecl") 430 | ; setFocusGainedFP(Address) 431 | ; } 432 | ; ... 433 | ; Return 434 | ; 435 | ; FocusGained(vmID, event, source) 436 | ; { 437 | ; DoSomething(vmID, source) 438 | ; ReleaseJavaObject(vmID,event) 439 | ; ReleaseJavaObject(vmID,source) 440 | ; } 441 | 442 | setFocusGainedFP(fp) 443 | { 444 | DllCall(this.DLLVersion "\setFocusGainedFP", "UInt", fp, "Cdecl") 445 | } 446 | 447 | setFocusLostFP(fp) 448 | { 449 | DllCall(this.DLLVersion "\setFocusLostFP", "UInt", fp, "Cdecl") 450 | } 451 | 452 | setJavaShutdownFP(fp) 453 | { 454 | DllCall(this.DLLVersion "\setJavaShutdownFP", "UInt", fp, "Cdecl") 455 | } 456 | 457 | setCaretUpdateFP(fp) 458 | { 459 | DllCall(this.DLLVersion "\setCaretUpdateFP", "UInt", fp, "Cdecl") 460 | } 461 | 462 | setMouseClickedFP(fp) 463 | { 464 | DllCall(this.DLLVersion "\setMouseClickedFP", "UInt", fp, "Cdecl") 465 | } 466 | 467 | setMouseEnteredFP(fp) 468 | { 469 | DllCall(this.DLLVersion "\setMouseEnteredFP", "UInt", fp, "Cdecl") 470 | } 471 | 472 | setMouseExitedFP(fp) 473 | { 474 | DllCall(this.DLLVersion "\setMouseExitedFP", "UInt", fp, "Cdecl") 475 | } 476 | 477 | setMousePressedFP(fp) 478 | { 479 | DllCall(this.DLLVersion "\setMousePressedFP", "UInt", fp, "Cdecl") 480 | } 481 | 482 | setMouseReleasedFP(fp) 483 | { 484 | DllCall(this.DLLVersion "\setMouseReleasedFP", "UInt", fp, "Cdecl") 485 | } 486 | 487 | setMenuCanceledFP(fp) 488 | { 489 | DllCall(this.DLLVersion "\setMenuCanceledFP", "UInt", fp, "Cdecl") 490 | } 491 | 492 | setMenuDeselectedFP(fp) 493 | { 494 | DllCall(this.DLLVersion "\setMenuDeselectedFP", "UInt", fp, "Cdecl") 495 | } 496 | 497 | setMenuSelectedFP(fp) 498 | { 499 | DllCall(this.DLLVersion "\setMenuSelectedFP", "UInt", fp, "Cdecl") 500 | } 501 | 502 | setPopupMenuCanceledFP(fp) 503 | { 504 | DllCall(this.DLLVersion "\setPopupMenuCanceledFP", "UInt", fp, "Cdecl") 505 | } 506 | 507 | setPopupMenuWillBecomeInvisibleFP(fp) 508 | { 509 | DllCall(this.DLLVersion "\setPopupMenuWillBecomeInvisibleFP", "UInt", fp, "Cdecl") 510 | } 511 | 512 | setPopupMenuWillBecomeVisibleFP(fp) 513 | { 514 | DllCall(this.DLLVersion "\setPopupMenuWillBecomeVisibleFP", "UInt", fp, "Cdecl") 515 | } 516 | 517 | setPropertyNameChangeFP(fp) 518 | { 519 | DllCall(this.DLLVersion "\setPropertyNameChangeFP", "UInt", fp, "Cdecl") 520 | } 521 | 522 | setPropertyDescriptionChangeFP(fp) 523 | { 524 | DllCall(this.DLLVersion "\setPropertyDescriptionChangeFP", "UInt", fp, "Cdecl") 525 | } 526 | 527 | setPropertyStateChangeFP(fp) 528 | { 529 | DllCall(this.DLLVersion "\setPropertyStateChangeFP", "UInt", fp, "Cdecl") 530 | } 531 | 532 | setPropertyValueChangeFP(fp) 533 | { 534 | DllCall(this.DLLVersion "\setPropertyValueChangeFP", "UInt", fp, "Cdecl") 535 | } 536 | 537 | setPropertySelectionChangeFP(fp) 538 | { 539 | DllCall(this.DLLVersion "\setPropertySelectionChangeFP", "UInt", fp, "Cdecl") 540 | } 541 | 542 | setPropertyTextChangeFP(fp) 543 | { 544 | DllCall(this.DLLVersion "\setPropertyTextChangeFP", "UInt", fp, "Cdecl") 545 | } 546 | 547 | setPropertyCaretChangeFP(fp) 548 | { 549 | DllCall(this.DLLVersion "\setPropertyCaretChangeFP", "UInt", fp, "Cdecl") 550 | } 551 | 552 | setPropertyVisibleDataChangeFP(fp) 553 | { 554 | DllCall(this.DLLVersion "\setPropertyVisibleDataChangeFP", "UInt", fp, "Cdecl") 555 | } 556 | 557 | setPropertyChangeFP(fp) 558 | { 559 | DllCall(this.DLLVersion "\setPropertyChangeFP", "UInt", fp, "Cdecl") 560 | } 561 | 562 | setPropertyChildChangeFP(fp) 563 | { 564 | DllCall(this.DLLVersion "\setPropertyChildChangeFP", "UInt", fp, "Cdecl") 565 | } 566 | 567 | setPropertyActiveDescendentChangeFP(fp) 568 | { 569 | DllCall(this.DLLVersion "\setPropertyActiveDescendentChangeFP", "UInt", fp, "Cdecl") 570 | } 571 | 572 | setPropertyTableModelChangeFP(fp) 573 | { 574 | DllCall(this.DLLVersion "\setPropertyTableModelChangeFP", "UInt", fp, "Cdecl") 575 | } 576 | } 577 | 578 | class JavaAccessibleContext 579 | { 580 | vmID:=0 581 | ac:=0 582 | JAB:="" 583 | 584 | __New(vmID, ac, JAB) 585 | { 586 | If (vmID and ac and IsObject(JAB)) 587 | { 588 | this.vmID:=vmID 589 | this.ac:=ac 590 | this.JAB:=JAB 591 | } 592 | else 593 | return, 0 594 | } 595 | 596 | __Delete() 597 | { 598 | DllCall(this.JAB.DLLVersion "\ReleaseJavaObject", "Int", this.vmID, this.JAB.acType, this.ac, "Cdecl") 599 | } 600 | 601 | GetVisibleChild(Name:="", Role:="", Description:="") 602 | { 603 | retval:=0 604 | Info:=this.GetAccessibleContextInfo() 605 | If (Instr(Info.States,"visible")) 606 | { 607 | if ((Name="" or RegExMatch(Info.Name,Name)) 608 | and (Role="" or Role=Info.Role) 609 | and (Description="" or RegExMatch(Info.Description,Description))) 610 | { 611 | retval:=new JavaAccessibleContext(this.vmID, this.ac, this.JAB) 612 | } 613 | if (!retval) 614 | { 615 | Loop, % Info.ChildrenCount 616 | { 617 | retval:=this.GetAccessibleChildFromContext(A_Index-1).GetVisibleChild(Name, Role, Description) 618 | if (retval) 619 | break 620 | } 621 | } 622 | } 623 | return, retval 624 | } 625 | 626 | ; retrieves an object with all children of the input control 627 | GetAllChildrenFromTree() 628 | { 629 | Children:=Object() 630 | this.RecurseAllChildren(Children) 631 | return, Children 632 | } 633 | 634 | ; recursion for RecurseAllChildren 635 | ; do not use separately 636 | RecurseAllChildren(Children) 637 | { 638 | Info:=this.GetAccessibleContextInfo() 639 | Children.Push(new JavaAccessibleContext(this.vmID, this.ac, this.JAB)) 640 | Loop, % Info.ChildrenCount 641 | { 642 | this.GetAccessibleChildFromContext(A_Index-1).RecurseAllChildren(Children) 643 | } 644 | } 645 | 646 | ; used to retrieve an object with all visible children of the input control 647 | GetVisibleChildrenFromTree() 648 | { 649 | Children:=Object() 650 | this.RecurseVisibleChildren(Children) 651 | return, Children 652 | } 653 | 654 | ; recursion for RecurseControllableChildren 655 | ; do not use separately 656 | RecurseVisibleChildren(Children) 657 | { 658 | Info:=this.GetAccessibleContextInfo() 659 | If (Instr(Info.States,"visible")) 660 | { 661 | Children.Push(new JavaAccessibleContext(this.vmID, this.ac, this.JAB)) 662 | Loop, % Info.ChildrenCount 663 | { 664 | this.GetAccessibleChildFromContext(A_Index-1).RecurseVisibleChildren(Children) 665 | } 666 | } 667 | } 668 | 669 | ; used to retrieve an object with all children that are likely to be controlled 670 | GetControllableChildrenFromTree() 671 | { 672 | Children:=Object() 673 | this.RecurseControllableChildren(Children) 674 | return, Children 675 | } 676 | 677 | ; recursion for RecurseControllableChildren 678 | ; do not use separately 679 | RecurseControllableChildren(Children) 680 | { 681 | Info:=this.GetAccessibleContextInfo() 682 | If (Instr(Info.States,"visible")) 683 | { 684 | blockedroles:=this.JAB.BlockedRoles 685 | role:=Info.Role 686 | If role not in %blockedroles% 687 | Children.Push(new JavaAccessibleContext(this.vmID, this.ac, this.JAB)) 688 | Loop, % Info.ChildrenCount 689 | { 690 | this.GetAccessibleChildFromContext(A_Index-1).RecurseControllableChildren(Children) 691 | } 692 | } 693 | } 694 | 695 | GetControlTree(Invisible:=0) 696 | { 697 | RetObj:=Object() 698 | Info:=this.GetAccessibleContextInfo() 699 | If (Instr(Info.States,"visible") or Invisible) 700 | { 701 | RetObj.AC:=new JavaAccessibleContext(this.vmID, this.ac, this.JAB) 702 | RetObj.Children:=Object() 703 | Loop, % Info.ChildrenCount 704 | { 705 | rac:=this.GetAccessibleChildFromContext(A_Index-1) 706 | RetObj.Children[A_Index-1]:=rac.GetControlTree(Invisible) 707 | } 708 | } 709 | return, RetObj 710 | } 711 | 712 | ; performs mouse clicks in the center of the specified control 713 | MouseClick(action:="left", count:=1) 714 | { 715 | Info:=this.GetAccessibleContextInfo() 716 | If !(Info["X"]=-1 and Info["Width"]=-1 and Info["Y"]=-1 and Info["Height"]=-1) 717 | { 718 | xp:=Floor(Info["X"]+Info["Width"]/2) 719 | yp:=Floor(Info["Y"]+Info["Height"]/2) 720 | CoordMode, Mouse, Screen 721 | SetMouseDelay, 0 722 | SetDefaultMouseSpeed, 0 723 | BlockInput On 724 | MouseGetPos, MouseX, MouseY 725 | MouseClick, %action%, %xp%, %yp%, %count% 726 | If (action<>"right") 727 | { 728 | sleep, 100 729 | MouseMove, %MouseX%, %MouseY% 730 | } 731 | BlockInput Off 732 | return, 0 733 | } 734 | 735 | ; actionsToDo : object (1,"Action") of actions 736 | DoAccessibleActions(actionsToDo) 737 | { 738 | VarSetCapacity(Actions, 256*256*2+A_PtrSize,0) 739 | for index, action in actionsToDo 740 | { 741 | NumPut(A_Index,&Actions,0,"Int") 742 | lind:=A_Index 743 | Loop, Parse, action 744 | { 745 | offset:=(A_Index-1)*2+this.SHORT_STRING_SIZE*2*(lind-1)+A_PtrSize 746 | NumPut(Asc(A_LoopField),&Actions,offset,"UChar") 747 | } 748 | failure:=0 749 | DllCall(this.JAB.DLLVersion "\doAccessibleActions", "Int", this.vmID , this.JAB.acType, this.ac , "Ptr", &Actions , "Int", failure, "Cdecl Int") 750 | } 751 | return, failure 752 | } 753 | 754 | GetAccessibleActions() 755 | { 756 | VarSetCapacity(Actions, 256*256*2+A_PtrSize,0) 757 | if DllCall(this.JAB.DLLVersion "\getAccessibleActions", "Int", this.vmID, this.JAB.acType, this.ac, "Ptr", &Actions, "Cdecl Int") 758 | { 759 | Actret:=Object() 760 | retact:=NumGet(&Actions,0,"Int") 761 | Offset:=A_PtrSize 762 | Loop, % retact 763 | { 764 | Actret[A_Index]:=GetJavaString(Actions, Offset, this.JAB.SHORT_STRING_SIZE) 765 | } 766 | return Actret 767 | } 768 | else 769 | return 0 770 | } 771 | 772 | ; index is 0 based 773 | GetAccessibleChildFromContext(index) 774 | { 775 | ac:=DllCall(this.JAB.DLLVersion "\getAccessibleChildFromContext", "Int", this.vmID, this.JAB.acType, ac, "Int", index, "Cdecl " this.JAB.acType) 776 | If (ac) 777 | return new JavaAccessibleContext(this.vmID,ac,this.JAB) 778 | else 779 | return 0 780 | } 781 | 782 | ; retieves child context at coordinates x, y within the parent context 783 | ; Is not always reliable. Better use: JavaAccessBridge.GetAccessibleContextAt 784 | GetAccessibleContextAt(x, y) 785 | { 786 | ac:=0 787 | If DllCall(this.JAB.DLLVersion "\getAccessibleContextAt", "Int", this.vmID, this.JAB.acType, this.ac, "Int", x, "Int", y, this.JAB.acPType, ac, "Cdecl Int") 788 | return new JavaAccessibleContext(this.vmID,ac,this.JAB) 789 | else 790 | return 0 791 | } 792 | 793 | ; retrieves information about a certain element as an object with the keys: 794 | ; Name, Description, Role_local, Role, States_local, States, IndexInParent, 795 | ; ChildrenCount, X, Y, Width, Height, AccessibleComponent, AccessibleAction, 796 | ; AccessibleSelection, AccessibleText, AccessibleValueInterface, 797 | ; AccessibleActionInterface, AccessibleComponentInterface, 798 | ; AccessibleSelectionInterface, AccessibleTableInterface, 799 | ; AccessibleTextInterface, AccessibleHypertextInterface 800 | GetAccessibleContextInfo() 801 | { 802 | VarSetCapacity(Info, 6188,0) 803 | if (DllCall(this.JAB.DLLVersion "\getAccessibleContextInfo", "Int", this.vmID, this.JAB.acType, this.ac, "Ptr", &Info, "Cdecl Int")) 804 | { 805 | TempInfo:=Object() 806 | Offset:=0 807 | TempInfo["Name"]:=GetJavaString(Info, Offset, this.JAB.MAX_STRING_SIZE) 808 | TempInfo["Description"]:=GetJavaString(Info, Offset, this.JAB.MAX_STRING_SIZE) 809 | TempInfo["Role_local"]:=GetJavaString(Info, Offset, this.JAB.SHORT_STRING_SIZE) 810 | TempInfo["Role"]:=GetJavaString(Info, Offset, this.JAB.SHORT_STRING_SIZE) 811 | TempInfo["States_local"]:=GetJavaString(Info, Offset, this.JAB.SHORT_STRING_SIZE) 812 | TempInfo["States"]:=GetJavaString(Info, Offset, this.JAB.SHORT_STRING_SIZE) 813 | TempInfo["IndexInParent"]:=NumGet(&Info,Offset,"Int") 814 | Offset+=4 815 | TempInfo["ChildrenCount"]:=NumGet(&Info,Offset,"Int") 816 | Offset+=4 817 | TempInfo["X"]:=NumGet(&Info,Offset,"Int") 818 | Offset+=4 819 | TempInfo["Y"]:=NumGet(&Info,Offset,"Int") 820 | Offset+=4 821 | TempInfo["Width"]:=NumGet(&Info,Offset,"Int") 822 | Offset+=4 823 | TempInfo["Height"]:=NumGet(&Info,Offset,"Int") 824 | Offset+=4 825 | TempInfo["AccessibleComponent"]:=NumGet(&Info,Offset,"Int") 826 | Offset+=4 827 | TempInfo["AccessibleAction"]:=NumGet(&Info,Offset,"Int") 828 | Offset+=4 829 | TempInfo["AccessibleSelection"]:=NumGet(&Info,Offset,"Int") 830 | Offset+=4 831 | TempInfo["AccessibleText"]:=NumGet(&Info,Offset,"Int") 832 | Offset+=4 833 | tmp:=NumGet(&Info,Offset,"Int") 834 | TempInfo["AccessibleValueInterface"]:=tmp & 1 835 | TempInfo["AccessibleActionInterface"]:=tmp & 2 836 | TempInfo["AccessibleComponentInterface"]:=tmp & 4 837 | TempInfo["AccessibleSelectionInterface"]:=tmp & 8 838 | TempInfo["AccessibleTableInterface"]:=tmp & 16 839 | TempInfo["AccessibleTextInterface"]:=tmp & 32 840 | TempInfo["AccessibleHypertextInterface"]:=tmp & 64 841 | return TempInfo 842 | } 843 | else 844 | return 0 845 | } 846 | 847 | GetAccessibleParentFromContext() 848 | { 849 | ac:=DllCall(this.JAB.DLLVersion "\getAccessibleParentFromContext", "Int", this.vmID, this.JAB.acType, this.ac, "Cdecl "this.JAB.acType) 850 | If (ac) 851 | return new JavaAccessibleContext(this.vmID,ac,this.JAB) 852 | else 853 | return 0 854 | } 855 | 856 | ; retrieves the text items as an object with the keys: 857 | ; letter, word, sentence 858 | GetAccessibleTextItems(Index) 859 | { 860 | VarSetCapacity(Info, 2562,0) 861 | If (DllCall(this.JAB.DLLVersion "\getAccessibleTextItems", "Int", this.vmID, this.JAB.acType, this.ac, "Ptr", &Info, "Int", Index, "Cdecl Int")) 862 | { 863 | TempInfo:=Object() 864 | TempInfo["letter"]:=Chr(NumGet(&Info,0,"UChar")) 865 | Offset:=2 866 | TempInfo["word"]:=GetJavaString(Info, Offset, this.JAB.SHORT_STRING_SIZE) 867 | TempInfo["sentence"]:=GetJavaString(Info, Offset, this.JAB.MAX_STRING_SIZE) 868 | return TempInfo 869 | } 870 | else 871 | return 0 872 | } 873 | 874 | ; retrieves the text attributes as an object with the keys: 875 | ; bold, italic, underline, strikethrough, superscript, subscript, 876 | ; backgroundColor, foregroundColor, fontFamily, fontSize, 877 | ; alignment, bidiLevel, firstLineIndent, leftIndent, rightIndent, 878 | ; lineSpacing, spaceAbove, spaceBelow, fullAttributesString 879 | GetAccessibleTextAttributes() 880 | { 881 | VarSetCapacity(Info, 3644,0) 882 | if (DllCall(this.JAB.DLLVersion "\getAccessibleTextAttributes", "Int", this.vmID, this.JAB.acType, this.ac, "Ptr", &Info, "Cdecl Int")) 883 | { 884 | TempInfo:=Object() 885 | Offset:=0 886 | TempInfo["bold"]:=NumGet(&Info, Offset, "Int") 887 | Offset+=4 888 | TempInfo["italic"]:=NumGet(&Info, Offset, "Int") 889 | Offset+=4 890 | TempInfo["underline"]:=NumGet(&Info, Offset, "Int") 891 | Offset+=4 892 | TempInfo["strikethrough"]:=NumGet(&Info, Offset, "Int") 893 | Offset+=4 894 | TempInfo["superscript"]:=NumGet(&Info, Offset, "Int") 895 | Offset+=4 896 | TempInfo["subscript"]:=NumGet(&Info, Offset, "Int") 897 | Offset+=4 898 | TempInfo["backgroundColor"]:=GetJavaString(Info, Offset, this.JAB.SHORT_STRING_SIZE) 899 | TempInfo["foregroundColor"]:=GetJavaString(Info, Offset, this.JAB.SHORT_STRING_SIZE) 900 | TempInfo["fontFamily"]:=GetJavaString(Info, Offset, this.JAB.SHORT_STRING_SIZE) 901 | TempInfo["fontSize"]:=NumGet(&Info, Offset, "Int") 902 | Offset+=4 903 | TempInfo["alignment"]:=NumGet(&Info, Offset, "Int") 904 | Offset+=4 905 | TempInfo["bidiLevel"]:=NumGet(&Info, Offset, "Int") 906 | Offset+=4 907 | TempInfo["firstLineIndent"]:=NumGet(&Info, Offset, "Float") 908 | Offset+=4 909 | TempInfo["leftIndent"]:=NumGet(&Info, Offset, "Float") 910 | Offset+=4 911 | TempInfo["rightIndent"]:=NumGet(&Info, Offset, "Float") 912 | Offset+=4 913 | TempInfo["lineSpacing"]:=NumGet(&Info, Offset, "Float") 914 | Offset+=4 915 | TempInfo["spaceAbove"]:=NumGet(&Info, Offset, "Float") 916 | Offset+=4 917 | TempInfo["spaceBelow"]:=NumGet(&Info, Offset, "Float") 918 | Offset+=4 919 | TempInfo["fullAttributesString"]:=GetJavaString(Info, Offset, this.JAB.MAX_STRING_SIZE) 920 | return TempInfo 921 | } 922 | else 923 | return 0 924 | } 925 | 926 | ; retrieves information about a certain text element as an object with the keys: 927 | ; CharCount, CaretIndex, IndexAtPoint 928 | GetAccessibleTextInfo(x:=0, y:=0) 929 | { 930 | VarSetCapacity(Info, 12,0) 931 | if (DllCall(this.JAB.DLLVersion "\getAccessibleTextInfo", "Int", this.vmID, this.JAB.acType, this.ac, "Ptr", &Info, "Int", x, "Int", y, "Cdecl Int")) 932 | { 933 | TempInfo:=Object() 934 | TempInfo["CharCount"]:=NumGet(&Info, 0, "Int") 935 | TempInfo["CaretIndex"]:=NumGet(&Info, 4, "Int") 936 | TempInfo["IndexAtPoint"]:=NumGet(&Info, 8, "Int") 937 | return TempInfo 938 | } 939 | else 940 | return 0 941 | } 942 | 943 | ; retrieves the start and end index of the line containing Index as an object with the keys: 944 | ; StartPos, EndPos 945 | GetAccessibleTextLineBounds(Index) 946 | { 947 | StartPos:=0 948 | EndPos:=0 949 | if (DllCall(this.JAB.DLLVersion "\getAccessibleTextLineBounds", "Int", this.vmID, this.JAB.acType, this.ac, "Int*", &StartPos, "Int*", &EndPos, "Cdecl Int")) 950 | { 951 | TempInfo:=Object() 952 | TempInfo["StartPos"]:=StartPos 953 | TempInfo["EndPos"]:=EndPos 954 | return TempInfo 955 | } 956 | else 957 | return 0 958 | } 959 | 960 | ; retrieves text between start and end index 961 | GetAccessibleTextRange(startc:=0, endc:=0) 962 | { 963 | TInfo:=this.GetAccessibleTextInfo() 964 | If IsObject(TInfo) 965 | { 966 | TempStr:="" 967 | maxlen:=10000 ; arbitrary value, larger values tend to fail sometimes 968 | If (startc<0) 969 | { 970 | startc:=0 971 | } 972 | cnt:=startc 973 | If (endc=0 or endc>TInfo.CharCount) 974 | { 975 | endc:=TInfo.CharCount 976 | } 977 | If (endc>0) 978 | { 979 | Loop, 980 | { 981 | if (cnt+maxlen>endc) 982 | cnt2:=endc-1 983 | else 984 | cnt2:=cnt+maxlen 985 | len:=maxlen+1 986 | VarSetCapacity(Txt, len*2,0) 987 | if (DllCall(this.JAB.DLLVersion "\getAccessibleTextRange", "Int", this.vmID, this.JAB.acType, this.ac, "Int", cnt, "Int", cnt2, "Ptr", &Txt, "Int", len, "Cdecl Int")) 988 | { 989 | NumPut(0,Txt,(cnt2-cnt+1)*2, "UChar") 990 | if (cnt2>cnt) and (NumGet(Txt,0,"UChar")=0) ; occasionally the first call fails at the end of the text 991 | { 992 | DllCall(this.JAB.DLLVersion "\getAccessibleTextRange", "Int", this.vmID, this.JAB.acType, this.ac, "Int", cnt, "Int", cnt2, "Ptr", &Txt, "Int", len, "Cdecl Int") 993 | NumPut(0,Txt,(cnt2-cnt+1)*2, "UChar") 994 | } 995 | Offset:=0 996 | TempStr.=GetJavaString(Txt, Offset, maxlen+1) 997 | if (cnt>=cnt2) 998 | cnt++ 999 | else 1000 | cnt:=cnt2+1 1001 | if (cnt>=endc-1) 1002 | break 1003 | } 1004 | } 1005 | } 1006 | } 1007 | Return TempStr 1008 | } 1009 | 1010 | ; retrieves the location of position Index as an object with the keys: 1011 | ; X, Y, Width, Height 1012 | GetAccessibleTextRect(Index) 1013 | { 1014 | VarSetCapacity(Info, 16,0) 1015 | if (DllCall(this.JAB.DLLVersion "\getAccessibleTextRect", "Int", this.vmID, this.JAB.acType, this.ac, "Ptr", &Info, "Int", Index, "Cdecl Int")) 1016 | { 1017 | TempInfo:=Object() 1018 | TempInfo["X"]:=NumGet(&Info,0,"Int") 1019 | TempInfo["Y"]:=NumGet(&Info,4,"Int") 1020 | TempInfo["Width"]:=NumGet(&Info,8,"Int") 1021 | TempInfo["Height"]:=NumGet(&Info,12,"Int") 1022 | return TempInfo 1023 | } 1024 | else 1025 | return 0 1026 | } 1027 | 1028 | ; retrieves the currently selected text and its start and end index as an object with the keys: 1029 | ; SelectionStartIndex, SelectionEndIndex, SelectedText 1030 | GetAccessibleTextSelectionInfo() 1031 | { 1032 | VarSetCapacity(Info, this.JAB.MAX_STRING_SIZE*2+8,0) 1033 | if (DllCall(this.JAB.DLLVersion "\getAccessibleTextSelectionInfo", "Int", this.vmID, this.JAB.acType, this.ac, "Ptr", &Info, "Cdecl Int")) 1034 | { 1035 | TempInfo:=Object() 1036 | TempInfo["SelectionStartIndex"]:=NumGet(&Info, 0, "Int") 1037 | TempInfo["SelectionEndIndex"]:=NumGet(&Info, 4, "Int") 1038 | Offset:=8 1039 | TempInfo["SelectedText"]:=GetJavaString(Info, Offset, this.JAB.MAX_STRING_SIZE) 1040 | return TempInfo 1041 | } 1042 | else 1043 | return 0 1044 | } 1045 | 1046 | ; retrieves the text attributes as an object with the keys: 1047 | ; bold, italic, underline, strikethrough, superscript, subscript, 1048 | ; backgroundColor, foregroundColor, fontFamily, fontSize, 1049 | ; alignment, bidiLevel, firstLineIndent, leftIndent, rightIndent, 1050 | ; lineSpacing, spaceAbove, spaceBelow, fullAttributesString 1051 | GetTextAttributesInRange(startc:=0, endc:=0) 1052 | { 1053 | VarSetCapacity(Info, 3644,0) 1054 | len:=endc-startc+1 1055 | if (DllCall(this.JAB.DLLVersion "\getTextAttributesInRange", "Int", this.vmID, this.JAB.acType, this.ac, "Int", startc, "Int", endc, "Ptr", &Info, "Int", len, "Cdecl Int")) 1056 | { 1057 | TempInfo:=Object() 1058 | Offset:=0 1059 | TempInfo["bold"]:=NumGet(&Info, Offset, "Int") 1060 | Offset+=4 1061 | TempInfo["italic"]:=NumGet(&Info, Offset, "Int") 1062 | Offset+=4 1063 | TempInfo["underline"]:=NumGet(&Info, Offset, "Int") 1064 | Offset+=4 1065 | TempInfo["strikethrough"]:=NumGet(&Info, Offset, "Int") 1066 | Offset+=4 1067 | TempInfo["superscript"]:=NumGet(&Info, Offset, "Int") 1068 | Offset+=4 1069 | TempInfo["subscript"]:=NumGet(&Info, Offset, "Int") 1070 | Offset+=4 1071 | TempInfo["backgroundColor"]:=GetJavaString(Info, Offset, this.JAB.SHORT_STRING_SIZE) 1072 | TempInfo["foregroundColor"]:=GetJavaString(Info, Offset, this.JAB.SHORT_STRING_SIZE) 1073 | TempInfo["fontFamily"]:=GetJavaString(Info, Offset, this.JAB.SHORT_STRING_SIZE) 1074 | TempInfo["fontSize"]:=NumGet(&Info, Offset, "Int") 1075 | Offset+=4 1076 | TempInfo["alignment"]:=NumGet(&Info, Offset, "Int") 1077 | Offset+=4 1078 | TempInfo["bidiLevel"]:=NumGet(&Info, Offset, "Int") 1079 | Offset+=4 1080 | TempInfo["firstLineIndent"]:=NumGet(&Info, Offset, "Float") 1081 | Offset+=4 1082 | TempInfo["leftIndent"]:=NumGet(&Info, Offset, "Float") 1083 | Offset+=4 1084 | TempInfo["rightIndent"]:=NumGet(&Info, Offset, "Float") 1085 | Offset+=4 1086 | TempInfo["lineSpacing"]:=NumGet(&Info, Offset, "Float") 1087 | Offset+=4 1088 | TempInfo["spaceAbove"]:=NumGet(&Info, Offset, "Float") 1089 | Offset+=4 1090 | TempInfo["spaceBelow"]:=NumGet(&Info, Offset, "Float") 1091 | Offset+=4 1092 | TempInfo["fullAttributesString"]:=GetJavaString(Info, Offset, this.JAB.MAX_STRING_SIZE) 1093 | return TempInfo 1094 | } 1095 | else 1096 | return 0 1097 | } 1098 | 1099 | GetActiveDescendent() 1100 | { 1101 | ac:=0 1102 | If (DllCall(this.JAB.DLLVersion "\getActiveDescendent", "Int", this.vmID, this.JAB.acType, this.ac, "Cdecl Int")) 1103 | return new JavaAccessibleContext(this.vmID,ac,this.JAB) 1104 | else 1105 | return 0 1106 | } 1107 | 1108 | ; retrieves the caret location as an object with the keys: 1109 | ; Index, X, Y, Width, Height 1110 | GetCaretLocation(Index:=0) 1111 | { 1112 | VarSetCapacity(Info, 16,0) 1113 | Index:=0 1114 | if (DllCall(this.JAB.DLLVersion "\getCaretLocation", "Int", this.vmID, this.JAB.acType, this.ac, "Ptr", &Info, "Int", Index, "Cdecl Int")) 1115 | { 1116 | TempInfo:=Object() 1117 | TempInfo["X"]:=NumGet(&Info,0,"Int") 1118 | TempInfo["Y"]:=NumGet(&Info,4,"Int") 1119 | TempInfo["Width"]:=NumGet(&Info,8,"Int") 1120 | TempInfo["Height"]:=NumGet(&Info,12,"Int") 1121 | TempInfo["Index"]:=Index 1122 | return TempInfo 1123 | } 1124 | else 1125 | return 0 1126 | } 1127 | 1128 | GetHWNDFromAccessibleContext() 1129 | { 1130 | return DllCall(this.JAB.DLLVersion "\getHWNDFromAccessibleContext", "Int", this.vmID, this.JAB.acType, this.ac, "Cdecl UInt") 1131 | } 1132 | 1133 | GetObjectDepth() 1134 | { 1135 | return DllCall(this.JAB.DLLVersion "\getObjectDepth", "Int", this.vmID, this.JAB.acType, this.ac, "Cdecl Int") 1136 | } 1137 | 1138 | GetParentWithRole(Role) 1139 | { 1140 | ac:=DllCall(this.JAB.DLLVersion "\getParentWithRole", "Int", this.vmID, this.JAB.acType, this.ac, "Ptr", &Role, "Cdecl " this.JAB.acType) 1141 | If (ac) 1142 | return new JavaAccessibleContext(this.vmID,ac,this.JAB) 1143 | else 1144 | return 0 1145 | } 1146 | 1147 | GetParentWithRoleElseRoot(Role) 1148 | { 1149 | ac:=DllCall(this.JAB.DLLVersion "\getParentWithRoleElseRoot", "Int", this.vmID, this.JAB.acType, this.ac, "Ptr", &Role, "Cdecl " this.JAB.acType) 1150 | If (ac) 1151 | return new JavaAccessibleContext(this.vmID,ac,this.JAB) 1152 | else 1153 | return 0 1154 | } 1155 | 1156 | GetTopLevelObject() 1157 | { 1158 | ac:=DllCall(this.JAB.DLLVersion "\getTopLevelObject", "Int", this.vmID, this.JAB.acType, this.ac, "Cdecl " this.JAB.acType) 1159 | If (ac) 1160 | return new JavaAccessibleContext(this.vmID,ac,this.JAB) 1161 | else 1162 | return 0 1163 | } 1164 | 1165 | ; this function seems to be unreliable under Win7 64bit (limit 768 elements?) 1166 | ; works fine under WinXP 1167 | GetVisibleChildren() 1168 | { 1169 | NumChild:=this.GetVisibleChildrenCount() 1170 | StartChild:=0 1171 | Children:=Object() 1172 | Loop, 1173 | { 1174 | VarSetCapacity(TempChildren, 257*this.JAB.acSize,0) 1175 | if (DllCall(this.JAB.DLLVersion "\getVisibleChildren", "Int", this.vmID, this.JAB.acType, this.ac, "Int", StartChild, "Ptr", &TempChildren, "Cdecl Int")) 1176 | { 1177 | retchild:=NumGet(&TempChildren, 0, "Int") 1178 | Loop, %retchild% 1179 | { 1180 | ac:=Numget(&TempChildren, this.JAB.acSize*A_Index, this.JAB.acType) 1181 | Children.Push(new JavaAccessibleContext(this.vmID,ac,this.JAB)) 1182 | } 1183 | StartChild:=StartChild+retchild-10 1184 | } 1185 | else 1186 | break 1187 | } Until StartChild>=NumChild 1188 | return Children 1189 | } 1190 | 1191 | GetVisibleChildrenCount() 1192 | { 1193 | return DllCall(this.JAB.DLLVersion "\getVisibleChildrenCount", "Int", this.vmID, this.JAB.acType, this.ac, "Cdecl Int") 1194 | } 1195 | 1196 | RequestFocus() 1197 | { 1198 | return DllCall(this.JAB.DLLVersion "\requestFocus", "Int", this.vmID, this.JAB.acType, this.ac, "Cdecl Int") 1199 | } 1200 | 1201 | ; may not work properly before JRE7 Update 67 1202 | SetTextContents(Text) 1203 | { 1204 | len := StrLen(Text) 1205 | VarSetCapacity(TempStr, len * 2 + 2, 0) 1206 | Loop, Parse, Text 1207 | { 1208 | offset:=(A_Index-1)*2 1209 | NumPut(Asc(A_LoopField),TempStr,offset,"UChar") 1210 | } 1211 | return, DllCall(this.JAB.DLLVersion "\setTextContents", "Int", this.vmID, this.JAB.acType, this.ac, "UInt", &TempStr, "Cdecl Int") 1212 | } 1213 | 1214 | ; helper function to determine if the current JVM is 32 or 64 bit 1215 | Is64bit() 1216 | { 1217 | If (A_Is64bitOS) 1218 | { 1219 | ; find out if the JVM is running at 32 or 64 bit to circumvent a bug with the adress length in 32 bit JVMs (JRE 6+7) 1220 | tlo:=this.GetTopLevelObject() 1221 | Awin:=tlo.GetHWNDFromAccessibleContext() 1222 | WinGet, ProcID, PID, ahk_id %Awin% 1223 | phandle:=DllCall("OpenProcess", "uint", 0x1000, "uint", 0, "uint", ProcID) 1224 | isWow64process:=0 1225 | DllCall("IsWow64Process", "uint", phandle, "int*", isWow64process) 1226 | if (isWow64process) 1227 | return 0 1228 | else 1229 | return 1 1230 | } 1231 | else 1232 | return 0 1233 | } 1234 | 1235 | SelectTextRange(startIndex, endIndex) 1236 | { 1237 | ; find out if the JVM is running at 32 or 64 bit to circumvent a bug with the adress length in 32 bit JVMs (JRE 6+7) 1238 | ; this workaround seems not be necessary with JRE7update67 or later but seems to causes no trouble either 1239 | if (this.Is64bit()) 1240 | { 1241 | return DllCall(this.JAB.DLLVersion "\selectTextRange", "Int", this.vmID, this.JAB.acType, this.ac, "Int", startIndex, "Int", endIndex, "Cdecl Int") 1242 | } 1243 | else 1244 | { 1245 | return DllCall(this.JAB.DLLVersion "\selectTextRange", "Int", this.vmID, "Ptr", this.ac, "Int", startIndex, "Int", endIndex, "Cdecl Int") 1246 | } 1247 | } 1248 | 1249 | SetCaretPosition(position) 1250 | { 1251 | ; find out if the JVM is running at 32 or 64 bit to circumvent a bug with the adress length in 32 bit JVMs (JRE 6+7) 1252 | ; this workaround seems not be necessary with JRE7update67 or later but seems to causes no trouble either 1253 | if (this.Is64bit()) 1254 | { 1255 | return DllCall(this.JAB.DLLVersion "\setCaretPosition", "Int", this.vmID, this.JAB.acType, this.ac, "Int", position, "Cdecl Int") 1256 | } 1257 | else 1258 | { 1259 | return DllCall(this.JAB.DLLVersion "\setCaretPosition", "Int", this.vmID, "Ptr", this.ac, "Int", position, "Cdecl Int") 1260 | } 1261 | } 1262 | } 1263 | 1264 | GetJavaString(byref Struct, byref BaseOffset, Length) 1265 | { 1266 | resstr:="" 1267 | Loop, %Length% 1268 | { 1269 | offset:=(A_Index-1)*2+BaseOffset 1270 | char:=Chr(NumGet(&Struct,offset,"UChar")) 1271 | if (char=Chr(0)) 1272 | break 1273 | resstr.=char 1274 | } 1275 | BaseOffset+=Length*2 1276 | return resstr 1277 | } 1278 | 1279 | /* 1280 | functions that have not been ported yet 1281 | 1282 | { exported user functions of the Java Access Bridge } 1283 | 1284 | { AccessibleTable } 1285 | function getAccessibleTableInfo(vmID: longint; ac: AccessibleContext; tableinfo: PAccessibleTableInfo):JBool; 1286 | function getAccessibleTableCellInfo(vmID: longint; at: AccessibleTable; row: jint; column: jint; tableCellInfo: PAccessibleTableCellInfo):JBool; 1287 | function getAccessibleTableRowHeader(vmID: longint; acParent: AccessibleContext; tableInfo: PAccessibleTableInfo):JBool; 1288 | function getAccessibleTableColumnHeader(vmID: longint; acParent: AccessibleContext; tableinfo: PAccessibleTableInfo):JBool; 1289 | function getAccessibleTableRowDescription(vmID: longint; acParent: AccessibleContext; row: jint):AccessibleContext; 1290 | function getAccessibleTableColumnDescription(vmID: longint; acParent: AccessibleContext; column: jint):AccessibleContext; 1291 | function getAccessibleTableRowSelectionCount(vmID: longint; table: AccessibleTable):jint; 1292 | function isAccessibleTableRowSelected(vmID: longint; table: AccessibleTable; row: jint):Jbool; 1293 | function getAccessibleTableRowSelections(vmID: longint; table: AccessibleTable; count: jint; selections: pjint):JBool; 1294 | function getAccessibleTableColumnSelectionCount(vmID: longint; table: AccessibleTable):Jint; 1295 | function isAccessibleTableColumnSelected(vmID: longint; table: AccessibleTable; column: jint):JBool; 1296 | function getAccessibleTableColumnSelections(vmID: longint; table: AccessibleTable; count: jint; selections: pjint):JBool; 1297 | function getAccessibleTableRow(vmID: longint; table: AccessibleTable; index: jint):jint; 1298 | function getAccessibleTableColumn(vmID: longint; table: AccessibleTable; index: jint):jint; 1299 | function getAccessibleTableIndex(vmID: longint; table: AccessibleTable; row: jint; column: jint):jint; 1300 | 1301 | { AccessibleRelationSet } 1302 | function getAccessibleRelationSet(vmID: longint; ac: AccessibleContext; relationSetInfo: PAccessibleRelationSetInfo):JBool; 1303 | 1304 | { AccessibleHypertext } 1305 | function getAccessibleHypertext(vmID: longint; ac: AccessibleContext; hypertextInfo: PAccessibleHypertextInfo):JBool; 1306 | function activateAccessibleHyperlink(vmID: longint; ac: AccessibleContext; aH: AccessibleHyperlink):JBool; 1307 | function getAccessibleHyperlinkCount(vmID: longint; ac: AccessibleContext):Jint; 1308 | function getAccessibleHypertextExt(vmID: longint; ac: AccessibleContext; nStartIndex: jint; hypertextInfo: PAccessibleHypertextInfo):JBool; 1309 | function getAccessibleHypertextLinkIndex(vmID: longint; ah: AccessibleHypertext; nIndex: jint):jint; 1310 | function getAccessibleHyperlink(vmID: longint; ah: AccessibleHypertext; nIndex: jint; hyperlinkInfo: PAccessibleHyperlinkInfo):JBool; 1311 | 1312 | { Accessible KeyBindings, Icons and Actions } 1313 | function getAccessibleKeyBindings(vmID: longint; ac: AccessibleContext; keyBindings: PAccessibleKeyBindings):JBool; 1314 | function getAccessibleIcons(vmID: longint; ac: AccessibleContext; icons: PAccessibleIcons):JBool; 1315 | 1316 | { AccessibleText } 1317 | getCurrentAccessibleValueFromContext 1318 | getMaximumAccessibleValueFromContext 1319 | getMinimumAccessibleValueFromContext 1320 | 1321 | function GetCurrentAccessibleValueFromContext(vmID: longint; av: AccessibleValue; value: pwidechar; len: jshort):JBool; 1322 | function GetMaximumAccessibleValueFromContext(vmID: longint; av: AccessibleValue; value: pwidechar; len: jshort):JBool; 1323 | function GetMinimumAccessibleValueFromContext(vmID: longint; av: AccessibleValue; value: pwidechar; len: jshort):JBool; 1324 | 1325 | procedure AddAccessibleSelectionFromContext(vmID: longint; acsel: AccessibleSelection; i: Jint); 1326 | procedure ClearAccessibleSelectionFromContext(vmID: longint; acsel: AccessibleSelection); 1327 | function GetAccessibleSelectionFromContext(vmID: longint; acsel: AccessibleSelection; i: jint):JObject; 1328 | function GetAccessibleSelectionCountFromContext(vmID: longint; acsel: AccessibleSelection):Jint; 1329 | function IsAccessibleChildSelectedFromContext(vmID: longint; acsel: AccessibleSelection; i: Jint):Jbool; 1330 | procedure RemoveAccessibleSelectionFromContext(vmID: longint; acsel: AccessibleSelection; i: Jint); 1331 | procedure SelectAllAccessibleSelectionFromContext(vmID: longint; acsel: AccessibleSelection); 1332 | 1333 | { Utility methods } 1334 | function getVirtualAccessibleName(vmID: longint; ac: AccessibleContext; name: pwidechar; len: integer):JBool; 1335 | function getTextAttributesInRange(vmID: longint; ac: AccessibleContext; startIndex: integer; endIndex: integer; attributes: PAccessibleTextAttributesInfo; len: Jshort): JBool; 1336 | function getEventsWaiting():Jint; 1337 | 1338 | { All unported functions in Windowsaccessbridge32.dll } 1339 | activateAccessibleHyperlink 1340 | getAccessibleHyperlink 1341 | getAccessibleHyperlinkCount 1342 | getAccessibleHypertext 1343 | getAccessibleHypertextExt 1344 | getAccessibleHypertextLinkIndex 1345 | 1346 | getAccessibleTableCellInfo 1347 | getAccessibleTableColumn 1348 | getAccessibleTableColumnDescription 1349 | getAccessibleTableColumnHeader 1350 | getAccessibleTableColumnSelectionCount 1351 | getAccessibleTableColumnSelections 1352 | getAccessibleTableIndex 1353 | getAccessibleTableInfo 1354 | getAccessibleTableRow 1355 | getAccessibleTableRowDescription 1356 | getAccessibleTableRowHeader 1357 | getAccessibleTableRowSelectionCount 1358 | getAccessibleTableRowSelections 1359 | isAccessibleTableColumnSelected 1360 | isAccessibleTableRowSelected 1361 | 1362 | addAccessibleSelectionFromContext 1363 | clearAccessibleSelectionFromContext 1364 | getAccessibleSelectionCountFromContext 1365 | getAccessibleSelectionFromContext 1366 | isAccessibleChildSelectedFromContext 1367 | removeAccessibleSelectionFromContex 1368 | selectAllAccessibleSelectionFromContext 1369 | 1370 | getAccessibleIcons 1371 | getAccessibleKeyBindings 1372 | getAccessibleRelationSet 1373 | getEventsWaiting 1374 | getVirtualAccessibleName 1375 | */ 1376 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | Version: MPL 2.0/GPL 3.0/LGPL 3.0 2 | 3 | The contents of this project are subject to the Mozilla Public License Version 4 | 2.0 (the "License"); you may not use this file except in compliance with 5 | the License. You may obtain a copy of the License at 6 | 7 | http://www.mozilla.org/MPL/ 8 | 9 | Software distributed under the License is distributed on an "AS IS" basis, 10 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | for the specific language governing rights and limitations under the License. 12 | 13 | The Initial Developer of the Original Code is 14 | Elgin . 15 | Portions created by the Initial Developer are Copyright (C) 2010-2017 16 | the Initial Developer. All Rights Reserved. 17 | 18 | Contributor(s): 19 | 20 | Alternatively, the contents of this file may be used under the terms of 21 | either the GNU General Public License Version 3 or later (the "GPL"), or 22 | the GNU Lesser General Public License Version 3.0 or later (the "LGPL"), 23 | in which case the provisions of the GPL or the LGPL are applicable instead 24 | of those above. If you wish to allow use of your version of this file only 25 | under the terms of either the GPL or the LGPL, and not to allow others to 26 | use your version of this file under the terms of the MPL, indicate your 27 | decision by deleting the provisions above and replace them with the notice 28 | and other provisions required by the GPL or the LGPL. If you do not delete 29 | the provisions above, a recipient may use your version of this file under 30 | the terms of any one of the MPL, the GPL or the LGPL. 31 | 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java Access Bridge Wrapper for AutoHotkey 2 | 3 | The [Java Access Bridge](http://www.oracle.com/technetwork/articles/javase/index-jsp-136191.html) for Windows is an API provided by Oracle to use the accessibility features of Java-Swing GUIs. This repository contains wrappers for this API to use the Java Access Bridge from AutoHotkey. 4 | 5 | The files in this repository are: 6 | - [JavaAccessBridge.ahk](JavaAccessBridge.ahk): A function based wrapper for the Java Access Bridge 7 | - [JavaAccessBridge_class.ahk](JavaAccessBridge_class.ahk): A class based wrapper for the Java Access Bridge 8 | - [JControlWriter.ahk](JControlWriter.ahk): A browser for accessible controls in Java applications 9 | - [JAB Swingset3 Demo.ahk](JAB%20Swingset3%20Demo.ahk): A demo how to use the JAB with SwingSet3.jar (various download locations) 10 | - [JCWGUIStrings.ini](JCWGUIStrings.ini): The GUI-strings for JControlWriter 11 | 12 | ## How to use 13 | 14 | Before you can access Java applications through the Java access bridge you need to enable or install the Java Access Bridge first. 15 | 16 | - **Java SE 7 Update 6 or later**: Java Access Bridge can be enabled through the Control Panel in the Ease of Access Center. (See *[Enabling and Testing Java Access Bridge](https://docs.oracle.com/javase/7/docs/technotes/guides/access/enable_and_test.html)*) 17 | - **Java SE 7 Update 5 or earlier**: Java Access Bridge must be installed manually. (See *[Installing Java Access Bridge](http://www.oracle.com/technetwork/articles/javase/index-jsp-136191.html)*) 18 | 19 | To get an overview of which accessible information is published by your Java application you can use [JControlWriter.ahk](JControlWriter.ahk). 20 | 21 | With your Java application as the active window, press either Ctrl-Alt-F10 or Ctrl-Alt-F11 to show a list of the accessible controls. 22 | 23 | ## Known issues 24 | 25 | - Not all functions are wrapped yet; see comment section at the end of [JavaAccessBridge.ahk](JavaAccessBridge.ahk) 26 | - Java applications can sometimes behave strangely. For instance when you use an action to call a function that opens a dialog, this call may not return until the dialog is closed again, effectively freezing your script. Use the "left click" action in those cases. 27 | 28 | --------------------------------------------------------------------------------