Skip to main content

Version License

Introduction

Python wrapper around the Java Access Bridge / Windows Access Bridge.

Requirements

Enable the Java Access Bridge in windows

C:\path\to\java\bin\jabswitch -enable

Install

pip install java-access-bridge-wrapper

How to use

Import the Java Access Bridge (JAB) wrapper and optionally the context tree

from JABWrapper.jab_wrapper import JavaAccessBridgeWrapper
from JABWrapper.context_tree import ContextNode, ContextTree, SearchElement

The JAB creates an virtual GUI window when it is opened. For the JAB to operate and receive events from the GUI, the calling code needs to implement the windows message pump and call it in a loop. The JABWrapper object needs to be in the same thread.

This can be achieved for example by starting the message pump in a separate thread, where the JAB object is also initialized.

GetMessage = ctypes.windll.user32.GetMessageW
TranslateMessage = ctypes.windll.user32.TranslateMessage
DispatchMessage = ctypes.windll.user32.DispatchMessageW

def pump_background(pipe: queue.Queue):
    try:
        jab_wrapper = JavaAccessBridgeWrapper()
        pipe.put(jab_wrapper)
        message = byref(wintypes.MSG())
        while GetMessage(message, 0, 0, 0) > 0:
            TranslateMessage(message)
            logging.debug("Dispatching msg={}".format(repr(message)))
            DispatchMessage(message)
    except Exception as err:
        pipe.put(None)

def main():
    pipe = queue.Queue()
        thread = threading.Thread(target=pump_background, daemon=True, args=[pipe])
        thread.start()
        jab_wrapper = pipe.get()
        if not jab_wrapper:
            raise Exception("Failed to initialize Java Access Bridge Wrapper")
        time.sleep(0.1) # Wait until the initial messages are parsed, before accessing frames

if __name__ == "__main__":
    main()

Once the JABWrapper object is initialized, attach to some frame and optionally create the context tree to get the element tree of the application.

jab_wrapper.switch_window_by_title("Frame title")
context_tree = ContextTree(jab_wrapper)

Development

Prerequisites

  1. Install Invoke, Poetry and the other required dependencies in order to be able to develop and package the library: pip install -Ur requirements.txt.
    • If you want to isolate these from the other projects and not rely on the OS Python, enable a (pyenv) virtual environment first by following these instructions.
  2. Now you're ready to set-up Poetry for the first time with inv setup.
    • Check with -h on how to pass credentials for ensuring that both your production PyPI and CI DevPI are configured. You'll find these in our Robocorp > Shared 1Password by searching for keywords like "pypi" (where we recommend a personal token instead) and "devpi".
  3. Run inv update so the library gets ready for development.

Testing

Run test script against a simple Swing application.

Set environment variable

set RC_JAVA_ACCESS_BRIDGE_DLL="C:\path\to\Java\bin\WindowsAccessBridge-64.dll"

Update requirements and install the library in development mode

inv update

Run tests

inv test  # runs all the tests in all scenarios
inv test -s -t test_jab_wrapper.py  # runs all the tests from a file in one simple common scenario
inv test -s -c -t test_jab_wrapper.py::test_depth  # as above, but specific test and captures output

Packaging

Check linting

inv lint  # apply with '-a'

Building and publishing

inv publish  # '-c' for DevPI

TODO:

  • Support for 32-bit Java Access Bridge version
  • Implement rest of the utility functions to the JABWrapper

Metadata

Release files for java-access-bridge-wrapper 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for java-access-bridge-wrapper 2.0.0
File Size Uploaded
java_access_bridge_wrapper-2.0.0.tar.gz 29.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for java-access-bridge-wrapper 2.0.0
File Interpreter ABI Platform
java_access_bridge_wrapper-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 62.5 kB

Release files / java_access_bridge_wrapper-2.0.0.tar.gz

Download URL java_access_bridge_wrapper-2.0.0.tar.gz
Size 29.4 kB
Tags Source
SHA-256 checksum
How to use checksums
eb7d067f5c9fe951110cc532ee6045fd204b31ab7294208eb1db2bbd31ea690e
BLAKE2b-256 checksum
How to use checksums
d3beb8298c256b3ee1e7da0d734e13cf54e8e12411daa6dce1035b91e29fe479
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.12.7 Windows/11

Release files / java_access_bridge_wrapper-2.0.0-py3-none-any.whl

Download URL java_access_bridge_wrapper-2.0.0-py3-none-any.whl
Size 33.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1296f2c5f0c804330824367ecbadb18ece0bbf9736738cac0ae5ba791e311e2
BLAKE2b-256 checksum
How to use checksums
b733cd31b8e1786b5660987856d37ebd9266313671ce4c20c76c9501acda8a47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.12.7 Windows/11

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.14.1

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.9.7

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.2

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page