AutoHotKey,更新图标 [英] AutoHotKey, Updating Icons

查看:205
本文介绍了AutoHotKey,更新图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在更新GUI的图标时遇到问题. 我想拥有它,所以当我按下一个按钮时,图标会更改,而当我按下另一个按钮时,它会更改为其他图标.

So i have a problem with updating the icon for my gui. I want to have it so when i press a button the icon changes, and when i press another button it changes to a different icon.

使用以下脚本创建gui时,我可以更改一次图标:

I can change the icon once when i create the gui with this script:

gui, show, w0 h0
Menu, Tray, Icon, %A_WorkingDir%\Files\Red_Icon.ico, 1, 1
gui, destroy

但是我似乎无法多次更改它

But i cant seem to be able to change it multiple times

所以我想知道我如何多次更改图标/如何更新图标

So im wondering how i change the icon multiple times/How to uppdate to icon

推荐答案

如果只想在图标一和图标二之间切换,则可以使用以下方法:

If you just want to toggle between the icon one and icon two you can use this:

Gui, Add, Button, gNewIcon, Click to change icon
Gui, Show, w200 h200
Menu, Tray, Icon, C:\icon1.png, ,  ;first icon path
return

NewIcon:
if (toggle := !toggle)
  Menu,Tray,Icon, C:\icon2.png, ,  ;second icon path
else
  Menu, Tray, Icon, C:\icon1.png, ,  ;first icon path
return

如果您想在多个图标之间切换,请使用以下方法:

If you want to switch between multiple icons then use this:

Gui, Add, Button, x10 y20 gNewIcon1, Click to change to icon 1
Gui, Add, Button, x10 y60 gNewIcon2, Click to change to icon 2
Gui, Add, Button, x10 y100 gIconDef, Click to change icon back to default
Gui, Show, w200 h200
Menu, Tray, Icon, C:\icon1.png, ,  ;first icon path
return

IconDef:
Menu, Tray, Icon, C:\icon1.png, ,  ;first icon path
return

NewIcon1:
Menu, Tray, Icon, C:\icon2.png, ,  ;second icon path
return

NewIcon2:
Menu, Tray, Icon, C:\icon3.png, ,  ;third icon path
return

这篇关于AutoHotKey,更新图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆