close_window
Close a specific window by its title to manage desktop applications and free up system resources.
Instructions
关闭指定窗口
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | 窗口标题 |
Implementation Reference
- src/tools/window.js:203-218 (handler)The main handler function that executes the close_window tool logic: finds processes matching the window title using PowerShell and closes their main window.async closeWindow(title) { try { // 使用 taskkill 通过窗口标题关闭 const script = ` $processes = Get-Process | Where-Object { $_.MainWindowTitle -like "*${title}*" } foreach ($proc in $processes) { $proc.CloseMainWindow() | Out-Null } `; await execAsync(`powershell -Command "${script}"`, { shell: 'powershell.exe' }); return { success: true, window: title, message: '窗口已关闭' }; } catch (error) { return { success: false, error: error.message }; } }
- src/tools/window.js:41-51 (schema)Schema definition for the close_window tool, including name, description, and input schema requiring a 'title' string.{ name: 'close_window', description: '关闭指定窗口', inputSchema: { type: 'object', properties: { title: { type: 'string', description: '窗口标题' }, }, required: ['title'], }, },
- src/tools/window.js:91-92 (registration)Tool registration in the executeTool switch statement, dispatching close_window calls to the closeWindow handler.case 'close_window': return await this.closeWindow(args.title);
- src/tools/window.js:78-80 (registration)Includes 'close_window' in the list of supported tools checked by canHandle method.const tools = ['list_windows', 'get_active_window', 'activate_window', 'close_window', 'minimize_window', 'maximize_window']; return tools.includes(toolName);