Do a Reload Without Flashing The Tray Icon - Autohotkey Script

0

I want to do a Reload Without Flashing The Tray Icon, on my Windows 10 64/bit System.

Is there a Simple Autohotkey Script that i can use.

i do not want, if i run the Reload Command, that My Autohotkey Tray Icon does Disappear and then in a Certain Time will appears back. (and it will reordered all my other Tray icons on my Taskbar.)

If you run this Ahk Script and the Click on the [F1] key, you can see what i mean.

#SingleInstance force

;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.

f1:: ;Restart script and clear all variables.
reload
return

f2::
a1 := 100
;a.... := ....
a1000 := 100
return


~esc::exitapp

.

Shout it not be great if you can write a Ahk Script that can Reload and Ignore the Tray Icon, if it is already existing on the System Taskbar why shout we want to reload it again, or if you can use a command, something like this [ReloadIgnoreTray] or [#ReloadIgnoreTray] so like [#notrayicon]

Maybe the Creators that did maked Autohotkey can change or Upgrade that Reload command, the Reload command must only do this, first look to the Name of that Tray Icon if existing then Ignore Reload the Tray Icon. (the only question is, is it possible to change the TrayMenus without to must have reload that Tray Icon)

Philip Lavour

Posted 2018-01-23T16:35:44.653

Reputation: 38

Answers

1

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.

  • Example1.ahk - is your Main Script. (This Does Have a #Notrayicon command to Hide the Tray Icon.)

  • Example1Tray.ahk is the External Script. (if you run this it will automatic run the Main Script)

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
;----------------------------------

Frank Quardro

Posted 2018-01-23T16:35:44.653

Reputation: 28

1

What are you trying to accomplish by performing the reload?

You probably won't be able to (easily) modify the default reload behavior for the reload command baked into AutoHotkey, but you can likely re-initialize all of your variables as needed by calling a function call and possibly just adding it to the tray menu as a "Soft Reload" option that will clear the internal state variables that you'd like to clear.

If you were trying to automatically close dialogs and things of that nature it might be a bit more complicated.

I would start with adding an option to the tray menu and getting an external function in place that will execute when you select that option, and then adding code to that function to reset what you'd like to have reset, without forcing a full reload that will reset the position of the tray icon.

Main:

    Menu, Tray, Add, SoftRestart, myFuncSoftRestart
Return

f1::reload

f2::
    a := 100
    a100 := 100
return    

myFuncSoftRestart() {       ; use this function to clear internal state variables
    a :=""
    a100 := ""
}

JJohnston2

Posted 2018-01-23T16:35:44.653

Reputation: 1 341