Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Notify() - multiple easy tray area notifications - v0.4991


  • Please log in to reply
319 replies to this topic
gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
thanks... so there basically is no standard... hmm... oh well...

could yuo clarify the naming convention you mentioned, labels? _NotifyLabel: or Notify_Label:

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
I meant _NotifyLabel. Somewhere someone says that helper functions in a lib should start with a _ and also global lib vars with a _ so to be consistent labels should probably also start with an _ :?: (but what do I know)

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
i guess that makes sense, and i'll probably make the changes, but don't really like underscores all over the code... but with a name like notify, conflicts could arise... no helper functions or globals needed, so labels are easy enough

new version in first post, 0.43, cleaned up code some, made "_" change, fixing AT (action on timeout instead of click) now, changed Reset option functionality (!!)...

code needs a lot of optimizing (the ShowToolTip() thread has some tips i may try for having a single timer instead of one for each notification) but after AT i think all functionality i want is in there,

tho i may add a sound option (wav file, soundbeep, TTS()) but not sure if that should be handled scriptside or functionside (feedback??)


-gwarble

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
compiling a simple script like:
#SingleInstance Off
;#NoTrayIcon
 If %0%
 {
  Loop %0% ;= not sure how to put %1% into the function call
   CL%A_Index% := %A_Index%
  If (CL3)
   CL3 := -Abs(CL3)    ;= negative to exitapp after notification
  Notify(CL1,CL2,CL3,CL4,CL5)
 }
 Else
  Notify("Notify Command Line:", "Notify.exe ''Title'' ''Message'' Seconds ''Options'' ''Image''",-30,"",44)
Return
#Include Notify.ahk
yields Notify.exe, which is a useful command line tool (for batch files) to display notifications (without conflicting from those in any scipt using Notify()!) this could easily be expanded to run an application or something on AC or AT...

A dll option would be equally great; Notify.dll... I don't want to bother the AutoHotKey.dll thread since i don't think it is one of the goals of that project yet, but it'd be sweet to be able to compile an AHK function(s) into a .dll, which could then be called from any language

- gwarble

Edit: using the above in a batch file (.cmd, .bat):
notify.exe waiting...
start /wait notify.exe also waiting
start notify no waiting
notify waiting
can be a good replacement for "pause" or delays or simple UI if nothing else, especially if the command prompt window is not visible... and of course copying notify.exe to your path (win\system32) allows you to use it in any batch file as just "notify x x x"

Edit: to make Notify a better MsgBox equivalent, i'm planning to add a pause script option (or an integrated notification and wait call), and an easier way to use the 4 msgbox icons, probably in the options parameter (like how reset is now?) basically a shortcut to using IN=1-5 and user32.dll as the image (i was wondering where those icons were)

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
i'm not sure if anyone uses this (hugov?), but i'm finding it very useful, and have some plans for implementing options in 2 fashions, the current way, and also without the equals sign to:
show the same modified notification, but not change the static setting... so you could run a colored notification and then the following would revert to the defaults (or statics set with = options)


also planning to clean up the syntax for this functionality, one of the common ways i use it:

NotifyID := Notify("Title","Msg",0)
Sleep, 5000 ;do something useful and time consuming
Notify("","",0,"Wait",NotifyID)
Notify("Finished!","",3)

or to simulate a paused thread like msgbox (until clicked):
Notify("","","","Wait",Notify("Pause"))

let me know what you think...

oh also, i need to remove the gui, #:default line so it doesnt effect the running script... anyone know how to detect the notifications without changing the last found window??

- gwarble

doyle
  • Members
  • 335 posts
  • Last active: Mar 02 2012 04:47 PM
  • Joined: 14 Nov 2007
Very, very, nice function gwarble.

And sleek design too.

I'm still absorbing how it works, so forgive me if my question is stupid.

I work on multiple monitors and sometimes it would be good to create a Notify() on a monitor that is not the default. (i.e One that does not have the taskbar.)

Is this something that is possible? Could I make the change easily myself, or is it more complicated?

Thanks again!

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
Yes I use it 8)

Perhaps you can clarify this example for me (and others):
NotifyID := Notify("Title","Msg",0)
Sleep, 5000 ;do something useful and time consuming
Notify("","",0,"Wait",NotifyID)
Notify("Finished!","",3)
Why did you choose to keep the Notify "active", e.g. the script doesn't 'exitapp' after the you click the notify windows, that part of the lib I never quite got. I mainly use it with the "-3" option to close it. I like to use notify to let me know when certain scripts have finished or are closing... or simple reminders (e.g. go home now)

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
Hey HugoV, thanks for the feedback and i'm glad you're using it... in the case of a script that does something, and only one thing, you're right... thats how i use it as well...

for your reminders, or for the scripts i usually use it in, which are persistent (two applications i wrote use it a lot, and never exit with them (they exit like any normal app, the notify's are there for status updates, like when firefox tells you a download has completed)

thats when i use that example... so the Title-Message notification will show (and flash, which for me means working)... then some work is done by the script (ie processing a large file, or that sleep 5000), then the "Wait" command kills that notification before showing the finished one...


i should write up some real documentation for these possibilities i guess

thanks
- gwarble

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
Just to be sure, what I meant was if you run the above script, it remains active in the systray after the script is finished and you have clicked the notifications as well. E.g. if I use notify in my script I either must use "-seconds" OR explicitly add an exit(app) to my script to ... well exit :D Once there are no more notify windows why does if have to remain "active"

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
well its either or... using -seconds is useful when the script does one thing and then exits itself, as u are using it...

the above is useful for a script that acts as an application, ie: persistent, has an exitapp in a GuiClose: or something... i'll post an example when i'm not at work, but this might make more sense:

^1:: ;= CTRL-1
NotifyID := Notify("","Parsing emails...",0)
GoSub, ParseEmails
Notify("","",0,"Wait",NotifyID) ;= closes last notification
Notify("email parsing finished","",3)
GoSub, GuiCreate
Return

ParseEmails:
 Sleep 10000 ;= parsing the emails takes n seconds, where n > 0
Return

GuiCreate:
;make a gui that shows the parsed emails
Return

GuiClose:
ExitApp
Return

make any more sense?

another example that just waits for a click:

Notify("","","","Wait",Notify("click here"))

but this should allow a -0 for time to exitapp the way u use it but currently "-0" hasnt been fixed

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
No not really (bit is probably just me) :D
I don't understand why notify should keep a script "open" when it is done notifying. The "-seconds" is useful as you as you can use it to exitapp as well, but why does "seconds" keep the script open when the seconds have passed.
(Disclaimer: I haven't looked at the Notify code indepth, I merely use it, if I did it might sink in)

  • Guests
  • Last active:
  • Joined: --
hmm.... i didnt think that was very far fetched... are all of the scripts you write dedicated to one task (never persistent?)


imagine a script that uses Notify() at the beginning to say welcome to the script:

Notify("Welcome",A_ScriptName,5)



and then a little more advanced (but still at startup):

NotifyID := Notify("loading settings",A_ScriptName,0)
Sleep 5000 ;= pretend to be loading settings or something
Notify("","",0,"Wait",NotifyID) ;= closes last notification
Notify("settings loaded successfully ",A_ScriptName,5)
Sleep 4000
Notify("Goodbye","",-3) ;= this one does exitApp




these examples are using notify() without being involved with the exitapp at all...

make sense?

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
hey, i think the confusion may be arising because using Notify() would cause a normally non-persistent script to become persistent without the # directive (because of using gui commands), so thats why a negative duration is used...


what i'm talking about is a script that is persistent (# directive or not) and desired to be, in which you usually have to use an exitapp somewhere anyway... in these cases one can use Notify() all over the place, not wanting to exitapp... except maybe Notify("goodbye","",-3) at the end for the exitapp.

I've written a few applications (that i run and distribute compiled) that use it, some for real time notifications of other equipment, some for "balloon tip" replacements (for multiple simultaneous)...

- gwarble

doyle
  • Members
  • 335 posts
  • Last active: Mar 02 2012 04:47 PM
  • Joined: 14 Nov 2007
When Notify()'s are created, do you think it would be possible to Dock them to a window, using Majkinetors Dock() function?

Or are we restricted to where Notifys can appear?

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
sure it would be possible... from what i've seen of Dock()... i think that may merit another aux function, but i was toying with the idea of making the position on the screen optional (ie centered, left side, etc) and docking may be a nice option to include, i'll look into it

part of the purpose of the notifications done like this is to support multiple, from any number or scripts/sources... and not have them interfere/cover eachother... how would you like that handled in the case of docked notifications? probably stack them in the window they are docked to, and ignore ones that are docked to other windows/desktop??

- gwarble

thanks for trying it