Platforms to show: All Mac Windows Linux Cross-Platform

/MacOSX/Accessibility services/Accessible Browser


Required plugins for this example: MBS MacCF Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacOSX/Accessibility services/Accessible Browser

This example is the version from Mon, 6th Oct 2013.

Project "Accessible Browser.xojo_binary_project"
Class Window1 Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub ExpandRow(row As Integer) dim id as integer id=val(List.Cell(row,1)) if id>0 then showvalue obj(id) end if End EventHandler
End Control
EventHandler Sub Open() if not AccessibilityMBS.Available then MsgBox "The framework for the Accessible API could not be loaded." quit end if if not AccessibilityMBS.AXAPIEnabled then MsgBox "The Accessible API is not enabled" quit end if List.DeleteAllRows showitem AccessibilityMBS.SystemWideAXUIElement,"SystemWide" End EventHandler
Sub showCFArray(ob as cfobjectMBS) if ob isa CFArrayMBS then dim s as CFArrayMBS = CFArrayMBS(ob) dim c as integer = s.Count - 1 for i as integer = 0 to c showitem s.Item(i), "Array item "+str(i+1)+"/"+str(c) next end if End Sub
Sub showCFBoolean(ob as cfobjectMBS) if ob isa CFBooleanMBS then dim s as CFBooleanMBS = CFBooleanMBS(ob) if s.Value then List.AddRow "Boolean: true" else List.AddRow "Boolean: false" end if end if End Sub
Sub showCFNumber(ob as cfobjectMBS) if ob isa CFNumberMBS then dim s as CFNumberMBS = CFNumberMBS(ob) List.AddRow "Number: "+str(s.doubleValue) end if End Sub
Sub showCFString(ob as cfobjectMBS) if ob isa CFStringMBS then dim s as CFStringMBS = CFStringMBS(ob) List.AddRow "String: "+s.str end if End Sub
Sub showelement(el as axuiElementMBS) dim i,c,count as integer dim o as CFObjectMBS dim s as CFStringMBS dim ar as cfarrayMBS dim des as String dim al as AXValueMBS ar=el.ActionNames if ar<>nil then c=ar.Count-1 for i=0 to c o=ar.Item(i) if o isa CFStringMBS then s = CFStringMBS(o) if s<>nil then des="" o=el.ActionDescription(s) if o isa CFStringMBS then s = CFStringMBS(o) if s<>nil then des=" ("+s.str+")" end if end if List.AddRow "Action: "+s.str+des end if end if next end if ar=el.AttributeNames if ar<>nil then c=ar.Count-1 for i=0 to c o=ar.Item(i) if o<>Nil then s = CFStringMBS(o) if s<>nil then count=el.GetAttributeValueCount(s) al=el.AttributeValue(s) des=" ("+str(count) if el.IsAttributeSettable(s) then des=des+", writeable)" else des=des+", readonly)" end if des=des if al<>nil then List.Addfolder s.str+des else List.Addrow s.str+des end if obj.Append al List.Cell(List.LastIndex,1)=str(UBound(obj)) end if end if next end if End Sub
Sub showitem(e as cfobjectmbs, s as string) dim id as integer if e<>nil then obj.Append e id=UBound(obj) List.AddFolder s List.Cell(List.LastIndex,1)=str(id) end if Exception End Sub
Sub showvalue(ob as cfobjectMBS) dim al as AXValueMBS dim el as AXUIElementMBS dim x,y,w,h as Single dim lo,le as integer dim typ as integer // Types from CoreGraphics.h */ const kAXValueCGPointType = 1 const kAXValueCGSizeType = 2 const kAXValueCGRectType = 3 // Types from CFBase.h */ const kAXValueCFRangeType = 4 // Other */ const kAXValueIllegalType = 0 // First it may be a AXValue object // But an AXValue object can be just a CFObject where AXTypeID=kAXValueIllegalType if ob isa AXValueMBS then al=AXValueMBS(ob) Select case al.AXTypeID case kAXValueCGPointType if al.AXGetCGPoint(x,y) then List.AddRow "CGPoint ("+str(x)+", "+str(y)+")" else List.AddRow "CGPoint?" end if Return case kAXValueCGSizeType if al.AXGetCGSize(w,h) then List.AddRow "CGSize ("+str(w)+", "+str(h)+")" else List.AddRow "CGSize?" end if Return case kAXValueCGRectType if al.AXGetCGRect(x,y,w,h) then List.AddRow "CGRect ("+str(x)+", "+str(y)+", "+str(w)+", "+str(h)+")" else List.AddRow "CGRect?" end if Return case kAXValueCFRangeType if al.AXGetCFRange(lo,le) then List.AddRow "CFRange ("+str(lo)+", "+str(le)+")" else List.AddRow "CFRange?" end if Return end Select end if // Now check CF type codes typ=ob.Type if typ=AccessibilityMBS.kAXUIElementMBSTypeID then if ob isa AXUIElementMBS then el=AXUIElementMBS(ob) else el=new AXUIElementMBS // make a new object to avoid cast exception el.Handle=ob.Handle end if showelement el elseif typ=kCFArrayMBSTypeID then showCFarray ob elseif typ=kCFSetMBSTypeID then List.AddRow "kCFSet" elseif typ=kCFStringMBSTypeID then showCFString ob elseif typ=kCFNumberMBSTypeID then showCFNumber ob elseif typ=kCFBagMBSTypeID then List.AddRow "kCFBag" elseif typ=kCFDictionaryMBSTypeID then List.AddRow "kCFDictionary" elseif typ=kCFBinaryDataMBSTypeID then List.AddRow "kCFBinaryData" elseif typ=kCFBooleanMBSTypeID then showCFBoolean ob elseif typ=kCFURLMBSTypeID then List.AddRow "kCFURL" elseif typ=kCFDateMBSTypeID then List.AddRow "kCFDate" else List.AddRow "?" end if End Sub
Property Protected obj(0) As cfobjectMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

See also:

The items on this page are in the following plugins: MBS MacOSX Plugin.


The biggest plugin in space...