function switchToDocument(docName) {
    var docs = app.documents;
    for (var i = 0; i < docs.length; i++) {
        if (docs[i].name == docName) {
            app.activeDocument = docs[i];
            break;
        }
    }
}

// 使用示例
switchToDocument("xxx.psd");
