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

Method getFinderPath

src/main/utils/appleScriptHelper.ts:32–57  ·  view source on GitHub ↗

* 获取访达(Finder)当前打开的路径 * @returns 访达当前路径,如果访达未激活或没有打开窗口则返回 null

()

Source from the content-addressed store, hash-verified

30 * @returns 访达当前路径,如果访达未激活或没有打开窗口则返回 null
31 */
32 async getFinderPath(): Promise<string | null> {
33 try {
34 const script = `
35 tell application "System Events"
36 set frontApp to name of first application process whose frontmost is true
37 end tell
38
39 if frontApp is "Finder" then
40 tell application "Finder"
41 if (count of windows) > 0 then
42 return POSIX path of (target of front window as alias)
43 else
44 return ""
45 end if
46 end tell
47 else
48 return ""
49 end if
50 `
51 const result = await this.execute(script)
52 return result || null
53 } catch (error) {
54 console.error('[AppleScript] 获取访达路径失败:', error)
55 return null
56 }
57 }
58
59 /**
60 * 获取当前激活的应用程序信息

Callers

nothing calls this directly

Calls 1

executeMethod · 0.95

Tested by

no test coverage detected