If you want to do a Reload Without Flashing The Tray Icon.
You can Do that With a Little trick.
You can Solved this With a (External Tray Icon with Tray Menus)
Try these Two Ahk Scripts and you are ready to go.
No more Hassling to must do Writing Many codelines to Clear all your Variables or anything else.
Note - This is only a Simple Example to show you that you can do that.
Example1.ahk
#Notrayicon
#SingleInstance force
;Click on <esc> key - to exit
;Click on <f1> key - to do an Reload Without Flashing Tray Icon
;Click on <f2> key - to do put the variables
;Click on <f3> key - to show if the variables is be Cleared
;Tip - if you change the Name Example1.ahk into Example2.ahk
;Then you can use ReplaceAll Function in Notepad - ReplaceAll Example1 to Example2
WriteReg_Example1("Suspend","0")
WriteReg_Example1("Exit","0")
mode=1
loop
{
;----------------
RegRead, x, HKEY_CURRENT_USER,software\Example1,Suspend ; read SuspendValue
if x=1
{
WriteReg_Example1("Suspend","0")
x=0
Suspend
}
;----------------
;----------------
RegRead, x, HKEY_CURRENT_USER,software\Example1,Exit ; read ExitValue
if x=1
{
exitapp
WriteReg_Example1("Exit","0")
x=0
}
;----------------
} ;End Loop
;if you have Many variables +-1000x and you want to clean them.
;you can use the Reload Command to empty them.
;but i do not want that the System Tray will be Flashing. and it will reordered all my other Tray icons.
;----------------------------------
#if mode
f1:: ;Restart script and clear all variables.
reload
return
f2::
a1 := 100
;a.... := ....
a1000 := 100
msgbox a1 = %a1% to a1000 = %a1000%
return
f3::
msgbox a1 = %a1% to a1000 = %a1000%
return
~esc::exitapp
#if
;----------------------------------
;----------------------------------
WriteReg_Example1(KeyName,KeyValue)
{
RegWrite, REG_SZ, HKEY_CURRENT_USER,software\Example1,%KeyName%,%KeyValue% ;write Registry for External Program
}
;---------------------------------
Example1Tray.ahk
;#Notrayicon
#Persistent
OnExit, DoExitExternal
#SingleInstance force
mode=1
;Tip - if you change the Name Example1.ahk into Example2.ahk
;Then you can use ReplaceAll Function in Notepad - ReplaceAll Example1 to Example2 and it is done!
WriteReg_Example1("Suspend","0")
WriteReg_Example1("Exit","0")
Menu, Tray, NoStandard ; Remove the Standard Menu items
Menu, Tray, Add , H&elp, DoHelp
Menu, Tray, Add , W&indow Spy, DoWindowSpy
Menu, Tray, Add , S&uspend Script, DoSuspendExternal
Menu, Tray, Add , E&xit, DoExitExternal
;----------------
#If WinNotExist Example1.ahk
{
run Example1.ahk
}
;----------------
loop
{
} ;End Loop
;----------------
DoHelp:
run C:\Program Files\AutoHotkey\AutoHotkey.chm
return
;----------------
;----------------
DoWindowSpy:
run C:\Program Files\AutoHotkey\AU3_Spy.exe
return
;----------------
;----------------
DoSuspendExternal:
WriteReg_Example1("Suspend","1")
if a=1
{
Menu, Tray, Icon , Shell32.dll, 29, 1
a=0
}else{
Menu, Tray, Icon, Shell32.dll, 132, 1
a=1
}
return
;----------------
;----------------
DoExitExternal:
WriteReg_Example1("Suspend","0")
WriteReg_Example1("Exit","1")
sleep 250
ExitApp
return
;----------------
;----------------------------------
WriteReg_Example1(KeyName,KeyValue)
{
RegWrite, REG_SZ, HKEY_CURRENT_USER,software\Example1,%KeyName%,%KeyValue% ;write Registry for External Program
}
;----------------------------------
;----------------------------------
#if mode
~esc::
gosub DoExitExternal
return
#if
;----------------------------------