Skip to content

Commit 24bb0f8

Browse files
committed
fixed bug, taking screenshot from selected display
1 parent 0bc9fac commit 24bb0f8

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/askui/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, log_level=logging.INFO, display: int = 1):
1717

1818
self.controller = AskUiControllerServer()
1919
self.controller.start(True)
20-
self.client = AskUiControllerClient()
20+
self.client = AskUiControllerClient(display)
2121
self.client.connect()
2222
self.client.set_display(display)
2323
self.claude = ClaudeHandler(log_level=log_level)

src/askui/tools/askui_controller.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __find_remote_device_controller(self) -> str:
3232
return f"{os.environ['ASKUI_INSTALLATION_DIRECTORY']}/Binaries/resources/assets/binaries/AskuiRemoteDeviceController"
3333

3434
def __start_process(self, path):
35-
self.process = subprocess.Popen(path)
35+
self.process = subprocess.Popen([path, "--debugDraw", "true"])
3636
wait_for_port(23000)
3737

3838
def start(self, clean_up=False):
@@ -54,13 +54,14 @@ def stop(self, force=False):
5454

5555

5656
class AskUiControllerClient():
57-
def __init__(self) -> None:
57+
def __init__(self, display: int = 1) -> None:
5858
self.stub = None
5959
self.channel = None
6060
self.session_info = None
6161
self.pre_action_wait = 0
6262
self.post_action_wait = 0.05
6363
self.max_retries = 10
64+
self.display = display
6465

6566
def connect(self):
6667
self.channel = grpc.insecure_channel('localhost:23000', options=[
@@ -103,8 +104,8 @@ def __start_execution(self):
103104
def __stop_execution(self):
104105
self.stub.StopExecution(controller_v1_pbs.Request_StopExecution(sessionInfo=self.session_info))
105106

106-
def screenshot(self, display=1) -> Image:
107-
screenResponse = self.stub.CaptureScreen(controller_v1_pbs.Request_CaptureScreen(sessionInfo=self.session_info, captureParameters=controller_v1_pbs.CaptureParameters(displayID=display)))
107+
def screenshot(self) -> Image:
108+
screenResponse = self.stub.CaptureScreen(controller_v1_pbs.Request_CaptureScreen(sessionInfo=self.session_info, captureParameters=controller_v1_pbs.CaptureParameters(displayID=self.display)))
108109
r, g, b, _ = Image.frombytes('RGBA', (screenResponse.bitmap.width, screenResponse.bitmap.height), screenResponse.bitmap.data).split()
109110
image = Image.merge("RGB", (b, g, r))
110111
return image
@@ -165,3 +166,4 @@ def keyboard_tap(self, key: str, modifierKeys: List[str] = None):
165166

166167
def set_display(self, displayNumber: int = 1):
167168
self.stub.SetActiveDisplay(controller_v1_pbs.Request_SetActiveDisplay(displayID=displayNumber))
169+
self.display = displayNumber

0 commit comments

Comments
 (0)