computer-use-ootb-internal 0.0.134__py3-none-any.whl → 0.0.136__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/guard_service.py +20 -31
- computer_use_ootb_internal/preparation/star_rail_prepare.py +23 -1
- {computer_use_ootb_internal-0.0.134.dist-info → computer_use_ootb_internal-0.0.136.dist-info}/METADATA +1 -1
- {computer_use_ootb_internal-0.0.134.dist-info → computer_use_ootb_internal-0.0.136.dist-info}/RECORD +6 -6
- {computer_use_ootb_internal-0.0.134.dist-info → computer_use_ootb_internal-0.0.136.dist-info}/WHEEL +0 -0
- {computer_use_ootb_internal-0.0.134.dist-info → computer_use_ootb_internal-0.0.136.dist-info}/entry_points.txt +0 -0
@@ -703,13 +703,14 @@ class GuardService(win32serviceutil.ServiceFramework):
|
|
703
703
|
return "failed_exception"
|
704
704
|
|
705
705
|
def create_or_update_logon_task(self, username):
|
706
|
-
"""Creates/updates task to run OOTB app via cmd /K on session connect
|
706
|
+
"""Creates/updates task to run OOTB app via cmd /K on session connect/reconnect."""
|
707
707
|
if not self.target_executable_path:
|
708
708
|
self.log_error(f"Cannot create task for {username}: Target executable path is not set.")
|
709
709
|
return False
|
710
710
|
|
711
|
-
task_name = f"OOTB_UserConnect_{username}"
|
712
|
-
|
711
|
+
task_name = f"OOTB_UserConnect_{username}"
|
712
|
+
# Action: Revert to running the actual executable via cmd /K
|
713
|
+
action_executable = 'cmd.exe'
|
713
714
|
action_arguments = f'/K "{self.target_executable_path}"'
|
714
715
|
safe_action_executable = action_executable.replace("'", "''")
|
715
716
|
safe_action_arguments = action_arguments.replace("'", "''")
|
@@ -717,55 +718,43 @@ class GuardService(win32serviceutil.ServiceFramework):
|
|
717
718
|
# Explicitly set the working directory to the executable's location
|
718
719
|
try:
|
719
720
|
executable_dir = os.path.dirname(self.target_executable_path.strip('"'))
|
720
|
-
if not executable_dir:
|
721
|
-
executable_dir = "." # Use current directory as fallback?
|
722
|
-
self.log_warning(f"Could not determine directory for {self.target_executable_path}, task WorkingDirectory might be incorrect.")
|
721
|
+
if not executable_dir: executable_dir = "."
|
723
722
|
safe_working_directory = executable_dir.replace("'", "''")
|
724
723
|
working_directory_setting = f"$action.WorkingDirectory = '{safe_working_directory}'"
|
725
724
|
except Exception as e:
|
726
|
-
self.log_error(f"Error determining working directory for task: {e}.
|
727
|
-
working_directory_setting = "# Could not set WorkingDirectory"
|
725
|
+
self.log_error(f"Error determining working directory for task: {e}. WD will not be set.")
|
726
|
+
working_directory_setting = "# Could not set WorkingDirectory"
|
728
727
|
|
729
728
|
# PowerShell command construction
|
730
729
|
ps_command = f"""
|
731
730
|
$taskName = "{task_name}"
|
732
731
|
$principal = New-ScheduledTaskPrincipal -UserId "{username}" -LogonType Interactive
|
733
732
|
|
734
|
-
# Action: Run
|
733
|
+
# Action: Run the OOTB executable via cmd /K
|
735
734
|
$action = New-ScheduledTaskAction -Execute '{safe_action_executable}' -Argument '{safe_action_arguments}'
|
736
|
-
{working_directory_setting}
|
735
|
+
{working_directory_setting} # Set the working directory
|
737
736
|
|
738
|
-
#
|
737
|
+
# Triggers: On session connect (21) AND reconnect (25)
|
739
738
|
$logName = 'Microsoft-Windows-TerminalServices-LocalSessionManager/Operational'
|
740
739
|
$source = 'Microsoft-Windows-TerminalServices-LocalSessionManager'
|
741
|
-
|
742
|
-
|
743
|
-
$
|
744
|
-
#
|
745
|
-
# $
|
746
|
-
#
|
747
|
-
$trigger = New-ScheduledTaskTrigger -Event -LogName $logName -Source $source -EventId $eventIDs[0] -Delay 'PT15S' # Primary trigger with delay
|
748
|
-
# Register additional triggers if needed, or handle logic differently.
|
749
|
-
# For simplicity, let's try one event trigger first (ID 21). If reconnect (25) is needed, we can add it.
|
750
|
-
# Consider adding delay: -Delay 'PT15S' # Delay 15 seconds after event?
|
740
|
+
# Define multiple triggers
|
741
|
+
$trigger1 = New-ScheduledTaskTrigger -Event -LogName $logName -Source $source -EventId 21
|
742
|
+
$trigger2 = New-ScheduledTaskTrigger -Event -LogName $logName -Source $source -EventId 25
|
743
|
+
# Optional Delay - Apply to both triggers if desired?
|
744
|
+
# $trigger1.Delay = 'PT15S'
|
745
|
+
# $trigger2.Delay = 'PT15S'
|
751
746
|
|
752
747
|
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Days 9999) -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1)
|
753
|
-
$description = "Runs OOTB Application (via cmd) for user {username} upon session connect
|
748
|
+
$description = "Runs OOTB Application (via cmd) for user {username} upon session connect/reconnect." # Updated description
|
754
749
|
|
755
750
|
# Unregister existing task first (force) - Use the NEW task name
|
756
751
|
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
|
757
752
|
|
758
|
-
# Register the new task
|
759
|
-
Register-ScheduledTask -TaskName $taskName -Principal $principal -Action $action -Trigger $
|
760
|
-
|
761
|
-
# Optional: Add second trigger for event ID 25 (Reconnect)
|
762
|
-
# Requires creating a separate trigger object and adding it.
|
763
|
-
# $trigger2 = New-ScheduledTaskTrigger -Event -LogName $logName -Source $source -EventId $eventIDs[1]
|
764
|
-
# Set-ScheduledTask -TaskName $taskName -Trigger $trigger, $trigger2 # This replaces existing triggers
|
765
|
-
# Append trigger is more complex via PowerShell cmdlets, often easier via XML or COM
|
753
|
+
# Register the new task with MULTIPLE triggers
|
754
|
+
Register-ScheduledTask -TaskName $taskName -Principal $principal -Action $action -Trigger $trigger1, $trigger2 -Settings $settings -Description $description -Force
|
766
755
|
|
767
756
|
"""
|
768
|
-
self.log_info(f"Attempting to create/update task '{task_name}' for user '{username}' to run
|
757
|
+
self.log_info(f"Attempting to create/update task '{task_name}' for user '{username}' to run OOTB on session connect/reconnect.")
|
769
758
|
try:
|
770
759
|
# Need to actually run the powershell command here!
|
771
760
|
success = self.run_powershell_command(ps_command)
|
@@ -1,6 +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
5
|
import pyautogui
|
5
6
|
import webbrowser
|
6
7
|
import logging # Use logging instead of print for better practice
|
@@ -11,7 +12,8 @@ log = logging.getLogger(__name__)
|
|
11
12
|
def run_preparation(state):
|
12
13
|
"""
|
13
14
|
Performs environment preparation specific to Star Rail on Windows.
|
14
|
-
|
15
|
+
Closes existing Edge browsers, opens the specified URL in a new Edge instance,
|
16
|
+
and performs initial clicks.
|
15
17
|
"""
|
16
18
|
if platform.system() != "Windows":
|
17
19
|
log.info("Star Rail preparation skipped: Not running on Windows.")
|
@@ -21,11 +23,31 @@ def run_preparation(state):
|
|
21
23
|
url = "https://sr.mihoyo.com/cloud/#/" # Consider making this configurable later
|
22
24
|
browser_opened = False
|
23
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
|
+
|
24
44
|
# Use only webbrowser.open
|
25
45
|
log.info(f"Attempting to open {url} using webbrowser.open()...")
|
26
46
|
if webbrowser.open(url):
|
27
47
|
log.info(f"Successfully requested browser to open {url} via webbrowser.open().")
|
28
48
|
browser_opened = True
|
49
|
+
# Keep original sleep time for browser load before clicks
|
50
|
+
time.sleep(5)
|
29
51
|
else:
|
30
52
|
log.warning("webbrowser.open() returned False, indicating potential failure.")
|
31
53
|
|
{computer_use_ootb_internal-0.0.134.dist-info → computer_use_ootb_internal-0.0.136.dist-info}/RECORD
RENAMED
@@ -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=
|
5
|
+
computer_use_ootb_internal/guard_service.py,sha256=T0j18PIbeHMTrV4myQX8DRobrL5ysi3HGraCAGrUykw,44652
|
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=
|
36
|
-
computer_use_ootb_internal-0.0.
|
37
|
-
computer_use_ootb_internal-0.0.
|
38
|
-
computer_use_ootb_internal-0.0.
|
39
|
-
computer_use_ootb_internal-0.0.
|
35
|
+
computer_use_ootb_internal/preparation/star_rail_prepare.py,sha256=Q6P9WuhtK6gNfYcHQqRGBY0XfD6vKr0f7oGknZ4Ac6I,3979
|
36
|
+
computer_use_ootb_internal-0.0.136.dist-info/METADATA,sha256=BcPCfVBrZVzGvuhk6-v8JWlgI2ojMApI8OXWUDkBN44,1048
|
37
|
+
computer_use_ootb_internal-0.0.136.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
38
|
+
computer_use_ootb_internal-0.0.136.dist-info/entry_points.txt,sha256=bXfyAU_qq-G1EiEgAQEioXvgEdRCFxaTooqdDD9Y4OA,258
|
39
|
+
computer_use_ootb_internal-0.0.136.dist-info/RECORD,,
|
{computer_use_ootb_internal-0.0.134.dist-info → computer_use_ootb_internal-0.0.136.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|