Visual Studio Code 和 AppleScript 的界限

Nrc*_*Nrc 4 applescript visual-studio-code

如何使用 AppleScript 获取代码编辑器 Visual Studio Pro 窗口的位置和大小?

\n\n

这是我尝试过的:

\n\n
tell application "Visual Studio Code" to get the bounds of window 1\n--> error "Visual Studio Code got an error: Can\xe2\x80\x99t get bounds of window 1." number -1728 from bounds of window 1\n\ntell application "System Events"\n    tell process "Visual Studio Code"\n        position of window 1\n        size of window 1\n    end tell\nend tell\n--> error "System Events got an error: Can\xe2\x80\x99t get process \\"Visual Studio Code\\"." number -1728 from process "Visual Studio Code"\n
Run Code Online (Sandbox Code Playgroud)\n

dav*_*ert 5

您可以使用名为“Code”的进程:

tell application "System Events" to tell process "Code"
    tell window 1
        set size to {1024, 768}
        set position to {100, 100}
    end tell
end tell
Run Code Online (Sandbox Code Playgroud)