computer-use-ootb-internal 0.0.126__py3-none-any.whl → 0.0.127__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.
@@ -135,37 +135,37 @@ class GuardService(win32serviceutil.ServiceFramework):
135
135
 
136
136
  # --- Instance Helper Methods (Moved from module level) ---
137
137
  def get_base_python_executable(self):
138
- """Tries to find python.exe instead of pythonservice.exe if running as service."""
138
+ """Tries to find pythonw.exe or python.exe instead of pythonservice.exe if running as service."""
139
139
  service_exe = sys.executable
140
140
  self.log_info(f"get_base_python_executable: sys.executable is {service_exe}")
141
- # Normalize path for comparison
142
141
  service_exe_lower = service_exe.lower()
143
-
144
- # Check if running as pythonservice.exe
142
+ final_exe_to_use = service_exe # Default to sys.executable
143
+
145
144
  if 'pythonservice.exe' in os.path.basename(service_exe_lower):
146
- # Construct expected python.exe path in the same directory
147
145
  dir_name = os.path.dirname(service_exe)
146
+ potential_pythonw_exe = os.path.join(dir_name, 'pythonw.exe')
148
147
  potential_python_exe = os.path.join(dir_name, 'python.exe')
149
- self.log_info(f"get_base_python_executable: Checking for python.exe at {potential_python_exe}")
150
148
 
151
- if os.path.exists(potential_python_exe):
152
- self.log_info(f"get_base_python_executable: Found python.exe at {potential_python_exe}")
153
- # Quote if necessary
154
- final_exe = potential_python_exe
155
- if " " in final_exe and not final_exe.startswith('"'):
156
- return f'"{final_exe}"'
157
- return final_exe
149
+ self.log_info(f"get_base_python_executable: Checking for pythonw.exe at {potential_pythonw_exe}")
150
+ if os.path.exists(potential_pythonw_exe):
151
+ self.log_info(f"get_base_python_executable: Found pythonw.exe, preferring it.")
152
+ final_exe_to_use = potential_pythonw_exe
158
153
  else:
159
- self.log_error(f"get_base_python_executable: Could not find python.exe near pythonservice.exe (checked {potential_python_exe}). Falling back to using {service_exe}.")
160
- # Fallback to original sys.executable (quoted if needed)
161
- if " " in service_exe and not service_exe.startswith('"'):
162
- return f'"{service_exe}"'
163
- return service_exe
164
- else: # Not running as pythonservice.exe, assume sys.executable is correct
154
+ self.log_info(f"get_base_python_executable: pythonw.exe not found. Checking for python.exe at {potential_python_exe}")
155
+ if os.path.exists(potential_python_exe):
156
+ self.log_info(f"get_base_python_executable: Found python.exe.")
157
+ final_exe_to_use = potential_python_exe
158
+ else:
159
+ self.log_error(f"get_base_python_executable: Could not find pythonw.exe or python.exe near pythonservice.exe. Falling back to using {service_exe}.")
160
+ # Keep final_exe_to_use as service_exe (default)
161
+ else:
165
162
  self.log_info(f"get_base_python_executable: sys.executable is not pythonservice.exe, using it directly.")
166
- if " " in service_exe and not service_exe.startswith('"'):
167
- return f'"{service_exe}"'
168
- return service_exe
163
+ # Keep final_exe_to_use as service_exe (default)
164
+
165
+ # Quote the final selected path if necessary
166
+ if " " in final_exe_to_use and not final_exe_to_use.startswith('"'):
167
+ return f'"{final_exe_to_use}"'
168
+ return final_exe_to_use
169
169
 
170
170
  def get_python_executable(self):
171
171
  # This method is now just an alias for clarity if needed elsewhere,
@@ -1,7 +1,7 @@
1
1
  # src/computer_use_ootb_internal/preparation/star_rail_prepare.py
2
2
  import time
3
3
  import platform
4
- import subprocess # Added for taskkill
4
+ import pyautogui
5
5
  import webbrowser
6
6
  import logging # Use logging instead of print for better practice
7
7
 
@@ -11,7 +11,7 @@ log = logging.getLogger(__name__)
11
11
  def run_preparation(state):
12
12
  """
13
13
  Performs environment preparation specific to Star Rail on Windows.
14
- Closes existing Edge browsers and opens the specified URL in a new Edge instance.
14
+ Opens the specified URL in Edge and performs initial clicks.
15
15
  """
16
16
  if platform.system() != "Windows":
17
17
  log.info("Star Rail preparation skipped: Not running on Windows.")
@@ -21,43 +21,45 @@ def run_preparation(state):
21
21
  url = "https://sr.mihoyo.com/cloud/#/" # Consider making this configurable later
22
22
  browser_opened = False
23
23
  try:
24
- # Attempt to close existing Microsoft Edge processes
25
- log.info("Attempting to close existing Microsoft Edge processes...")
26
- try:
27
- # /F forces termination, /IM specifies image name
28
- result = subprocess.run(['taskkill', '/F', '/IM', 'msedge.exe'],
29
- capture_output=True, text=True, check=False)
30
- if result.returncode == 0:
31
- log.info("Successfully sent termination signal to msedge.exe processes.")
32
- elif "not found" in result.stderr.lower() or "not found" in result.stdout.lower():
33
- log.info("No running msedge.exe processes found to close.")
34
- else:
35
- log.warning(f"taskkill command finished with return code {result.returncode}. Output: {result.stdout} Stderr: {result.stderr}")
36
- time.sleep(2) # Give processes time to close
37
- except FileNotFoundError:
38
- log.error("Error: 'taskkill' command not found. Make sure it's in the system PATH.")
39
- except Exception as e:
40
- log.error(f"Error occurred while trying to close Edge: {e}", exc_info=True)
41
-
42
-
43
24
  # Use only webbrowser.open
44
25
  log.info(f"Attempting to open {url} using webbrowser.open()...")
45
26
  if webbrowser.open(url):
46
27
  log.info(f"Successfully requested browser to open {url} via webbrowser.open().")
47
28
  browser_opened = True
48
- time.sleep(5) # Wait time for the browser to potentially load the page
49
29
  else:
50
30
  log.warning("webbrowser.open() returned False, indicating potential failure.")
51
- # No need to error out completely if browser *request* failed,
52
- # but it's unlikely the rest of the process would work.
53
31
 
54
32
  if not browser_opened:
55
- log.error("Failed to confirm browser opening via webbrowser.open().")
33
+ log.error("Failed to confirm browser opening via webbrowser.open(). Will still attempt clicks.")
34
+
35
+ # Add pyautogui click after attempting to open the browser
36
+ log.info("Proceeding with pyautogui actions...")
37
+ time.sleep(5) # Wait time for the browser to load
38
+
39
+ # Get screen size
40
+ screen_width, screen_height = pyautogui.size()
41
+ log.info(f"Detected screen size: {screen_width}x{screen_height}")
42
+
43
+ # Calculate click coordinates based on a reference resolution (e.g., 1280x720)
44
+ # TODO: Make these coordinates more robust or configurable
45
+ click_x = int(screen_width * (1036 / 1280))
46
+ click_y = int(screen_height * (500 / 720))
47
+ log.info(f"Calculated click coordinates: ({click_x}, {click_y})")
48
+
49
+ # Disable failsafe before clicking
50
+ pyautogui.FAILSAFE = False
51
+ log.info("PyAutoGUI failsafe temporarily disabled.")
56
52
 
57
- # Removed pyautogui click logic
53
+ log.info(f"Clicking at coordinates: ({click_x}, {click_y})")
54
+ pyautogui.click(click_x, click_y)
55
+ time.sleep(2)
56
+ pyautogui.click(click_x, click_y) # Double click?
58
57
 
59
- log.info("Star Rail preparation completed (browser opened).")
58
+ log.info("Star Rail preparation clicks completed.")
60
59
 
61
60
  except Exception as e:
62
- log.error(f"Error during Star Rail preparation: {e}", exc_info=True)
63
- # No finally block needed anymore as pyautogui failsafe is removed
61
+ log.error(f"Error during Star Rail preparation (browser/click): {e}", exc_info=True)
62
+ finally:
63
+ # Ensure failsafe is re-enabled
64
+ pyautogui.FAILSAFE = True
65
+ log.info("PyAutoGUI failsafe re-enabled.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: computer-use-ootb-internal
3
- Version: 0.0.126
3
+ Version: 0.0.127
4
4
  Summary: Computer Use OOTB
5
5
  Author-email: Siyuan Hu <siyuan.hu.sg@gmail.com>
6
6
  Requires-Python: >=3.11
@@ -2,7 +2,7 @@ computer_use_ootb_internal/README.md,sha256=FxpW95lyub2iX73ZDfK6ML7SdEKg060H5I6G
2
2
  computer_use_ootb_internal/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
3
3
  computer_use_ootb_internal/app_teachmode.py,sha256=ZZW98870QPNK76LN4f4k9RjBELYcF_3hl0w0fvxj3dY,22268
4
4
  computer_use_ootb_internal/dependency_check.py,sha256=y8RMEP6RXQzTgU1MS_1piBLtz4J-Hfn9RjUZg59dyvo,1333
5
- computer_use_ootb_internal/guard_service.py,sha256=rxTdjzhcZf-Osohnf9xnKFTiKUr-DJAgFHPEGfmFDVI,42789
5
+ computer_use_ootb_internal/guard_service.py,sha256=5wmestMg86e-TxnUVRLdDOTzJ7tOB1R0YoxMO8UjEhs,42829
6
6
  computer_use_ootb_internal/requirements-lite.txt,sha256=5DAHomz4A_P2BmTIXNkNqkHbnIF0AyZ4_1XAlb1LaYs,290
7
7
  computer_use_ootb_internal/run_teachmode_ootb_args.py,sha256=HB7L9vuIPUXVqeTicyNJKArzTNAfgdpsyO3JEzmByIo,7315
8
8
  computer_use_ootb_internal/service_manager.py,sha256=SD8jzfn0VVXBOr_nP6zmBWSC2TzrU_sp2e5JJkSlQFU,9734
@@ -32,8 +32,8 @@ computer_use_ootb_internal/computer_use_demo/tools/edit.py,sha256=b0PwUitxckHCQq
32
32
  computer_use_ootb_internal/computer_use_demo/tools/run.py,sha256=xhXdnBK1di9muaO44CEirL9hpGy3NmKbjfMpyeVmn8Y,1595
33
33
  computer_use_ootb_internal/computer_use_demo/tools/screen_capture.py,sha256=L8qfvtUkPPQGt92N-2Zfw5ZTDBzLsDps39uMnX3_uSA,6857
34
34
  computer_use_ootb_internal/preparation/__init__.py,sha256=AgtGHcBpiTkxJjF0xwcs3yyQ6SyUvhL3G0vD2XO-zJw,63
35
- computer_use_ootb_internal/preparation/star_rail_prepare.py,sha256=2Q1TcXE09F1-W7boTHfuQkGhaFD1YDuiQV8qvG83wOY,3000
36
- computer_use_ootb_internal-0.0.126.dist-info/METADATA,sha256=COh06SOLvlusAtDfKXDv5Rr_hxHwNgrSSQEI-qlcZW8,1048
37
- computer_use_ootb_internal-0.0.126.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
- computer_use_ootb_internal-0.0.126.dist-info/entry_points.txt,sha256=bXfyAU_qq-G1EiEgAQEioXvgEdRCFxaTooqdDD9Y4OA,258
39
- computer_use_ootb_internal-0.0.126.dist-info/RECORD,,
35
+ computer_use_ootb_internal/preparation/star_rail_prepare.py,sha256=s1VWszcTnJAKxqCHFlaOEwPkqVSrkiFx_yKpWSnSbHs,2649
36
+ computer_use_ootb_internal-0.0.127.dist-info/METADATA,sha256=gHp7WyAKyY3ctWvSuT1acMWsvqpxfnVQozEleBI15uI,1048
37
+ computer_use_ootb_internal-0.0.127.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
+ computer_use_ootb_internal-0.0.127.dist-info/entry_points.txt,sha256=bXfyAU_qq-G1EiEgAQEioXvgEdRCFxaTooqdDD9Y4OA,258
39
+ computer_use_ootb_internal-0.0.127.dist-info/RECORD,,