microsoft/xlang

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

wookidooki8 opened this issue · 1 comments

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

Originally posted by @dlech in #756 (comment)

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()

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.