microsoft / xlang

MIT License
875 stars 103 forks source link

Please try [winsdk](https://pypi.org/project/winsdk/) instead of [winrt](https://pypi.org/project/winrt/). #796

Closed wookidooki8 closed 10 months ago

wookidooki8 commented 10 months ago
          Please try [winsdk](https://pypi.org/project/winsdk/) instead of [winrt](https://pypi.org/project/winrt/).

Originally posted by @dlech in https://github.com/microsoft/xlang/issues/756#issuecomment-1141261907

When I applied the above code, the window selection screen appears, but after selecting the window I want to capture, nothing is displayed on the screen. Is there a way to resolve this issue?

import turtle

from winsdk._winrt import initialize_with_window from winsdk.windows.foundation import IAsyncOperation, AsyncStatus from winsdk.windows.graphics.capture import GraphicsCapturePicker, GraphicsCaptureItem

def on_pick_completed(op: IAsyncOperation, status: AsyncStatus) -> None: if status == AsyncStatus.ERROR: print("error: ", status.error_code.value) elif status == AsyncStatus.CANCELED:

this is programatically, canceled, not user canceled

    print("operation canceled")
elif status == AsyncStatus.COMPLETED:
    result: Optional[GraphicsCaptureItem] = op.get_results()
    if result:
        print("result:",  result.display_name)
    else:
        print("user canceled")

op.close()

picker = GraphicsCapturePicker() initialize_with_window(picker, turtle.getcanvas().winfo_id()) op = picker.pick_single_item_async() op.completed = on_pick_completed

turtle.mainloop()

github-actions[bot] commented 10 months ago

This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.