简体   繁体   English

更改桌面背景Mac OS X

[英]Change desktop background mac os x

please tell me how to programmatically change the desktop background in Mac OS X? 请告诉我如何以编程方式更改Mac OS X中的桌面背景? I found, but for windows https://stackoverflow.com/a/12212368/2838676 我找到了,但是对于Windows https://stackoverflow.com/a/12212368/2838676

public void setWallpaper(File file)
throws Exception {
    String as[] = {
            "osascript", 
            "-e", "tell application \"Finder\"", 
            "-e", "set desktop picture to POSIX file \"" + file.getAbsolutePath() + "\"",
            "-e", "end tell"
    };
    Runtime runtime = Runtime.getRuntime();
    Process process;
    process = runtime.exec(as);
}

Credits 积分

https://stackoverflow.com/a/5007344/1401250 https://stackoverflow.com/a/5007344/1401250

https://sourceforge.net/p/jawc-wallpaperc/code/HEAD/tree/trunk/Jawc/src/it/jwallpaper/platform/impl/MacPlatform.java#l38 https://sourceforge.net/p/jawc-wallpaperc/code/HEAD/tree/trunk/Jawc/src/it/jwallpaper/platform/impl/MacPlatform.java#l38

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM