2018-4-11 01:24 /
THIS BLOG IS UNDER CONSTRUCTION

今天更新到 win10 的春季创意者版本了,感觉还行,那个时间线也挺有意思

这里贴一下换 win10 开始屏幕磁贴的办法

原理就是在程序安装位置新建一个名为
xxx.VisualElementsManifest.xml
的 xml 文件来控制磁贴的样式
这个文件里这些个参数:
ForegroundText:磁贴文本的颜色,只有 light 和 drak 两种,白色和黑色
BackgroundColor:背景色
ShowNameOnSquare150x150Logo:on 和 off
下面两个是你自定义磁贴图片的位置
<?xml version=“1.0” encoding=“utf-8”?>
<Application xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
<VisualElements
  ForegroundText=“light”
  BackgroundColor=“#49825a”
  ShowNameOnSquare150x150Logo=“on”
  Square150x150Logo=""
  Square70x70Logo=""
  />
</Application>


如果想自己动手,我推荐这篇图文并茂的博文
https://sspai.com/post/41307

否则,可以试试这个我写的 python 脚本
第一步:右键你想改的磁贴,选择更多 > 打开文件所在位置,然后输入那个 .lnk 文件的完整路径
第二步:输入你要自定义的磁贴图案,要求是 150x150 的 PNG 文件
第三步:是输入一个 70x70 的 PNG 文件
(暂时是个 python 脚本,之后会打包成 exe
import os
import struct
import shutil

"""
following the function is from https://stackoverflow.com/questions/397125/reading-the-target-of-a-lnk-file-in-python
it read the target of a .lnk file
thx @Glycerine and @Jared
"""
def read_target_of_a_lnk_file(path):
    target = ''

    with open(path, 'rb') as stream:
        content = stream.read()
        # skip first 20 bytes (HeaderSize and LinkCLSID)
        # read the LinkFlags structure (4 bytes)
        lflags = struct.unpack('I', content[0x14:0x18])[0]
        position = 0x18
        # if the HasLinkTargetIDList bit is set then skip the stored IDList
        # structure and header
        if (lflags & 0x01) == 1:
            position = struct.unpack('H', content[0x4C:0x4E])[0] + 0x4E
        last_pos = position
        position += 0x04
        # get how long the file information is (LinkInfoSize)
        length = struct.unpack('I', content[last_pos:position])[0]
        # skip 12 bytes (LinkInfoHeaderSize, LinkInfoFlags, and VolumeIDOffset)
        position += 0x0C
        # go to the LocalBasePath position
        lbpos = struct.unpack('I', content[position:position+0x04])[0]
        position = last_pos + lbpos
        # read the string at the given position of the determined length
        size= (length + last_pos) - position - 0x02
        temp = struct.unpack('c' * size, content[position:position+size])
        target = ''.join([chr(ord(a)) for a in temp])

    return target

def mycopyfile(srcfile, dstpath):
    if not os.path.isfile(srcfile):
        print("file not exist!")
        print("文件不存在")
    else:
        _, filename = os.path.split(srcfile)
        if not os.path.exists(dstpath):
            os.makedirs(dstpath)
        dstfile = dstpath + '\\' + filename
        shutil.copyfile(srcfile, dstfile)
        print("successful copy %s -> %s" %(srcfile, dstfile))
        print("成功复制文件 %s -> %s" %(srcfile, dstfile))

print('please input the \'.lnk\' file path (you may drag the file here):')
print('首先输入一个LNK文件路径:')
lnk_path = input()
lnk_target_exe = read_target_of_a_lnk_file(lnk_path)
print('get the source file at ' + lnk_target_exe)
print("这个LNK文件指向" + lnk_target_exe)

exe_path, exe_name = os.path.split(lnk_target_exe)
dst_img_path = exe_path + '\\image'

print('please input the 150x150 png file path (you may drag the file here):')
print("然后输入一个150x150的PNG文件路径:")
src_img = input()
mycopyfile(src_img, dst_img_path)
_, img_150_name = os.path.split(src_img)

print('please input the 70x70 png file path (you may drag the file here):')
print("最后输入一个70x70的PNG文件路径:")
src_img = input()
mycopyfile(src_img, dst_img_path)
_, img_70_name = os.path.split(src_img)

exe_name = exe_name[:-4] # set xxx.exe to xxx, if the target file is not exe, ...
xml_name = exe_path + '\\' + exe_name + '.VisualElementsManifest.xml'
fp = open(xml_name, 'w')
fp.write('<Application xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n')
fp.write('\t<VisualElements\n')
fp.write('\t\tBackgroundColor=\"#4CAF50\"\n')
fp.write('\t\tShowNameOnSquare150x150Logo=\"on\"\n')
fp.write('\t\tSquare150x150Logo=\"image\\' + img_150_name + '\"\n')
fp.write('\t\tSquare70x70Logo=\"image\\' + img_70_name + '\"\n')
fp.write('\t\tForegroundText=\"light\" />\n')
fp.write('</Application>\n')
fp.close()
print("successful create file %s" %xml_name)
print("成功新建样式文件:%s" %xml_name)

lnk_path, _ = os.path.split(lnk_path)
os.chdir(lnk_path)
os.system('for %f in (*.*) do copy /b "%f" +,,')
print("successful fresh the temp")
print("成功刷新磁贴缓存。")

print("Now repatch your tile to start menu and enjoy.")
print("也许成功了,快去看看吧!")
input()
#1 - 2018-4-12 12:39
(Nice Fever)
在想能不能自动选取图标的主要颜色,我现在的颜色都是手动选取的(bgm38)
#1-1 - 2018-4-12 15:53
🦋喵小六❄️
像素点扫一遍还是很容易选取图标主要颜色的
不过感觉磁贴的背景色和图标色重合的话会很丑bgm38
(我也仅仅是把win32程序的磁贴改成UWP磁贴
#1-2 - 2018-4-12 18:26
神戸小鳥
喵小六 说: 像素点扫一遍还是很容易选取图标主要颜色的
不过感觉磁贴的背景色和图标色重合的话会很丑bgm38
(我也仅仅是把win32程序的磁贴改成UWP磁贴
说起重色问题,突然想起大部分图标我都手撸了个白色图标(bgm38)
#1-3 - 2018-4-12 21:25
🦋喵小六❄️
神戸小鳥 说: 说起重色问题,突然想起大部分图标我都手撸了个白色图标
我是整张就用UWP的,底色对我来说没太大影响