2013-09-27 4 views
2

Java Access Bridge 이벤트를 사용하여 Java 응용 프로그램의 UI 컨트롤 (단추/편집 상자/체크 박스 등)에서 텍스트를 캡처 할 수 있습니다. 어떻게 I :Java Access Bridge를 사용한 자동화

  1. 설정 자바 액세스 브릿지 API 호출을 사용하여 버튼

에 편집 상자

  • 클릭의 텍스트?

  • +0

    는 당신이 JAB와 텍스트를 캡처하는 방법을 설명 할 수 ... 버튼

    public void Press() { DoAction("click"); } protected void DoAction(params string[] actions) { API.AccessibleActionsToDo todo = new API.AccessibleActionsToDo() { actionInfo = new API.AccessibleActionInfo[API.MAX_ACTIONS_TO_DO], actionsCount = actions.Length, }; for (int i = 0, n = Math.Min(actions.Length, API.MAX_ACTIONS_TO_DO); i < n; i++) todo.actionInfo[i].name = actions[i]; Int32 failure = 0; if (!API.doAccessibleActions(this.VmId, this.Context, ref todo, ref failure)) throw new AccessibilityException("Error performing action"); } 

    코어를 클릭? –

    답변

    0

    나는 당신의 GUI 구성 요소의 AccessibleContext를를 서브 클래스와 AccessibleAction가 객체를 제공한다. AccessibleContext.getAccessibleAction() 개체를 반환하십시오.

    null이 아닌 경우 화면 판독기에서 doAction을 호출하여 지원되는 동작 목록을 화면 판독기에 제공합니다.

    0

    여기 내 프로젝트에서 사용한 방법입니다. 모든 PInvokes를 JAB WindowsAccessBridge DLL로 호출하는 기본 클래스 API를 만듭니다. 64 비트 OS를 사용하는 경우 적절한 DLL 이름을 지정하십시오. getAccessibleContextFromHWND 함수를 사용하여 Windows Handle에서 VmID 및 Context를 가져옵니다. 자식을 열거하여 Java 창에서 텍스트 상자 또는 단추를 찾습니다. TextBox 또는 버튼을 사용하여 찾고있는 컨트롤을 찾으면 작업을 수행합니다. 설정

    1) 텍스트

    public string Text 
    { 
        get 
        { 
         return GetText(); 
        } 
        set 
        { 
         if (!API.setTextContents(this.VmId, this.Context, value)) 
          throw new AccessibilityException("Error setting text"); 
        } 
    } 
    
    private string GetText() 
    { 
        System.Text.StringBuilder sbText = new System.Text.StringBuilder(); 
    
        int caretIndex = 0; 
    
        while (true) 
        { 
         API.AccessibleTextItemsInfo ti = new API.AccessibleTextItemsInfo(); 
         if (!API.getAccessibleTextItems(this.VmId, this.Context, ref ti, caretIndex)) 
          throw new AccessibilityException("Error getting accessible text item information"); 
    
         if (!string.IsNullOrEmpty(ti.sentence)) 
          sbText.Append(ti.sentence); 
         else    
          break; 
    
         caretIndex = sbText.Length; 
    
        } 
    
        return sbText.ToString().TrimEnd(); 
    } 
    

    2)

    public API.AccessBridgeVersionInfo VersionInfo 
    { 
        get { return GetVersionInfo(this.VmId); } 
    } 
    
    public API.AccessibleContextInfo Info 
    { 
        get { return GetContextInfo(this.VmId, this.Context); } 
    } 
    
    public Int64 Context 
    { 
        get; 
        protected set; 
    } 
    
    public Int32 VmId 
    { 
        get; 
        protected set; 
    } 
    
    관련 문제