问题
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.
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
回答1:
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
来源:https://stackoverflow.com/questions/49803867/autohotkey-updating-icons