robocorp / java-access-bridge-wrapper

Python wrapper around the Java Access Bridge Windows .dll
Apache License 2.0
14 stars 6 forks source link

Process finished with exit code -1073740771 (0xC000041D) #3

Closed sunnic1988 closed 3 years ago

sunnic1988 commented 3 years ago
import ctypes
import logging
import queue
import threading
import time
from ctypes import wintypes

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

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 = ctypes.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
    jab_wrapper.switch_window_by_title("SwingSet2")
    context_tree = ContextTree(jab_wrapper)
    print(context_tree)

if __name__ == "__main__":
    main()

When the python code including Java Access Bridge API Callbacks, i always met this error code. Do you have any idea?

Please see the logs: 2021-07-07 13:59:13,517 [Thread-6] [DEBUG] Loading WindowsAccessBridge 2021-07-07 13:59:13,519 [Thread-6] [DEBUG] WindowsAccessBridge loaded succesfully 2021-07-07 13:59:24,231 [Thread-6] [DEBUG] Dispatching msg=<cparam 'P' (000001D9D0714C30)> 2021-07-07 13:59:26,941 [Thread-6] [DEBUG] Dispatching msg=<cparam 'P' (000001D9D0714C30)> 2021-07-07 13:59:28,788 [Thread-6] [DEBUG] Dispatching msg=<cparam 'P' (000001D9D0714C30)>

sunnic1988 commented 3 years ago

Today is a lucky day. I re-installed java jdk-8u291-windows-x64.exe. enable jabswitch for C:\Program Files\Java\jre1.8.0_291\bin and C:\Program Files\Java\jdk1.8.0_291\bin. It can be worked.

mmokko commented 3 years ago

Closing the issue as reinstalling java solved the issue.