Does Reflex provide a way to get the window handle?

I’m trying to integrate an Azure AD sign in method with a Reflex app. The MSAL python library provides a broker service to allow interactive sign ins in a windows environment, but requires a window handle to target. It’s inside a docker container, which rules out pywin32 for grabbing the active window.

My question:
Does Reflex provide a way to get its window handle? Pywin32’s equivalent is:

hwnd = win32gui.GetForegroundWindow()

You can use rx.call_script with window.getCurrent (refer here)
There’s a similar example in the docs which gets the window location here

I copied the docs example, which runs normally. When I add in an identical section for the window.getCurrent, it doesn’t return anything and I end up with “{}” in the text box. I’ve also tried lastFocusedWindow, but it’s the same. I know nothing about Javascript or what I could be doing wrong with the script other than mimicking the docs. Would you be able to tell me where to fix this?

class WindowState(rx.State):
    location: dict[str, str] = {}
    scroll_position: dict[str, int] = {}
    window_handle: dict[str, str] = {}

    def update_location(self, location):
        self.location = location

    def update_handle(self, new_handle):
        self.window_handle = new_handle

    def update_scroll_position(self, scroll_position):
        self.scroll_position = {
            "x": scroll_position[0],
            "y": scroll_position[1],
        }

    def get_client_values(self):
        return [
            rx.call_script(
                "window.location",
                callback=WindowState.update_location,
            ),
            rx.call_script(
                "[window.scrollX, window.scrollY]",
                callback=WindowState.update_scroll_position,
            ),
            rx.call_script(
                "window.getCurrent",
                callback=WindowState.update_handle,
            ),
        ]


def index() -> rx.Component:
    # Welcome Page (Index)
    return rx.container(
        rx.color_mode.button(position="top-right"),
        rx.button(
            "Update Values",
            on_click=WindowState.get_client_values,
        ),
        rx.text(
            f"Scroll Position: {WindowState.scroll_position.to_string()}"
        ),
        rx.text("window.location:"),
        rx.text_area(
            value=WindowState.location.to_string(),
            is_read_only=True,
        ),
        rx.text_area(
            value=WindowState.window_handle.to_string(),
            is_read_only=True,
        ),
        on_mount=WindowState.get_client_values,
    )

In JavaScript, there is no direct window.getCurrent function to retrieve the window handle; window.getCurrent is likely a placeholder that may not actually work as you expect. In web environments, the concept of a “window handle” isn’t directly accessible like it is in native applications.

def get_client_values(self):
    return [
        rx.call_script(
            "window.location.href",  # This returns the current URL
            callback=WindowState.update_location,
        ),
        rx.call_script(
            "[window.scrollX, window.scrollY]",  # Returns current scroll positions
            callback=WindowState.update_scroll_position,
        ),
        rx.call_script(
            "document.title",  # Example to return page title instead of window handle
            callback=WindowState.update_handle,
        ),
    ]

If you are trying to get the hwnd from a client, i can tell you this wont be an easy progress. Server side this is no Problem but Java script is limited to the browser, pretty hard to escape from there and check the whole computers env for the current active window.