|
6 | 6 | from operate.utils.misc import convert_percent_to_decimal |
7 | 7 |
|
8 | 8 |
|
9 | | -def keyboard_type(text): |
| 9 | +def type(text): |
10 | 10 | """ |
11 | 11 | Types the given text using the keyboard. |
12 | 12 |
|
@@ -53,6 +53,31 @@ def search(text): |
53 | 53 | return "Open program: " + text |
54 | 54 |
|
55 | 55 |
|
| 56 | +def click(click_detail): |
| 57 | + """ |
| 58 | + Perform a mouse click at the specified coordinates. |
| 59 | +
|
| 60 | + Args: |
| 61 | + click_detail (dict): A dictionary containing the coordinates of the click. |
| 62 | +
|
| 63 | + Returns: |
| 64 | + str: The description of the click if successful, otherwise "We failed to click". |
| 65 | + """ |
| 66 | + try: |
| 67 | + x = convert_percent_to_decimal(click_detail["x"]) |
| 68 | + y = convert_percent_to_decimal(click_detail["y"]) |
| 69 | + |
| 70 | + if click_detail and isinstance(x, float) and isinstance(y, float): |
| 71 | + click_at_percentage(x, y) |
| 72 | + return click_detail["description"] |
| 73 | + else: |
| 74 | + return "We failed to click" |
| 75 | + |
| 76 | + except Exception as e: |
| 77 | + print(f"Error parsing JSON: {e}") |
| 78 | + return "We failed to click" |
| 79 | + |
| 80 | + |
56 | 81 | def click_at_percentage( |
57 | 82 | x_percentage, y_percentage, duration=0.2, circle_radius=50, circle_duration=0.5 |
58 | 83 | ): |
@@ -92,31 +117,6 @@ def click_at_percentage( |
92 | 117 | return "Successfully clicked" |
93 | 118 |
|
94 | 119 |
|
95 | | -def mouse_click(click_detail): |
96 | | - """ |
97 | | - Perform a mouse click at the specified coordinates. |
98 | | -
|
99 | | - Args: |
100 | | - click_detail (dict): A dictionary containing the coordinates of the click. |
101 | | -
|
102 | | - Returns: |
103 | | - str: The description of the click if successful, otherwise "We failed to click". |
104 | | - """ |
105 | | - try: |
106 | | - x = convert_percent_to_decimal(click_detail["x"]) |
107 | | - y = convert_percent_to_decimal(click_detail["y"]) |
108 | | - |
109 | | - if click_detail and isinstance(x, float) and isinstance(y, float): |
110 | | - click_at_percentage(x, y) |
111 | | - return click_detail["description"] |
112 | | - else: |
113 | | - return "We failed to click" |
114 | | - |
115 | | - except Exception as e: |
116 | | - print(f"Error parsing JSON: {e}") |
117 | | - return "We failed to click" |
118 | | - |
119 | | - |
120 | 120 | def get_last_assistant_message(messages): |
121 | 121 | """ |
122 | 122 | Retrieve the last message from the assistant in the messages array. |
|
0 commit comments