AHK using Notify() to advise on actions

I came across Notify() and saw there were a lot of different things you can do with the function.

It gives you a Toast Pop-up when somerthing happens. So when you fire up AHK scripts you can have a notification of that, as well as when you are shutting programs down. That makes you aware of that even taking place.

I also came across a usage of using it to show Variables when you are testing scripts. That seems like a great idea too.

The original forum went on for 23 pages, so there was a lot of interest in it.

there is a Function and a Class. I’ve been trying out the function but may move across to the class.

I can see this being handy with some of the scripts I use intermittently, like “Capture Time” & “FileSaveLaunch” , as well as some of the scripts I have in AHK Commander which will tell me whether they are active or when I close them.

I had a middling interest in this function when I was looking at stuff on the archive scripts site https://autohotkey.com/board/forum/49-scripts-and-functions/ but then I saw a remark about testing and vars and I thought it would be worth a crack.

I got the original function one working quite easily and had no problem with setting that up on the morning PC , but then I wanted to try and use the Class Notify() and ran into a few issues.

Notify Function

There are a couple of videos about Notify() done by the automator, first is about the initial function one with a mention of the class one:

Refer video for the code

Notify Class

The 2nd video is about class one and somewhere he mentions having a pop-up notification with buttons that you can say 5min or 15 min and the notification comes up that way. The Class demo also showed buttons that showed the variables that were stored in the object that you get when you click on it and they are key/value pairs.

Refer video for the code

So I tried to make a button that would wait for a period and then pop-up again and had real difficulty in getting the value from the object.

  global Text
  global TT
  global Time
  for a,b in Obj

  if Obj.a == 0Snooze1

    ;MsgBox,  %b%  ;Obj[1]
    sleep , %b%

    Notify().AddWindow(Text[TT],{Size:Size,Icon:Icon "," Ico,IconSize:IconSize,Title:Title,TitleColor:TitleColor,TitleFont:TitleFont,TitleSize:TitleSize,Background:Background,Color:Color,Time:Time,Buttons:"This,One,Here"}) ;Flash:1000,


So I had an object Obj with a load of key/value pairs and the original script looped through them and showed them in a gui when you clicked on a button, as below, but found it really difficult accessing the value that I wanted to use further on in the program.

I was trying to get b when a== 0Snooze1 so tried Obj.b, Obj[0] or [1] and all sorts of things, it ended up inside the function you just call b on its own. That took ages to get , after that I lost interest in it.

End comment

So now I’ve set it up on Main PC with programs I use intermittently, just to advise I’ve activated them.

In the end, I may consider going back to the function one as that was easier to implement. I’ve got them both running and now I’ll have to find uses for them.