Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1004276 // Try Setting Desktop Wallpaper On Windows [Works on XP!]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1289L/9K/31K).

1  
!752
2  
3  
p {
4  
  S imageID = or2(get(args, 0), "#1002132"); // Eleutheria
5  
  File img = prepareProgramFile(parseSnippetID(imageID) + ".bmp");
6  
  saveBMP(loadImage2(imageID), img);
7  
  assertTrue(img.getAbsolutePath(), img.isFile());
8  
  
9  
  backtick_verbose = true;
10  
  
11  
  S cmd = "reg add \"HKEY_CURRENT_USER\\Control Panel\\Desktop\" /v Wallpaper /t REG_SZ /d " + bashQuote(img) + " /f";
12  
  backtick(cmd);
13  
  
14  
  // Set to "fit" (WallpaperStyle=6, TileWallpaper=0) doesn't seem to work
15  
  // So set to "center"
16  
  cmd = "reg add \"HKEY_CURRENT_USER\\Control Panel\\Desktop\" /v WallpaperStyle /t REG_SZ /d " + 0 + " /f";
17  
  backtick(cmd);
18  
  cmd = "reg add \"HKEY_CURRENT_USER\\Control Panel\\Desktop\" /v TileWallpaper /t REG_SZ /d " + 0 + " /f";
19  
  backtick(cmd);
20  
21  
  cmd = "RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters";
22  
  backtick(cmd);
23  
  
24  
  print("Wallpaper set to " + imageID + "!?");
25  
}

Author comment

Began life as a copy of #1004272

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, etmzoiygucik, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004276
Snippet name: Try Setting Desktop Wallpaper On Windows [Works on XP!]
Eternal ID of this version: #1004276/1
Text MD5: c131941a4574e6afdab31bf537547f1a
Transpilation MD5: a7b271f358a1b4409c8a712559b37921
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-12 17:23:47
Source code size: 905 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 490 / 583
Referenced in: [show references]