MCPcopy Index your code
hub / github.com/ZToolsCenter/ZTools / getRunningApps

Method getRunningApps

src/main/utils/appleScriptHelper.ts:227–245  ·  view source on GitHub ↗

* 获取所有运行中的应用程序列表 * @returns 运行中的应用程序名称数组

()

Source from the content-addressed store, hash-verified

225 * @returns 运行中的应用程序名称数组
226 */
227 async getRunningApps(): Promise<string[]> {
228 try {
229 const script = `
230 tell application "System Events"
231 set appList to name of every application process
232 return appList as text
233 end tell
234 `
235 const result = await this.execute(script)
236 if (result) {
237 // AppleScript 返回的列表用逗号分隔
238 return result.split(', ').filter((name) => name.trim())
239 }
240 return []
241 } catch (error) {
242 console.error('[AppleScript] 获取运行中应用列表失败:', error)
243 return []
244 }
245 }
246
247 /**
248 * 检查指定应用是否正在运行

Callers

nothing calls this directly

Calls 1

executeMethod · 0.95

Tested by

no test coverage detected