activate_window
Brings a specified window to the foreground by matching its title, enabling quick switching between open applications on Windows.
Instructions
激活指定窗口(通过标题)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | 窗口标题(支持部分匹配) |
Implementation Reference
- src/tools/window.js:189-201 (handler)The handler function that implements the activate_window tool logic using PowerShell WScript.Shell to activate the window by title.async activateWindow(title) { try { const script = ` $wshell = New-Object -ComObject wscript.shell $wshell.AppActivate("${title}") `; 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:30-40 (schema)Input schema for the activate_window tool, defining the required 'title' parameter.{ name: 'activate_window', description: '激活指定窗口(通过标题)', inputSchema: { type: 'object', properties: { title: { type: 'string', description: '窗口标题(支持部分匹配)' }, }, required: ['title'], }, },
- src/tools/window.js:89-90 (registration)Registration and dispatch logic in the executeTool method that routes 'activate_window' calls to the handler.case 'activate_window': return await this.activateWindow(args.title);
- src/tools/window.js:77-81 (registration)Tool name registration in the canHandle method for capability checking.canHandle(toolName) { const tools = ['list_windows', 'get_active_window', 'activate_window', 'close_window', 'minimize_window', 'maximize_window']; return tools.includes(toolName); }