Skip to content

Commit

Permalink
v2.7.0
Browse files Browse the repository at this point in the history
1.新功能:浏览系统内置图标或用户自选文件夹图标,并支持双击功能(随主窗口移动而移动)
2.优化了搜索的Edit控件内的显示内容和tooltip位置
3.新增关闭时的渐进淡化隐藏和关闭的效果
4.优化了判断快捷方式是否更换过图标的能力
  • Loading branch information
iKineticate committed Mar 17, 2024
1 parent bb93352 commit 59873ad
Show file tree
Hide file tree
Showing 13 changed files with 339 additions and 129 deletions.
283 changes: 176 additions & 107 deletions AHK_ChangeIcon.ahk

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions AHK_Language.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ Text :=
{
; Label Name
HOME_ZH : " 主 页"
,HOME_EN : " Home"
,HOME_EN : " Home"

,OTHER_ZH : " 其 他"
,OTHER_EN : " Other"
,OTHER_EN : " Other"

,LOG_ZH : " 日 志"
,LOG_EN : " Log"
,LOG_EN : "Log "

,HELP_ZH : " 设 置"
,HELP_EN : " Settings"
,HELP_EN : " Settings"

,ABOUT_ZH : " 关 于"
,ABOUT_EN : " About"
,ABOUT_EN : " About"

;==========================================================================
; Tab: Home
Expand Down Expand Up @@ -195,6 +195,15 @@ Text :=
,IS_DELETE_ZH : "——该快捷方式是无效的,是否删除该快捷方式?"
,IS_DELETE_EN : "——The shortcut is invalid, do you need to delete the shortcut?"

,SYSTEM_ICONS_ZH : "浏览系统图标"
,SYSTEM_ICONS_EN : "Browse system icons"

,SYSTEM_ICONS_TITLE_ZH : "系统图标"
,SYSTEM_ICONS_TITLE_EN : "System Icons"

,USERS_ICONS_TITLE_ZH : "用户图标"
,USERS_ICONS_TITLE_EN : "Users Icons"

;==========================================================================
; Tab: About
;==========================================================================
Expand Down
131 changes: 131 additions & 0 deletions AHK_iconGUI.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
Create_iconGUI(*)
{
; 创建 iconGUI 窗口.
global iconGUI := Gui(" -Resize -caption +DPIScale +Owner" MyGui.hwnd)
iconGUI.SetFont("cffffff","Microsoft YaHei UI")
iconGUI.BackColor := "000000"
iconGUI.active_control := False
; 创建按钮
iconGUI.AddButton("vTestButton1 x0 y0" " w" 250/2 " h" 78/2, TEXT.SYSTEM_ICONS_TITLE).OnEvent("click", iconGUI_Menu)
iconGUI.AddButton("vTestButton2 x" 250/2 " y0 w" 250/2 " h" 78/2, TEXT.USERS_ICONS_TITLE).OnEvent("click", Add_Users_Icons)
iconGUI["TestButton1"].Setfont("s10 cffffff")
iconGUI["TestButton2"].Setfont("s10 cffffff")
WinSetTransparent(80, iconGUI["TestButton1"].hwnd)
WinSetTransparent(80, iconGUI["TestButton2"].hwnd)
; 大图标列表
iconLV := iconGUI.Add("ListView", "viconLV x0 y" 78/2 " h" 572/2 " w" 500/2 " Background252525 -Multi -E0x200 +icon +LV0x10000", ["Icon", "Path"]) ; 创建 ListView.
iconLV.SetFont("cf5f5f5 s12")
iconLV.OnEvent("DoubleClick", iconLV_DoubleCick)
; 添加图标
Add_Icon_dll_GUI("shell32.dll", "dll")
; 深色模式
DllCall("uxtheme\SetWindowTheme", "Ptr", iconLV.hWnd, "Str", "DarkMode_Explorer", "Ptr", 0)
; 设置圆角
FrameShadow(iconGUI.hwnd)
; 获取MyGui的大小位置
MyGui.GetPos(&X, &Y, &Width, &Height)
; 显示窗口
iconGUI.Show("x" (x+Width+10)*(A_ScreenDPI/96) " y" y*(A_ScreenDPI/96) " h" Height " w" 500/2 " NA")
; 重绘按钮
WinRedraw(iconGUI["TestButton1"].hwnd)
WinRedraw(iconGUI["TestButton2"].hwnd)
; 设置鼠标在其上方的按钮
icursor := "C:\Windows\Cursors\aero_link.cur"
DllCall("SetClassLongPtr", "ptr", iconGUI["TestButton1"].hwnd, "int", GCLP_HCURSOR := -12, "ptr", LoadPicture(icursor,"w" 28*(A_ScreenDPI/96) " h" 28*(A_ScreenDPI/96), &IMAGE_CURSOR := 2))

iconGUI_Menu(*)
{
iconsMenu := Menu()
iconsMenu.Add("shell32.dll", (*) => Add_Icon_dll_GUI("shell32.dll", "dll"))
iconsMenu.Add("imageres.dll", (*) => Add_Icon_dll_GUI("imageres.dll", "dll"))
iconsMenu.Add("mmres.dll", (*) => Add_Icon_dll_GUI("mmres.dll", "dll"))
iconsMenu.Add("ddores.dll", (*) => Add_Icon_dll_GUI("ddores.dll", "dll"))
iconsMenu.Add("explorer.exe", (*) => Add_Icon_dll_GUI("explorer.exe", "dll"))
iconsMenu.Add("imagesp1.dll", (*) => Add_Icon_dll_GUI("imagesp1.dll", "dll"))
iconsMenu.Add("pifmgr.dll", (*) => Add_Icon_dll_GUI("pifmgr.dll", "dll"))
iconsMenu.Add("networkexplorer.dll", (*) => Add_Icon_dll_GUI("networkexplorer.dll",""))
iconsMenu.Show(0, 39*(A_ScreenDPI/96))
}

Add_Users_Icons(*)
{
; 访问ini,打开上一次打开的存放ICO的文件夹,并更新ini里的上一次打开的图标文件夹路径
Try
{
last_selected_folder_path := iniRead(info_ini_path, "info", "last_icons_folder_path")
}
Catch
{
Msgbox("the info.ini does not have an option named `"last_icons_folder_path`" ",,"icon!")
}
If not (selected_folder_path := DirSelect("*" . last_selected_folder_path, 0, Text.SELECT_ICONS_FOLDER))
Return
Add_Icon_dll_GUI(selected_folder_path, "")
}

Add_Icon_dll_GUI(path, Is_dll_Icons)
{
global default_dll := path
iconLV.Opt("-Redraw")
iconLV.Delete()
If !Is_dll_Icons
{
global is_users_icons := False
icon_list_ID := IL_Create(,,"true")
iconLV.SetImageList(icon_list_ID)
Loop Files, path "\*.ico"
{
hIcon := DllCall_Get_Icon(A_LoopFilePath)
icon_number := DllCall("ImageList_ReplaceIcon", "Ptr", icon_list_ID, "Int", -1, "Ptr", hIcon) + 1
DllCall("DestroyIcon", "ptr", hIcon)
iconLV.Add("Icon" . icon_number, A_Index, A_LoopFilePath)
}
}
Else
{
global is_users_icons := True
icon_list_ID := IL_Create(,,"true")
iconLV.SetImageList(icon_list_ID)
Loop ; 把 DLL 中的一系列图标装入图像列表.
{
If !IL_Add(icon_list_ID, path, A_Index)
Break
iconLV.Add("Icon" . A_Index+1, A_Index)
}
}
iconLV.Opt("+Redraw")
}

iconLV_DoubleCick(*)
{
If !LV.GetNext()
or !iconLV.GetNext()
or Tab.Value != "1"
Return
; 获取快捷方式数据
link_name := LV.GetText(LV.GetNext())
link_ext := LV.GetText(LV.GetNext(), "3")
key := link_name . link_ext
link_path := link_map[key].LP
; 更换图标
COM_Link_Attribute(&Link_Path, &Link_Attribute, &Link_Icon_Location)
(!is_users_icons) ? (Link_Attribute.IconLocation := iconLV.GetText(iconLV.GetNext(), 2)) : (Link_Attribute.IconLocation := default_dll . "," . iconLV.GetNext())
Link_Attribute.Save()
; 更新显示的数据
If !LV.GetText(LV.GetNext(), 2)
{
MyGui["Changed_Count"].Value += 1
MyGui["Unchanged_Count"].Value -= 1
}
; 刷新顶部和列表图标,并目标行添加"√"
Refresh_Display_Icon(LV, LV.GetNext())
Refresh_LV_Icon(LV, LV.GetNext())
LV.Modify(LV.GetNext(),,,"")
; 添加日志
icon_from := (!is_users_icons) ? (iconLV.GetText(iconLV.GetNext(), 2)) : default_dll . "," . iconLV.GetNext()
MyGui["Log"].Value .= FormatTime(A_Now, "`syyyy/MM/dd HH:mm:ss`n`s")
. Text.LOG_CHANGED_LINK . link_name . "`n`s"
. Text.Source_OF_ICON . icon_from . "`n`n===========================================`n`n"
}
}

Binary file modified Introduction/change_and_restore.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Introduction/change_one.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Introduction/homepage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Introduction/menu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Introduction/other_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Introduction/other_zh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Introduction/system_icons.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@

![image](https://github.com/iKineticate/AHK-ChangeIcon/blob/main/Introduction/other_zh.png)

4.浏览系统大部分图标或用户自选图标,支持双击更换左侧列表快捷方式图标

![image](https://github.com/iKineticate/AHK-ChangeIcon/blob/main/Introduction/system_icons.gif)

## 已知问题

1.仅支持更换快捷方式(.lnk)图标,暂不支持更换非快捷方式图标(如.url、pdf、exe等图标)
Expand Down Expand Up @@ -88,6 +92,8 @@

尚无解决办法

9.Windows10不支持圆角

## 下载

Github:[AHK-ChangeIcon](https://github.com/iKineticate/AHK-ChangeIcon/releases)
Expand Down Expand Up @@ -115,14 +121,10 @@ Github:[AHK-ChangeIcon](https://github.com/iKineticate/AHK-ChangeIcon/releases

## 更新内容

1.文字图标代替PNG显示图标

2.检索配置内容

3.默认字体更换为UI
1.新功能:浏览系统内置图标或用户自选文件夹图标,并支持双击功能(随主窗口移动而移动)

4.垂直标签页添加图标
2.优化了搜索的Edit控件内的显示内容和tooltip位置

5.修复部分问题,优化部分代码
3.新增关闭时的渐进淡化隐藏和关闭的效果

6.垂直标签页的"帮助"更换为"设置"(设置内的功能未上线)
4.优化了判断快捷方式是否更换过图标的能力
6 changes: 2 additions & 4 deletions lib/Class_Button.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ Class CreateButton
active_name := StrReplace(this._name, "`s") . "_ACTIVE"
button_name := StrReplace(this._name, "`s") . "_BUTTON"
; Normal PNG image (常态的PNG图片)
MyGui.AddPicture("x" . this._x . " y" . this._y . " w" . this._w . " h" . this._h , "HICON:" Base64PNG_to_HICON(obj.normal_png_base64, obj.png_quality))
; Top button (顶层按钮) (+0x4000000:Top level buttons are displayed below other controls (顶层控件的显示在其他控件下方) )
MyGui.AddPicture("v" . button_name . " x" . this._x . " y" . this._y . " w" . this._w . " h" . this._h, "HICON:" Base64PNG_to_HICON(obj.normal_png_base64, obj.png_quality)).OnEvent("Click", ButtonFunc)
; 若PNG的Base64不存在或为空,则返回
If (!obj.HasOwnProp("active_png_base64") or !obj.active_png_base64)
Return
; Active PNG image (活跃态的PNG图片)
MyGui.AddPicture("v" . active_name . " x" . this._x . " y" . this._y . " w" . this._w . " h" . this._h . " Hidden", "HICON:" Base64PNG_to_HICON(obj.active_png_base64, obj.png_quality))
; Top button (顶层按钮) (+0x4000000:Top level buttons are displayed below other controls (顶层控件的显示在其他控件下方) )
MyGui.AddButton("v" . button_name . " x" . this._x . " y" . this._y . " w" . this._w . " h" . this._h . " -Tabstop +0x4000000").OnEvent("Click", ButtonFunc)
}

;========================================================================================================
Expand Down Expand Up @@ -107,7 +106,6 @@ Class CreateButton
MyGui.AddPicture("x" . this._x . " y" . this._y . " w" . this._w*(A_ScreenDPI/96) . " h" . this._h*(A_ScreenDPI/96) . " v" . active_name . " +0xE -E0x200 Hidden BackgroundTrans")
Gdip_SetPicRoundedRectangle(MyGui[active_name], obj.active_color, obj.r, isFill:="True")
}

; Top text button (顶层文本按钮)
MyGui.AddText("x" . this._x . " y" . this._y . " w" . this._w . " h" . this._h . " v" . button_name . " BackgroundTrans " . obj.text_options, obj.Text)
If (obj.HasOwnProp("font_options") and obj.HasOwnProp("font"))
Expand Down
11 changes: 6 additions & 5 deletions lib/Class_MyGui.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,21 @@ Class CreateModernGUI
Case 8 : obj.active_color:= RegExReplace(color,"i)^0x")
Case 10: obj.active_color:= RegExReplace(color, "i)^0x..")
}

; Create Windows Control Buttons (Replace button icons with font symbols) (创建文本符号的控制窗口按钮)
For key, value in map("Close", "0x2716", "Maximize", "0x25A2", "Minimize", "0xE0B8")
{
active_name := key . "_ACTIVE"
button_name := key . "_BUTTON"
button_x := this.w - (obj.margin_right + A_Index * obj.button_w)
button_y := obj.margin_top
(!obj.HasOwnProp("symbol_backcolor")) ? "" : MyGui.AddPicture("x" . button_x . " y" . button_y . " w" . obj.button_w . " h" . obj.button_h . " background" . obj.symbol_backcolor . " -E0x200")
text_color := (key="Maximize") ? "575757" : "ffffff"
; 常态
(obj.HasOwnProp("symbol_backcolor")) ? MyGui.AddPicture("x" . button_x . " y" . button_y . " w" . obj.button_w . " h" . obj.button_h . " background" . obj.symbol_backcolor . " -E0x200") : False
; 活跃态
(key="Maximize") ? "" : MyGui.AddPicture("v" active_name " x" . button_x . " y" . button_y . " w" . obj.button_w . " h" . obj.button_h . " background" . obj.active_color . " +Hidden -E0x200")
(key!="Maximize") ? MyGui.AddPicture("v" active_name " x" . button_x . " y" . button_y . " w" . obj.button_w . " h" . obj.button_h . " background" . obj.active_color . " +Hidden -E0x200") : False
; 文本按钮
FontSymbol( {name:button_name, x:button_x, y:button_y, w:obj.button_w, h:obj.button_h, unicode:value, font_name:"Segoe UI Symbol", text_color:"ffffff", back_color:"Trans", font_options:"s" obj.button_h/2, text_options:"+0x200 center"} )
(key="Maximize") ? "" : MyGui[button_name].OnEvent("Click", ButtonFunc)
FontSymbol( {name:button_name, x:button_x, y:button_y, w:obj.button_w, h:obj.button_h, unicode:value, font_name:"Segoe UI Symbol", text_color:text_color, back_color:"Trans", font_options:"s" obj.button_h/2, text_options:"+0x200 center"} )
(key!="Maximize") ? MyGui[button_name].OnEvent("Click", ButtonFunc) : False
}
}

Expand Down

0 comments on commit 59873ad

Please sign in to comment.