TrayTip not working (Win10 version 2004)

Get help with using AutoHotkey and its commands and hotkeys
jimhoyle
Posts: 29
Joined: 19 Dec 2015, 15:49

TrayTip not working (Win10 version 2004)

28 Jun 2020, 14:08

This topic has been discussed several times. However, as I suspect the newest Windows 10 version (2004) might have something to do with the issue. So, there are several tricks one must complete in order to get the old style balloons working (or even to get the new toast notifications). We could possibly list them all here for clarity. However, I want to start with the newest trick I encountered (when TrayTip balloon notifications are not appearing at all):

1. Run ms-settings:privacy-backgroundapps
2. "Let apps run in the background" = to DISABLED
3. Restart
4. Run ms-settings:privacy-backgroundapps again, this time "Let apps run in the background" = to ENABLED
5. Restart
6. Now TrayTips work

However, the TrayTips work only for a minute or two! Then, by itself, they stop working again! Repeating steps 1–6 will make it work again for a minute. What is this? Anybody found a solution?
vsub
Posts: 470
Joined: 29 Sep 2015, 03:39

Re: TrayTip not working (Win10 version 2004)

28 Jun 2020, 14:19

It works fine(at least here)but there is a condition
TrayTip,Title; this will not work
TrayTip,,Text; this will work
TrayTip,Title,text; this will work

Before we were able to just type a title and nothing else but that don't work anymore
lexikos
Posts: 6972
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: TrayTip not working (Win10 version 2004)

28 Jun 2020, 22:41

@vsub, omitting Text never worked in AutoHotkey v1.
Warning: The window will not be shown if the Text parameter is omitted, even if a Title is specified.
vsub
Posts: 470
Joined: 29 Sep 2015, 03:39

Re: TrayTip not working (Win10 version 2004)

29 Jun 2020, 04:25

lexikos wrote:
28 Jun 2020, 22:41
@vsub, omitting Text never worked in AutoHotkey v1.
Warning: The window will not be shown if the Text parameter is omitted, even if a Title is specified.
I am using v1 and it worked on Win7 but not on Win10
lexikos
Posts: 6972
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: TrayTip not working (Win10 version 2004)

29 Jun 2020, 05:58

@vsub, your memory is faulty.
To remove a balloon notification, specify NIF_INFO and provide an empty string through szInfo.
Source: NOTIFYICONDATAA (shellapi.h) - Win32 apps | Microsoft Docs
AutoHotkey v1 source code wrote: tcslcpy(nic.szInfo, aText, _countof(nic.szInfo)); // Empty text removes the balloon.
I have verified this (again) just now on a Windows 7 system.
vsub
Posts: 470
Joined: 29 Sep 2015, 03:39

Re: TrayTip not working (Win10 version 2004)

29 Jun 2020, 06:05

Maybe some chance was done to win7 or ahk since 2017(the last time I run ahk on win7)and I was using this code to show me the volume level and it was working fine but when I switch to wi10,I notest that the code did not work with just the text

Code: Select all

VolumeGet:
SoundGet, MasterV
TTL := Round(MasterV)
TrayTip,, Vol: %TTL%`%
Return
lexikos
Posts: 6972
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: TrayTip not working (Win10 version 2004)

29 Jun 2020, 06:11

Maybe some chance was done to win7
No. I could test in a Windows XP VM to prove that the behaviour exists there too, but it would be a waste of time.

Please note the inconsistency between your posts:
Before we were able to just type a title and nothing else
when I switch to wi10,I notest that the code did not work with just the text
Please note the difference between omitting Text:

Code: Select all

TrayTip,Title ; this will not work
and omitting Title:

Code: Select all

TrayTip,, Vol: %TTL%`%
This last code works just fine for me on Windows 10 version 2004.
jimhoyle
Posts: 29
Joined: 19 Dec 2015, 15:49

Re: TrayTip not working (Win10 version 2004)

30 Jun 2020, 07:03

Also, there is a trick to get the Title only:

Code: Select all

TrayTip, TitleOnly,´n
However, this is now off topic.. How to get TrayTip working in Win10 version 2004 in the first place? What is the checklist if it doesn't work at all?
jimhoyle
Posts: 29
Joined: 19 Dec 2015, 15:49

Re: TrayTip not working (Win10 version 2004)

10 Jul 2020, 12:17

I still couldn't figure out what's preventing the notifications from appearing. I have a hunch though. I used to be able to drag a file from Explorer (non-elevated, as normal) to Resource Hacker (ResourceHacker.exe) which is run elevated. But, now that doesn't work. So I used to be able to drag from non-elevated to elevated without problems. I don't know why that doesn't work anymore. These two issues may be related. Perhaps some gpedit.msc policy has changed.

I run AutoHotkey elevated by the way. Any ideas for either issue?
jimhoyle
Posts: 29
Joined: 19 Dec 2015, 15:49

Re: TrayTip not working (Win10 version 2004)

10 Jul 2020, 17:13

Ah, I think I might have found the cuprit. Bitdefender Total Security. It seems to think AutoHotkey.exe and/or the tray notification process is malware, even though this detection may happen silently, i.e. nothing in quarantine or anywhere. Bitdefender did, however, suddenly complain about AutoHotkey.exe, so I think it may have done something silently all along. I have to investigate further. Meanwhile, here's an alternative method to trigger a tray notification, using PowerShell (good for testing purposes).

Code: Select all

function ShowBalloonTipInfo
{
  [CmdletBinding()]
  param
  (
    [Parameter()]$Title,
    [Parameter()]$Text,
    $Icon = 'None'
  )

  # ---------------------------------------------------------
  # $Icon above must be: 'None', 'Info', 'Warning' or 'Error'
  # ---------------------------------------------------------

  Add-Type -AssemblyName System.Windows.Forms
 
  if ($script:balloonToolTip -eq $null)
  {
    $script:balloonToolTip = New-ObjectSystem.Windows.Forms.NotifyIcon 
  }
 
  $path = Get-Process -id $pid | Select-Object -ExpandProperty Path
  $balloonToolTip.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
  $balloonToolTip.BalloonTipIcon = $Icon
  $balloonToolTip.BalloonTipText = $Text
  $balloonToolTip.BalloonTipTitle = $Title
  $balloonToolTip.Visible = $true
  $balloonToolTip.ShowBalloonTip(1000)
            # display time in ms ^^^^ however it doesn't make a difference?
}
 
ShowBalloonTipInfo "Custom title" "Custom text"
Put that into ShowBalloonTip.ps1 and then run in any command prompt like this:
powershell -executionpolicy bypass -file ShowBalloonTip.ps1
jimhoyle
Posts: 29
Joined: 19 Dec 2015, 15:49

Re: TrayTip not working (Win10 version 2004)

14 Jul 2020, 10:33

So, it turns out that .ps1 (above), while it works (at least for me on Win10 v2004) and shows toasts or balloons, it is somehow problematic. If repeated a few times, all notifications seem to stop on my system. Possibly related to Bitdefender, possibly not.

Why classic balloons instead of modern toasts? Mainly because all toasts go into Action Center (the Win10 right side pane). I do want to see some critical notifications in Action Center, so I don't want to disable it completely. However, all TrayTip toasts add an entry in Action Center, so then there's an annoying white notification in the bottom right corner until Action Center is opened and the new entry is cleared. And there was no way to disable that. Well, this is what I came up with for that (clearing previous TrayTip notification out of Action center):

Code: Select all

x::
ControlGet, ShellTray, Hwnd,, TrayButton2, ahk_class Shell_TrayWnd ; TrayButton2 should be Action Center
ControlClick, , ahk_id %ShellTray% ; open Action Center
Send {Tab 3}{Enter} ; this should close the previous notifying app's notifications
ControlClick, , ahk_id %ShellTray% ; close Action Center (if it was open)
Return
But that's a horrible solution. So that's why classic balloons are necessary. I think I might have now gotten TrayTip balloons working reliably again. Will post again if it breaks again, but this is now my newest checklist if they don't work (I think the first in the list was supposed to be Enabled in a pre-v2004 Win10 but I'm not sure):
  • gpedit.msc: User Configuration / Administrative Templates / Start Menu and Taskbar / Notifications / Turn off toast notifications = Not configured
  • gpedit.msc: User Configuration / Administrative Templates / Start Menu and Taskbar / Disable showing balloon notifications as toasts = Enabled
  • regedit: Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\EnableBalloonTips (DWORD) = 1
lexikos
Posts: 6972
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: TrayTip not working (Win10 version 2004)

17 Jul 2020, 05:47

It seems to me that a more robust solution would be to show your own notification window with Gui or (for v1 only) SplashTextOn, SplashImage or Progress.

If you just don't want the notifications hanging around in the Action Center, you can hide it whenever you want if you use the proper notification API. You can experiment with the APIs via ActiveScript.

If you just open the Action Center and then close it, the button will no longer be white. Send #a{Esc} works for me, and is very quick.

There's another solution for the annoying white notification:

Code: Select all

Control Hide,, TrayButton2, ahk_class Shell_TrayWnd
:HeHe:
jimhoyle
Posts: 29
Joined: 19 Dec 2015, 15:49

Re: TrayTip not working (Win10 version 2004)

17 Jul 2020, 13:05

Wowa-weewa, mamma mia, fantastic tips. That toast API works even simultaneously with the classic balloon enabled (and showing simultaneously). And the notification clearing works. Extremely useful! :bravo:
jimhoyle
Posts: 29
Joined: 19 Dec 2015, 15:49

Re: TrayTip not working (Win10 version 2004)

18 Jul 2020, 13:44

About the ActiveScript toast. I am now triggering toasts like this:

%A_ScriptDir%\AutoHotkey.exe %A_ScriptDir%\API\Example_JsRT_Toast.ahk "title "text "smalltext"

and I modified that Example_JsRT_Toast.ahk to wait for 6500 ms and then hiding the notification instead of asking whether to hide it.

Is there a way to hide the previous ActiveScript toast immediately if a new one is triggered? Because I frequently need to trigger multiple toasts quickly, but I don't want to wait for about 7 seconds repeatedly for each consecutive toast to finally appear. Sounds simple, but how to do it? Gets so complicated in my head, there must be a simple way to achieve this.
lexikos
Posts: 6972
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: TrayTip not working (Win10 version 2004)

18 Jul 2020, 21:04

This will hide all previous notifications:

Code: Select all

Windows.UI.Notifications.ToastNotificationManager.history.clear(app)
Mostly you can just refer to the WinRT API documentation, but for JavaScript you must remember that methods and properties have a lowercase first letter. Namespaces and classes do not.

If you want to hide specific toasts, refer to the ToastNotificationHistory class. However, from desktop apps such as this, you can probably only use the methods that take an app ID.
jimhoyle
Posts: 29
Joined: 19 Dec 2015, 15:49

Re: TrayTip not working (Win10 version 2004)

20 Jul 2020, 17:35

Perfect, that clear(app) works perfectly.

About the original problem, balloons not showing at all. Unfortunately that problem returned for me. Basically at random times, anywhere between minutes to days, the balloons stop working for me. I checked and even that Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\EnableBalloonTips (DWORD) = 1 had gone back to 0 by itself. But, after fixing that, also restarting explorer (or rebooting), balloons worked randomly and now they don't work anymore again. Something's going on, I couldn't figure out what. Just thinking out loud, perhaps that will get solved one day.

EDIT: I confirmed that some of the older than 2004 builds of Win10 don't even need that EnableBalloonTips = 1 and balloons still work. Something might be strange with my system as also sometimes I get high CPU usage for explorer.exe without any good reason. I already did in-place upgrade of Win10 and it didn't help, strange.
jimhoyle
Posts: 29
Joined: 19 Dec 2015, 15:49

Re: TrayTip not working (Win10 version 2004)

06 Aug 2020, 03:33

I just found another security feature which may have possibly been interfering with my TrayTip notifications. Programs today are too "automatic" so it's very difficult to keep up on what is doing what. I just found that Acronis True Image backup software also has kind of blacklist/whitelist for programs. So I had to do: Acronis True Image / Active Protection tab / Monitored. There was AutoHotkey and I had to Allow it!

Edit: bummer, back to drawing board. After that Acronis whitelisting, still after a few hours the TrayTip stopped working.

Return to “Ask For Help”

Who is online

Users browsing this forum: Burnsy, eL Tux, karkas and 53 guests