computer-use-ootb-internal 0.0.173__py3-none-any.whl → 0.0.175__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- computer_use_ootb_internal/app_teachmode.py +641 -636
- computer_use_ootb_internal/computer_use_demo/animation/test_animation.py +39 -39
- computer_use_ootb_internal/computer_use_demo/executor/teachmode_executor.py +6 -0
- computer_use_ootb_internal/computer_use_demo/tools/computer.py +8 -3
- computer_use_ootb_internal/guard_service.py +950 -950
- computer_use_ootb_internal/preparation/powerpoint_prepare.py +73 -90
- computer_use_ootb_internal/preparation/star_rail_prepare.py +99 -99
- computer_use_ootb_internal/run_teachmode_ootb_args.py +235 -227
- computer_use_ootb_internal/service_manager.py +194 -194
- computer_use_ootb_internal/signal_connection.py +47 -47
- computer_use_ootb_internal/test_click_0425.py +57 -57
- {computer_use_ootb_internal-0.0.173.dist-info → computer_use_ootb_internal-0.0.175.dist-info}/METADATA +8 -9
- {computer_use_ootb_internal-0.0.173.dist-info → computer_use_ootb_internal-0.0.175.dist-info}/RECORD +15 -15
- computer_use_ootb_internal-0.0.175.dist-info/entry_points.txt +2 -0
- computer_use_ootb_internal-0.0.173.dist-info/entry_points.txt +0 -4
- {computer_use_ootb_internal-0.0.173.dist-info → computer_use_ootb_internal-0.0.175.dist-info}/WHEEL +0 -0
@@ -1,91 +1,74 @@
|
|
1
|
-
import os
|
2
|
-
import platform
|
3
|
-
import subprocess
|
4
|
-
import logging
|
5
|
-
from pathlib import Path
|
6
|
-
|
7
|
-
log = logging.getLogger(__name__)
|
8
|
-
|
9
|
-
def run_preparation(state):
|
10
|
-
"""
|
11
|
-
Performs environment preparation specific to PowerPoint.
|
12
|
-
Opens a specific template file located on the user's desktop.
|
13
|
-
"""
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
log.
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
log.error(f"Error opening PowerPoint: {result.stderr.strip()}")
|
75
|
-
except Exception as e:
|
76
|
-
log.error(f"Exception opening PowerPoint on Windows: {e}", exc_info=True)
|
77
|
-
|
78
|
-
elif system_platform == "Darwin": # macOS
|
79
|
-
log.info(f"Attempting to open {template_file} with PowerPoint on macOS...")
|
80
|
-
cmd = ['open', '-a', 'Microsoft PowerPoint', str(template_file)]
|
81
|
-
result = subprocess.run(cmd, check=False, capture_output=True, text=True)
|
82
|
-
|
83
|
-
if result.returncode == 0:
|
84
|
-
log.info(f"Successfully opened {template_file} with PowerPoint.")
|
85
|
-
else:
|
86
|
-
log.error(f"Failed to open {template_file} with PowerPoint. Error: {result.stderr.strip()}")
|
87
|
-
else:
|
88
|
-
log.warning(f"Opening PowerPoint on {system_platform} not explicitly supported")
|
89
|
-
|
90
|
-
except Exception as e:
|
1
|
+
import os
|
2
|
+
import platform
|
3
|
+
import subprocess
|
4
|
+
import logging
|
5
|
+
from pathlib import Path
|
6
|
+
|
7
|
+
log = logging.getLogger(__name__)
|
8
|
+
|
9
|
+
def run_preparation(state):
|
10
|
+
"""
|
11
|
+
Performs environment preparation specific to PowerPoint on Windows.
|
12
|
+
Opens a specific template file located on the user's desktop and maximizes the window.
|
13
|
+
"""
|
14
|
+
if platform.system() != "Windows":
|
15
|
+
log.warning("PowerPoint preparation skipped: Not running on Windows.")
|
16
|
+
return
|
17
|
+
|
18
|
+
log.info(f"PowerPoint preparation: Starting on Windows platform...")
|
19
|
+
|
20
|
+
try:
|
21
|
+
# Determine the desktop path for Windows
|
22
|
+
try:
|
23
|
+
username = os.environ.get("USERNAME", "")
|
24
|
+
if not username:
|
25
|
+
log.error("Could not determine Windows username from environment")
|
26
|
+
return
|
27
|
+
|
28
|
+
log.info(f"Using Windows username: {username}")
|
29
|
+
desktop_path = Path(f"C:/Users/{username}/Desktop")
|
30
|
+
|
31
|
+
if not desktop_path.exists():
|
32
|
+
log.error(f"Desktop path not found at: {desktop_path}")
|
33
|
+
alt_path = Path(f"C:/Documents and Settings/{username}/Desktop")
|
34
|
+
if alt_path.exists():
|
35
|
+
desktop_path = alt_path
|
36
|
+
log.info(f"Using alternative desktop path: {desktop_path}")
|
37
|
+
else:
|
38
|
+
log.error("Failed to find user's desktop directory")
|
39
|
+
return
|
40
|
+
|
41
|
+
except Exception as e:
|
42
|
+
log.error(f"Error determining Windows user desktop: {e}", exc_info=True)
|
43
|
+
return
|
44
|
+
|
45
|
+
# Construct path to template file
|
46
|
+
template_file = desktop_path / "template.pptx"
|
47
|
+
log.info(f"Looking for template file at: {template_file}")
|
48
|
+
|
49
|
+
if not template_file.exists():
|
50
|
+
log.error(f"Template file not found at: {template_file}")
|
51
|
+
return
|
52
|
+
|
53
|
+
# Open the file with PowerPoint maximized on Windows
|
54
|
+
log.info(f"Attempting to open {template_file} with PowerPoint maximized on Windows...")
|
55
|
+
try:
|
56
|
+
# Use start command with /max flag on Windows
|
57
|
+
cmd = ['cmd', '/c', 'start', '/max', 'powerpnt', str(template_file)]
|
58
|
+
result = subprocess.run(cmd, check=False, capture_output=True, text=True)
|
59
|
+
|
60
|
+
if result.returncode == 0:
|
61
|
+
log.info(f"Successfully launched PowerPoint maximized with {template_file}")
|
62
|
+
else:
|
63
|
+
# Log stderr for debugging potential start command issues
|
64
|
+
log.error(f"Error opening PowerPoint: {result.stderr.strip()}")
|
65
|
+
# Also log stdout as start command might output info there
|
66
|
+
if result.stdout:
|
67
|
+
log.error(f"Stdout from start command: {result.stdout.strip()}")
|
68
|
+
except FileNotFoundError:
|
69
|
+
log.error("Error: 'cmd' or 'start' command not found. Ensure system PATH is configured correctly.")
|
70
|
+
except Exception as e:
|
71
|
+
log.error(f"Exception opening PowerPoint on Windows: {e}", exc_info=True)
|
72
|
+
|
73
|
+
except Exception as e:
|
91
74
|
log.error(f"An unexpected error occurred during PowerPoint preparation: {e}", exc_info=True)
|
@@ -1,100 +1,100 @@
|
|
1
|
-
# src/computer_use_ootb_internal/preparation/star_rail_prepare.py
|
2
|
-
import time
|
3
|
-
import platform
|
4
|
-
import subprocess # Added for taskkill
|
5
|
-
import pyautogui
|
6
|
-
import webbrowser
|
7
|
-
import logging # Use logging instead of print for better practice
|
8
|
-
|
9
|
-
# Set up logging for this module if needed, or rely on root logger
|
10
|
-
log = logging.getLogger(__name__)
|
11
|
-
|
12
|
-
def run_preparation(state):
|
13
|
-
"""
|
14
|
-
Performs environment preparation specific to Star Rail on Windows.
|
15
|
-
Closes existing Edge browsers, opens the specified URL in a new Edge instance,
|
16
|
-
and performs initial clicks.
|
17
|
-
"""
|
18
|
-
if platform.system() != "Windows":
|
19
|
-
log.info("Star Rail preparation skipped: Not running on Windows.")
|
20
|
-
return
|
21
|
-
|
22
|
-
log.info("Star Rail preparation: Starting environment setup on Windows...")
|
23
|
-
url = "https://sr.mihoyo.com/cloud/#/" # Consider making this configurable later
|
24
|
-
browser_opened = False
|
25
|
-
try:
|
26
|
-
# Attempt to close existing Microsoft Edge processes
|
27
|
-
log.info("Attempting to close existing Microsoft Edge processes...")
|
28
|
-
try:
|
29
|
-
# /F forces termination, /IM specifies image name
|
30
|
-
result = subprocess.run(['taskkill', '/F', '/IM', 'msedge.exe'],
|
31
|
-
capture_output=True, text=True, check=False)
|
32
|
-
if result.returncode == 0:
|
33
|
-
log.info("Successfully sent termination signal to msedge.exe processes.")
|
34
|
-
elif "not found" in result.stderr.lower() or "not found" in result.stdout.lower():
|
35
|
-
log.info("No running msedge.exe processes found to close.")
|
36
|
-
else:
|
37
|
-
log.warning(f"taskkill command finished with return code {result.returncode}. Output: {result.stdout} Stderr: {result.stderr}")
|
38
|
-
time.sleep(2) # Give processes time to close
|
39
|
-
except FileNotFoundError:
|
40
|
-
log.error("Error: 'taskkill' command not found. Make sure it's in the system PATH.")
|
41
|
-
except Exception as e:
|
42
|
-
log.error(f"Error occurred while trying to close Edge: {e}", exc_info=True)
|
43
|
-
|
44
|
-
# Use only webbrowser.open
|
45
|
-
log.info(f"Attempting to open {url} using webbrowser.open()...")
|
46
|
-
if webbrowser.open(url):
|
47
|
-
log.info(f"Successfully requested browser to open {url} via webbrowser.open().")
|
48
|
-
browser_opened = True
|
49
|
-
# Ensure sleep time for browser load before clicks is present
|
50
|
-
time.sleep(5)
|
51
|
-
else:
|
52
|
-
log.warning("webbrowser.open() returned False, indicating potential failure.")
|
53
|
-
|
54
|
-
if not browser_opened:
|
55
|
-
log.error("Failed to confirm browser opening via webbrowser.open(). Will still attempt clicks.")
|
56
|
-
|
57
|
-
# Add pyautogui click after attempting to open the browser
|
58
|
-
log.info("Proceeding with pyautogui actions...")
|
59
|
-
time.sleep(5) # Wait time for the browser to load
|
60
|
-
|
61
|
-
# Get screen size
|
62
|
-
screen_width, screen_height = pyautogui.size()
|
63
|
-
log.info(f"Detected screen size: {screen_width}x{screen_height}")
|
64
|
-
|
65
|
-
# Calculate click coordinates based on a reference resolution (e.g., 1280x720)
|
66
|
-
# TODO: Make these coordinates more robust or configurable
|
67
|
-
click_x_1 = int(screen_width * (1036 / 1280))
|
68
|
-
click_y_1 = int(screen_height * (500 / 720))
|
69
|
-
log.info(f"Calculated click coordinates for starting the game: ({click_x_1}, {click_y_1})")
|
70
|
-
click_x_2 = int(screen_width * (1233 / 1280))
|
71
|
-
click_y_2 = int(screen_height * (30 / 720))
|
72
|
-
log.info(f"Calculated click coordinates for closing the browser warning: ({click_x_2}, {click_y_2})")
|
73
|
-
|
74
|
-
# Disable failsafe before clicking
|
75
|
-
pyautogui.FAILSAFE = False
|
76
|
-
log.info("PyAutoGUI failsafe temporarily disabled.")
|
77
|
-
|
78
|
-
log.info(f"Clicking at coordinates: ({click_x_1}, {click_y_1})")
|
79
|
-
pyautogui.click(click_x_1, click_y_1)
|
80
|
-
time.sleep(2)
|
81
|
-
pyautogui.click(click_x_1, click_y_1) # Double click?
|
82
|
-
|
83
|
-
# Press F11 to attempt fullscreen
|
84
|
-
log.info("Pressing F11 to enter fullscreen...")
|
85
|
-
time.sleep(1) # Short delay before pressing F11
|
86
|
-
pyautogui.press('f11')
|
87
|
-
time.sleep(1)
|
88
|
-
log.info(f"Clicking at coordinates: ({click_x_2}, {click_y_2})")
|
89
|
-
pyautogui.click(click_x_2, click_y_2)
|
90
|
-
time.sleep(1)
|
91
|
-
pyautogui.click(click_x_2, click_y_2)
|
92
|
-
|
93
|
-
log.info("Star Rail preparation clicks completed.")
|
94
|
-
|
95
|
-
except Exception as e:
|
96
|
-
log.error(f"Error during Star Rail preparation (browser/click): {e}", exc_info=True)
|
97
|
-
finally:
|
98
|
-
# Ensure failsafe is re-enabled
|
99
|
-
pyautogui.FAILSAFE = True
|
1
|
+
# src/computer_use_ootb_internal/preparation/star_rail_prepare.py
|
2
|
+
import time
|
3
|
+
import platform
|
4
|
+
import subprocess # Added for taskkill
|
5
|
+
import pyautogui
|
6
|
+
import webbrowser
|
7
|
+
import logging # Use logging instead of print for better practice
|
8
|
+
|
9
|
+
# Set up logging for this module if needed, or rely on root logger
|
10
|
+
log = logging.getLogger(__name__)
|
11
|
+
|
12
|
+
def run_preparation(state):
|
13
|
+
"""
|
14
|
+
Performs environment preparation specific to Star Rail on Windows.
|
15
|
+
Closes existing Edge browsers, opens the specified URL in a new Edge instance,
|
16
|
+
and performs initial clicks.
|
17
|
+
"""
|
18
|
+
if platform.system() != "Windows":
|
19
|
+
log.info("Star Rail preparation skipped: Not running on Windows.")
|
20
|
+
return
|
21
|
+
|
22
|
+
log.info("Star Rail preparation: Starting environment setup on Windows...")
|
23
|
+
url = "https://sr.mihoyo.com/cloud/#/" # Consider making this configurable later
|
24
|
+
browser_opened = False
|
25
|
+
try:
|
26
|
+
# Attempt to close existing Microsoft Edge processes
|
27
|
+
log.info("Attempting to close existing Microsoft Edge processes...")
|
28
|
+
try:
|
29
|
+
# /F forces termination, /IM specifies image name
|
30
|
+
result = subprocess.run(['taskkill', '/F', '/IM', 'msedge.exe'],
|
31
|
+
capture_output=True, text=True, check=False)
|
32
|
+
if result.returncode == 0:
|
33
|
+
log.info("Successfully sent termination signal to msedge.exe processes.")
|
34
|
+
elif "not found" in result.stderr.lower() or "not found" in result.stdout.lower():
|
35
|
+
log.info("No running msedge.exe processes found to close.")
|
36
|
+
else:
|
37
|
+
log.warning(f"taskkill command finished with return code {result.returncode}. Output: {result.stdout} Stderr: {result.stderr}")
|
38
|
+
time.sleep(2) # Give processes time to close
|
39
|
+
except FileNotFoundError:
|
40
|
+
log.error("Error: 'taskkill' command not found. Make sure it's in the system PATH.")
|
41
|
+
except Exception as e:
|
42
|
+
log.error(f"Error occurred while trying to close Edge: {e}", exc_info=True)
|
43
|
+
|
44
|
+
# Use only webbrowser.open
|
45
|
+
log.info(f"Attempting to open {url} using webbrowser.open()...")
|
46
|
+
if webbrowser.open(url):
|
47
|
+
log.info(f"Successfully requested browser to open {url} via webbrowser.open().")
|
48
|
+
browser_opened = True
|
49
|
+
# Ensure sleep time for browser load before clicks is present
|
50
|
+
time.sleep(5)
|
51
|
+
else:
|
52
|
+
log.warning("webbrowser.open() returned False, indicating potential failure.")
|
53
|
+
|
54
|
+
if not browser_opened:
|
55
|
+
log.error("Failed to confirm browser opening via webbrowser.open(). Will still attempt clicks.")
|
56
|
+
|
57
|
+
# Add pyautogui click after attempting to open the browser
|
58
|
+
log.info("Proceeding with pyautogui actions...")
|
59
|
+
time.sleep(5) # Wait time for the browser to load
|
60
|
+
|
61
|
+
# Get screen size
|
62
|
+
screen_width, screen_height = pyautogui.size()
|
63
|
+
log.info(f"Detected screen size: {screen_width}x{screen_height}")
|
64
|
+
|
65
|
+
# Calculate click coordinates based on a reference resolution (e.g., 1280x720)
|
66
|
+
# TODO: Make these coordinates more robust or configurable
|
67
|
+
click_x_1 = int(screen_width * (1036 / 1280))
|
68
|
+
click_y_1 = int(screen_height * (500 / 720))
|
69
|
+
log.info(f"Calculated click coordinates for starting the game: ({click_x_1}, {click_y_1})")
|
70
|
+
click_x_2 = int(screen_width * (1233 / 1280))
|
71
|
+
click_y_2 = int(screen_height * (30 / 720))
|
72
|
+
log.info(f"Calculated click coordinates for closing the browser warning: ({click_x_2}, {click_y_2})")
|
73
|
+
|
74
|
+
# Disable failsafe before clicking
|
75
|
+
pyautogui.FAILSAFE = False
|
76
|
+
log.info("PyAutoGUI failsafe temporarily disabled.")
|
77
|
+
|
78
|
+
log.info(f"Clicking at coordinates: ({click_x_1}, {click_y_1})")
|
79
|
+
pyautogui.click(click_x_1, click_y_1)
|
80
|
+
time.sleep(2)
|
81
|
+
pyautogui.click(click_x_1, click_y_1) # Double click?
|
82
|
+
|
83
|
+
# Press F11 to attempt fullscreen
|
84
|
+
log.info("Pressing F11 to enter fullscreen...")
|
85
|
+
time.sleep(1) # Short delay before pressing F11
|
86
|
+
pyautogui.press('f11')
|
87
|
+
time.sleep(1)
|
88
|
+
log.info(f"Clicking at coordinates: ({click_x_2}, {click_y_2})")
|
89
|
+
pyautogui.click(click_x_2, click_y_2)
|
90
|
+
time.sleep(1)
|
91
|
+
pyautogui.click(click_x_2, click_y_2)
|
92
|
+
|
93
|
+
log.info("Star Rail preparation clicks completed.")
|
94
|
+
|
95
|
+
except Exception as e:
|
96
|
+
log.error(f"Error during Star Rail preparation (browser/click): {e}", exc_info=True)
|
97
|
+
finally:
|
98
|
+
# Ensure failsafe is re-enabled
|
99
|
+
pyautogui.FAILSAFE = True
|
100
100
|
log.info("PyAutoGUI failsafe re-enabled.")
|