Get a TrayTip whenever your script is reloaded

Post your working scripts, libraries and tools
aph
Posts: 7
Joined: 29 Jan 2018, 21:53

Get a TrayTip whenever your script is reloaded

Post by aph » 06 Feb 2018, 19:21

Code: Select all

; Description: Get a TrayTip whenever your script is reloaded
; Permalink: https://autohotkey.com/boards/viewtopic.php?t=43865
; Author: aph
; Version: 0.1
FileGetAttrib, attribs, %A_ScriptFullPath%
if (attribs="A") {
   FileSetAttrib, -A, %A_ScriptFullPath%
   TrayTip, Reloaded script, %A_ScriptFullPath%,, 1
}
OnExit, ExitSub
Return
ExitSub:
   if (A_ExitReason="Reload") {
       FileSetAttrib, +A, %A_ScriptFullPath%
   }
ExitApp
For example, works well with:

Code: Select all

; Alt+Shift+R to reload AutoHotkey script
+!r::Reload
Last edited by aph on 11 Feb 2018, 08:39, edited 2 times in total.
aph
Posts: 7
Joined: 29 Jan 2018, 21:53

Re: Get a tray tooltip whenever your script is reloaded

Post by aph » 08 Feb 2018, 19:47

No question. I corrected "tray tooltip to clarify that this code gives you a TrayTip whenever the Reload command is issued.

Normally this would not be possible since since AHK is reloading, removing all its widgets.

By temporarily toggling the archive attribute on the currently running script when it exits due to a reload, we can issue a TrayTip when it loads again.
lexikos
Posts: 6175
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Get a TrayTip whenever your script is reloaded

Post by lexikos » 12 Feb 2018, 04:24

Why modify the file's attributes?

You can detect whether the script was reloaded by looking at its command line.
Post Reply

Return to “Scripts and Functions”