Python wrapper for the Windows Java Access Bridge
Reason this release was yanked:
Incorrect API change breaking backward compatibility
Project description
Introduction
Python wrapper around the Java Access Bridge / Windows Access Bridge.
Prerequisites
- 64-bit Windows
- Java >= 8 (https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/downloads-list.html)
- Python >= 3.7 (https://www.python.org/downloads/release/python-375/)
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
Development prerequisites
- Install poetry: https://python-poetry.org/docs/
Test
Run test script against simple Swing application
set environment variable
set RC_JAVA_ACCESS_BRIDGE_DLL="C:\path\to\Java\bin\WindowsAccessBridge-64.dll"
Run test with poetry
poetry run python tests\test.py
Packaging
poetry build
poetry publish
TODO:
- Support for 32-bit Java Access Bridge version
- Implement rest of the utility functions to the JABWrapper
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file java-access-bridge-wrapper-0.9.6.tar.gz
.
File metadata
- Download URL: java-access-bridge-wrapper-0.9.6.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.8.10 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c1964fd555ba1b507d795b97d9e5d5c29ea0569e5c545148929f7ca8f76ee23 |
|
MD5 | 3e2cba4d06585779cdff4bb9ef3cc384 |
|
BLAKE2b-256 | 8f332cdd3b65e0794aec317459cc1b84b29be7a3900a375f5e7fadfadece9f3e |
Provenance
File details
Details for the file java_access_bridge_wrapper-0.9.6-py3-none-any.whl
.
File metadata
- Download URL: java_access_bridge_wrapper-0.9.6-py3-none-any.whl
- Upload date:
- Size: 28.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.8.10 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60159873612f5b54f6a44ba04f298e53a5f2ff9614444bbf13988f56fb4277f9 |
|
MD5 | ee049210abd2f324efb83c366a15917c |
|
BLAKE2b-256 | d5d211e0d82501821b1cff40f573c02866e08bfa90b8ab8fabb4404baf2c9b97 |