21 lines
822 B
Python
21 lines
822 B
Python
import ctypes
|
|
from typing import Dict, Any
|
|
|
|
async def lock_computer(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
"""
|
|
Locks the Windows computer screen using the LockWorkStation API.
|
|
Args:
|
|
args: Dictionary of arguments (not used in this implementation).
|
|
Returns:
|
|
Dictionary with status message and input arguments.
|
|
Raises:
|
|
OSError: If the lock operation fails or the platform is not Windows.
|
|
"""
|
|
try:
|
|
# Use Windows API to lock the screen
|
|
result = ctypes.WinDLL('user32.dll').LockWorkStation()
|
|
if not result:
|
|
raise OSError("Failed to lock the Windows screen")
|
|
return {"message": "Windows screen locked successfully", "args": args}
|
|
except Exception as e:
|
|
raise OSError(f"Error while locking the Windows screen: {str(e)}") |