activate_window
Brings a specified window to the foreground and makes it active using partial or full title matching for Windows automation tasks.
Instructions
激活指定窗口(通过标题)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | 窗口标题(支持部分匹配) |
Input Schema (JSON Schema)
{
"properties": {
"title": {
"description": "窗口标题(支持部分匹配)",
"type": "string"
}
},
"required": [
"title"
],
"type": "object"
}
Implementation Reference
- src/tools/window.js:189-201 (handler)The main handler function that activates the specified window using PowerShell's WScript.Shell.AppActivate method.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)Defines the tool schema including name, description, and input schema requiring a 'title' string parameter.{ name: 'activate_window', description: '激活指定窗口(通过标题)', inputSchema: { type: 'object', properties: { title: { type: 'string', description: '窗口标题(支持部分匹配)' }, }, required: ['title'], }, },
- src/tools/window.js:89-90 (registration)Registers the dispatch from executeTool switch statement to the activateWindow handler.case 'activate_window': return await this.activateWindow(args.title);
- src/tools/window.js:78-79 (registration)Includes 'activate_window' in the list of supported tools for canHandle method.const tools = ['list_windows', 'get_active_window', 'activate_window', 'close_window', 'minimize_window', 'maximize_window'];