之前写一个gui,需要嵌入图片到ahk代码,但HEX太长,所以有了这么一个压缩脚本
zip(a){
;自定义设置
size = 2 ;多少字节一取样 比如24为bmp 6字节
;完毕
last =
Loop
{
if a =
{
if times > 1
out = % out "[" times "_" last "]"
Else
out = % out last
Break
}
StringLeft, tmp_var, a, %size%
StringTrimLeft, a, a, %size%
if tmp_var <> %last%
{
if last =
{
last := tmp_var
times = 1
}
Else
{
if times > 1
{
out = % out "[" times "_" last "]"
last := tmp_var
times = 1
}
Else
{
out = % out last
last := tmp_var
times = 1
}
}
}
Else
{
times += 1
}
}
return %out%
}
unzip(a){
StringSplit, var, a, ]
Loop % var0-1
{
tmp_var = % var%A_Index%
StringSplit, key, tmp_var, [
StringSplit, xx, key2, _
unzip_var =
Loop % xx1
{
unzip_var = % unzip_var xx2
}
out = % out key1 unzip_var
}
out := out var%var0%
Return out
}
file2hex(file){
tmp_file := FileOpen(file, "r")
while not tmp_file.AtEOF {
tmp_file.RawRead(Data, 1)
SetFormat, IntegerFast, hex
tmp_hex := asc(Data)
StringReplace, tmp_hex, tmp_hex, 0x, , All
SetFormat, IntegerFast, d
if StrLen(tmp_hex) = 1
tmp_hex = 0%tmp_hex%
hex = % hex tmp_hex
}
tmp_file.Close()
Return hex
}
hex2file(hex,file){
tmp_file := FileOpen(file, "w")
StringLen, len, hex
loop % len/2
{
if blob =
break
StringLeft, tmp_hex, blob, 2
StringTrimLeft, blob, blob, 2
tmp_hex := "0x" tmp_hex
tmp_file.WriteUChar(tmp_hex)
}
tmp_file.Close()
tmp_file =
}
a := file2hex("D:\Desktop\no.bmp")
zip := zip(a)
FileAppend, %zip%, zip.txt
b := unzip(zip)
hex2file(b,"out.txt")
;===============================================================================
;
; Description: 返回指定文本文件的行数.
; Syntax: FileCountLines(sFilePath)
; Parameter(s): $sFilePath - 路径+文件名
; Requirement(s): 无
; Return Value(s): 成功 - 返回文件的行数
; 失败 - 返回0 并设置 error = 1
; Author(s): Tylo <tylo at start dot no> 修正 by thesnow Converted by Thinkai
;
;===============================================================================
FileCountLines(sFilePath){
global error
IfNotExist, %sFilePath%
{
error = 1
Return 0
}
Else
{
FileRead, m, %sFilePath%
StringSplit, n, m, `n
if n0 = 0
Return 1
Else
Return n0
}
}
;======================================================
;
; 函数名称: EncryptFile(sFilePath)
; 详细信息: 加密文件,NTFS磁盘系统自带的EFS加密
; sFilePath: sFilePath 为您想加密的文件.
; 返回值 : Dllcall的Errorlevel
; 作者: thesnow(rundll32@126.com) Converted by Thinkai
;
;======================================================
EncryptFile(sFilePath){
dllcall("advapi32.dll\EncryptFile","str", sFilePath)
Return Errorlevel
}
;======================================================
;
; 函数名称: DecryptFile(sFilePath)
; 详细信息: 解密文件,NTFS磁盘系统自带的EFS加密
; sFilePath: sFilePath 为您想解密的文件.
; 返回值 : Dllcall的Errorlevel
; 作者: thesnow(rundll32@126.com) Converted by Thinkai
;
;======================================================
DecryptFile(sFilePath){
dllcall("advapi32.dll\DecryptFile","str", sFilePath,"int",1)
Return Errorlevel
}
;======================================================
;
; 函数名称: _HideSystemFolder($PathCode,$Hide)
; 详细信息: 隐藏系统特殊文件夹.
; $PathCode: 系统文件夹代码:
; 0,控制面板/1,程序文件夹目录/2,系统所在驱动器/3,windows目录
; $Hide: 隐藏为1,不隐藏为0.
; 返回值 : 成功返回1,失败(文件夹代码错误)返回0,失败(隐藏代码错误),返回0.
; 作者: thesnow(rundll32@126.com) Converted by Thinkai
;
;======================================================
HideSystemFolder(PathCode:=4,Hide:=1){
If Hide is not integer
{
Return 0
}
Else
{
if PathCode = 0
RegWrite, REG_DWORD, HKCU, Software\Microsoft\Windows\CurrentVersion\Explorer\WebView\BarricadedFolders, shell:ControlPanelFolder, %Hide%
Else if PathCode = 1
RegWrite, REG_DWORD, HKCU, Software\Microsoft\Windows\CurrentVersion\Explorer\WebView\BarricadedFolders, shell:ProgramFiles, %Hide%
Else if PathCode = 2
RegWrite, REG_DWORD, HKCU, Software\Microsoft\Windows\CurrentVersion\Explorer\WebView\BarricadedFolders, shell:SystemDriveRootFolder, %Hide%
Else if PathCode = 3
RegWrite, REG_DWORD, HKCU, Software\Microsoft\Windows\CurrentVersion\Explorer\WebView\BarricadedFolders, shell:Windows, %Hide%
Else if PathCode = 4
RegWrite, REG_DWORD, HKCU, Software\Microsoft\Windows\CurrentVersion\Explorer\WebView\BarricadedFolders, shell:Windows, %Hide%
Else
Return 0
}
Return 1
}
49 queries in 1.527 seconds |