提取win10锁屏壁纸
⾃制提取⼯具:
Win10锁屏壁纸提取1.0:原始版本;
Win10锁屏壁纸提取2.0:改进版本,默认你的win10壁纸也是1920*1080;
Win10锁屏壁纸提取3.0:改进版本,通过注册表配置直接获取壁纸图⽚;
(有⼀点注意:必须放在桌⾯使⽤,否则⽤户的机器需要额外配置环境变量:键:EXE4J_JAVA_HOME值:C:anbuzhuangJava1.7jre<这⾥是打⽐⽅,如果你安装了jdk,此值也可
写成%JAVA_HOME%>)
最近电脑开机,发现Windows默认的锁屏壁纸特别之绚丽,欲图之,或设之为桌⾯壁纸;
从⽹上得之保存路径:
C:tDeliveryManager_cw5n1h2txyewyLocalStateAsts
(win+R-->%LocalAppData%tDeliveryManager_cw5n1h2txyewyLocalStateAsts可进⼊)
可是此⽂件夹下的⽂件较多,且⽆后缀名,导致系统不认识它们是图⽚,遂⽆缩略图,⽹络上的⽅法是将其⼀个个添加后缀.jpg,然后提取。
感觉不靠谱,所以我尝试⽤程序来提取。
代码如下:
packagetest;
;
putStream;
tputStream;
ption;
lFormat;
ties;
publicclassTt1{
publicstaticvoidmain(Stringargs[]){
//n(11/2);
//Scannersc=newScanner();
//n("请输⼊要复制去的⽬录:");
//Stringpath=ne();
////获取windows⽤户信息
//Propertiesprop=perties();
/**
*win10获取美丽壁纸图⽚getWallpaper
*/
Propertiesprop=perties();
Stringurname=perty("");
//复制⽂件夹和⽂件
StringsourcePath="C:Urs"+urname+"tDeliveryManager_cw5n1h2txyewyLocalStateAsts"
Stringpath="C:Urs"+urname+"Desktopwin10锁屏壁纸";
if((newFile(path)).exists()){
n("请先删除桌⾯上的-->win10锁屏壁纸<--⽂件夹");
return;
}
try{
longstartTime=tTimeMillis();//记录当前时间
copyDir(sourcePath,path);
longspendTime=tTimeMillis()-startTime;
Stringtime=formatDecimal(spendTime);
n("批量复制的时间为:"+spendTime+"毫秒,也就是"+time+"秒");
}catch(IOExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}
reNameFiles(path);
}
//⼩数格式处理毫秒转秒⼩数点后⼀位
publicstaticStringformatDecimal(longspendTime){
DecimalFormatdecimalFormat=newDecimalFormat(".0");
doubletemp=(double)spendTime/1000;
if(temp>=1)
(temp);
el
return"0"+(temp);
}
//批量重命名⽂件
publicstaticvoidreNameFiles(Stringpath){
longstartTime=tTimeMillis();//记录当前时间
Stringdir=path;
File[]files=newFile(dir).listFiles();
inti=0;
for(Filefile:files){//循环⽂件夹中的⽂件
if(()&&()){//判断⽂件是否存在
if(e().indexOf(".")==-1){
i++;
//renameTo⽅法的左右路径的⽬录结构部分必须是⼀样的否则返回fal
if(To(newFile(path+""+e()+".jpg"))){//这⾥⼀定要加不然全部⽂件会跑到上⼀级⽬录去。。
n(i+"success");
}el{
n(i+"failed");
}
}
}el{
n("第"+i+"个⽂件不存在,请检查⽂件位置!");
}
}
n("⼀共修改了"+i+"个⽂件名称");
longspendTime=tTimeMillis()-startTime;
Stringtime=formatDecimal(spendTime);
n("批量重命名⽂件的时间为:"+spendTime+"毫秒,也就是"+time+"秒");
}
//从某位置复制⽂件或⽂件夹(包括此⽂件夹内的⽂件⼀起)到新⽂件夹
publicstaticvoidcopyDir(StringsourcePath,StringnewPath)throwsIOException{
Filefile=newFile(sourcePath);
String[]filePath=();
if(!(newFile(newPath)).exists()){
(newFile(newPath)).mkdir();
}
for(inti=0;i<;i++){
if((newFile(sourcePath+tor+filePath[i])).isDirectory()){//⽬錄
longstartTime=tTimeMillis();//记录当前时间
copyDir(sourcePath+tor+filePath[i],newPath+tor+filePath[i]);
longspendTime=tTimeMillis()-startTime;
Stringtime=formatDecimal(spendTime);
n("复制⽂件夹"+i+"的时间为:"+spendTime+"毫秒,也就是"+time+"秒");
}
if(newFile(sourcePath+tor+filePath[i]).isFile()){//⽂件
longstartTime=tTimeMillis();//记录当前时间
copyFile(sourcePath+tor+filePath[i],newPath+tor+filePath[i]);
longspendTime=tTimeMillis()-startTime;
Stringtime=formatDecimal(spendTime);
n("复制⽂件"+i+"的时间为:"+spendTime+"毫秒,也就是"+time+"秒");
}
}
}
//从某位置复制⽂件到新⽂件夹
publicstaticvoidcopyFile(StringoldPath,StringnewPath)throwsIOException{
FileoldFile=newFile(oldPath);
Filefile=newFile(newPath);
FileInputStreamin=newFileInputStream(oldFile);
FileOutputStreamout=newFileOutputStream(file);;
byte[]buffer=newbyte[1024*1024*1024];//2097152设1个G的容量
intreadByte=0;
while((readByte=(buffer))!=-1){
(buffer,0,readByte);
在eclip中运⾏以上代码便可实现提取了,以下部分是打包为Windows平台可执⾏的exe⽂件的过程:
将此项⽬从eclip打jar包到:C:
下载exe4j⼯具并安装(下载地址:)此⼯具仅⽀持jdk1.7和1.8打的jar包!!
⽤exe4j⼯具打包jar为exe(图⽰为需要⼿动操作的地⽅,其余页默认next):
上图是后来才发现的⽐较重要的⼀步,需要注册,不然exe每次打开会出现弹框如下图,注册码是:
Searchquence这⼀步删掉默认的三项,添加⾃⼰的jre(事实上如果你是开发⼈员并且软件是在⾃⼰机器上⽤的话可以直接默认,最好删掉,选择jre时跟eclip打包的jre最
好⼀致)
运⾏⽣成的Win10锁屏壁纸提取⼯具.exe⽂件便可将壁纸提取到桌⾯了
遂取之<东瀛美⾊,⼼向往之!>============================================
改进代码:
再次改进:壁纸是由注册表配置⽽控制的(找到注册表,就可以找到图⽚的路径,就不需要写死了),在注册表中直接搜索壁纸得到其配置路径
再次改进代码如下:
}
();
();
}
}
A-XVK258563F-1p4lv7mg7sav
A-XVK209982F-1y0i3h4ywx2h1
A-XVK267351F-dpurrhnyarva
A-XVK204432F-1kkoilo1jy2h3r
A-XVK246130F-1l7msieqiwqnq
A-XVK249554F-pllh351kcke50
A-XVK238729F-25yn13iea25i
A-XVK222711F-134h5ta8yxbm0
A-XVK275016F-15wjjcbn4tpj
A-XVK275016F-15wjjcbn4tpj
ViewCode
//将符合尺⼨的图⽚复制到新⽂件夹
publicstaticvoidcopyDir(StringsourcePath,StringnewPath)throwsIOException{
Filefile=newFile(sourcePath);
String[]filePath=();
if(!(newFile(newPath)).exists()){
(newFile(newPath)).mkdir();
}
BufferedImagesourceImg=null;
for(inti=0;i<;i++){
//根据图⽚的尺⼨来找壁纸
n("============="+sourcePath+""+filePath[i]);
sourceImg=(newFileInputStream(sourcePath+""+filePath[i]));
if(th()==1920&&ght()==1080){
longstartTime=tTimeMillis();//记录当前时间
copyFile(sourcePath+tor+filePath[i],newPath+tor+filePath[i]);
longspendTime=tTimeMillis()-startTime;
Stringtime=formatDecimal(spendTime);
n("复制⽂件"+i+"的时间为:"+spendTime+"毫秒,也就是"+time+"秒");
}
}
}
packagetest;
edReader;
;
putStream;
tputStream;
ption;
treamReader;
卧槽,隔两天再运⾏,bug…原来注册表S-1-5-21-249709250-20829795-1001⽬录后的结构是会变的,再改:
ties;
publicclassTt1{
publicstaticvoidmain(Stringargs[]){
try{
/**
*通过win10注册表⾥边配置的landscapeImage项,得到锁屏壁纸的存储位置
*/
Processps=null;
//当路径中有空格时,要把路径打上引号。
ps=time().exec("regquery"HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrent"
+"VersionAuthenticationLogonUICreativeS-1-5-21-249709250-20829795-1557146304"");
putStream().clo();
InputStreamReaderi=newInputStreamReader(utStream());
Stringline;
BufferedReaderir=newBufferedReader(i);
while((line=ne())!=null){
if(ns("landscapeImage")){
line=ing(f(":")-1,());
break;
}
}
/**
*通过拷贝和重命名提取壁纸getWallpaper
*/
Propertiesprop=perties();
Stringurname=perty("");
//复制⽂件夹和⽂件
Stringpath="C:Urs"+urname+"Desktopchenyuuurefrain@";
FileoldFile=newFile(line);
Filefile=newFile(path);
FileInputStreamin=newFileInputStream(oldFile);
FileOutputStreamout=newFileOutputStream(file);;
byte[]buffer=newbyte[1024*1024*1024];//2097152设1个G的容量
intreadByte=0;
while((readByte=(buffer))!=-1){
(buffer,0,readByte);
}
();
();
}catch(IOExceptione){
tackTrace();
}
}
}
packagetest;
edReader;
;
putStream;
tputStream;
ption;
treamReader;
ist;
;
ties;
publicclassTt1{
publicstaticvoidmain(Stringargs[]){
try{
/**
*通过win10注册表⾥边配置的landscapeImage项,得到锁屏壁纸的存储位置
*/
Processps=null;
Stringchu="HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionAuthenticationLogonUICreativeS-1-5-21-249709250
ps=time().exec("regquery""+chu+""");//7146304<----不能写到这⼀级
putStream().clo();
InputStreamReaderi=newInputStreamReader(utStream());
n(i);
Stringline;
BufferedReaderir=newBufferedReader(i);
List
while((line=ne())!=null){
if(ns("S-1-5-21-249709250-20829795-1001")){
line=ing(f("S-1-5-21-249709250-20829795-1001")+46,());
(line);
}
}
List
for(intj=0;j<();j++){
ps=null;
ps=time().exec("regquery""+chu+""+(j)+""");
putStream().clo();
i=null;
i=newInputStreamReader(utStream());
ir=null;
ir=newBufferedReader(i);
line=null;
while((line=ne())!=null){
if(ns("landscapeImage")){
line=ing(f(":")-1,());
(line);
}
}
}
/**
*通过拷贝和重命名提取壁纸getWallpaper
*/
Propertiesprop=perties();
Stringurname=perty("");
for(intk=0;k<();k++){
copyF(urname,k,(k));
}
}catch(IOExceptione){
tackTrace();
}
}
publicstaticvoidcopyF(Stringurname,intxxx,StringfileP)throwsIOException{
Stringpath="C:Urs"+urname+"Desktopchennyuuu@."+xxx+".jpg";
FileoldFile=newFile(fileP);
Filefile=newFile(path);
FileInputStreamin=newFileInputStream(oldFile);
FileOutputStreamout=newFileOutputStream(file);;
byte[]buffer=newbyte[1024*1024*1024];//2097152设1个G的容量
intreadByte=0;
while((readByte=(buffer))!=-1){
(buffer,0,readByte);
}
();
();
}
}
ViewCode
本文发布于:2022-12-31 02:06:32,感谢您对本站的认可!
本文链接:http://www.wtabcd.cn/fanwen/fan/90/63080.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |