Sensor alert behaviour

quanzi

Member
Version 7.14-4610
Version: 64-bit
OS: Windows 10

I'm relying exclusively on HWiNFO sensor alert to monitor my laptop's charge level:

1638523636728.png

The idea is simple: when the charge level reaches 75%, I unplug my laptop; when it reaches 44%, I plug it back in.

The problem is, I used a multi-monitor setup. So, say, the alert window shows up on the main display, I'm focusing on other displays so I ignore that for a while, because according to the above settings, it will notify me again in 10 minutes, right?

Actually, the alert window will totally lock up all other sensors (i.e. none of their values will be updated while the alert window is still showing), and thus the second notification will never happen.

Very often that when I finally get around to close the first alert window, the charge level goes up to 90%+ since I ignore it for too long.

What's worse is after seeing the charge level at 90%+, I unplug my laptop. After a while, another alert window shows up on the main display saying the charge level has gone down to 8x% (>= 75%). I tend to forget about that one too, so after using my laptop unplugged for a while, the battery drops all the way down to sub 20% while HWiNFO still shows 8x% charge level.

I can think of some ways to fix this:
  • Add a new option so the alert window will only display for a set amount of time, after which it will diseapper on its own
  • Make it so the alert window won't lock up every sensor (not really sure if possible)
Thank you for looking into this.
 
Last edited:
For such use case I'd recommend to configure the alerts to rather start a custom program that would perform a custom notification. There are surely lots of various small and free tools that could be used.

Or you could for example use the following simple Visual Basic script to display a message:
1. Extract msg.vbs from the attached msg.vbs.zip file and place it anywhere on your drive
2. Configure the alert to Run a Program instead of Displaying a Warning Window:
- Program name: wscript.exe, which is the Visual Basic script interpreter built into Windows and resides in \Windows\System32. So the full path would look like: c:\Windows\System32\wscript.exe
- Use the following Arguments for the program: {PATH_TO_THE_VBS_FILE}\msg.vbs "%s is %v"
Make sure to replace {PATH_TO_THE_VBS_FILE} with the path where you stored the vbs file. The "%s is %v" specifies the text that will be displayed in the message box, in this case it's: {Sensor Name} is {Sensor value}. You can customize this as you wish.

Hope this helps.
 

Attachments

  • msg.vbs.zip
    223 bytes · Views: 8
For such use case I'd recommend to configure the alerts to rather start a custom program that would perform a custom notification. There are surely lots of various small and free tools that could be used.

Or you could for example use the following simple Visual Basic script to display a message:
1. Extract msg.vbs from the attached msg.vbs.zip file and place it anywhere on your drive
2. Configure the alert to Run a Program instead of Displaying a Warning Window:
- Program name: wscript.exe, which is the Visual Basic script interpreter built into Windows and resides in \Windows\System32. So the full path would look like: c:\Windows\System32\wscript.exe
- Use the following Arguments for the program: {PATH_TO_THE_VBS_FILE}\msg.vbs "%s is %v"
Make sure to replace {PATH_TO_THE_VBS_FILE} with the path where you stored the vbs file. The "%s is %v" specifies the text that will be displayed in the message box, in this case it's: {Sensor Name} is {Sensor value}. You can customize this as you wish.

Hope this helps.
Hello, thanks for the ingenious suggestion of using wscript.exe. After a bit of digging around, I finally found a way to display a self-closing toast notification in Windows 10.

For anyone interested:
1. Open Notepad, paste the following lines in and save it as "toast.ps1":
Code:
[reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[reflection.assembly]::loadwithpartialname("System.Drawing")
$notify = new-object system.windows.forms.notifyicon
$notify.icon  = [System.Drawing.SystemIcons]::Information
# remove hashtag before the 2 following lines if you want to use your custom icon
# $icon = New-Object system.drawing.icon ("[PATH_TO_YOUR_CUSTOM_ICON_HERE]\[ICON_NAME].ico")
# $notify.icon = $icon
$notify.visible = $true

# first parameter is the duration of the toast notification (deprecated, now controlled by system accessibility settings), second one is its title, third one is the messsage to be shown and last one is the icon
# change the last parameter in the following line from blahblahblah]::Warning to blahblahblah]::None if you want to use the same icon as the one in the systray (i.e. $notify.icon)
$notify.showballoontip(20,"Warning",$args,[system.windows.forms.tooltipicon]::Warning)

2. Open Notepad, paste the following lines in and save it as "run-ps.vbs":
Code:
Set args = CreateObject("System.Collections.ArrayList")
For Each oItem In Wscript.Arguments: args.Add oItem: Next

CreateObject("Wscript.Shell").Run("powershell -windowstyle hidden -File """ & Join(args.ToArray, """ """) & """"),0

3. Configure the alert to Run a Program instead of Displaying a Warning Window:
- Program name: wscript.exe (full path C:\Windows\System32\wscript.exe)
- Use the following Arguments for the program:

Code:
"[PATH_TO_THE_VBS_FILE]\ps-run.vbs" "[PATH_TO_THE_PS_FILE]\toast.ps1" "%s is %v %"

Result:
1639111245262.png

Note:
If this is your first time running a "ps1" file with PowerShell, your user account may have an undefined ExecutionPolicy, which you have to set by opening PowerShell in administator mode and run the following code:
Code:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
 
Last edited:
This actually works, unlike other methods to create this type of notification. I saved the VBS file as "ps-run.vbs" instead of "run-ps.vbs" since that is what the argument in HWiNFO specifies. The only problem is that blue circle icons accumulate in the taskbar, and hovering over those or opening the overflow causes all of the notifications to disappear from the history.
 
There are several reasons why the built-in alert boxes should not obstruct further activity. Say there is a warning when the memory usage reaches 90%, and it pauses multiple applications at 95% to prevent those from using even more memory (this can be done with PsSuspend64). What if I walk away, and the memory usage blows through the roof because the warning at 90% prevented the safety latch at 95% from executing? Or what if I have external HDDs with fans controlled by alerts, and one HDD is defective and has a warning, causing it and all others to overheat and burn-out even faster?

Is there any way to add buttons to these notifications as there is with regular VBS popups, or have the notification run something after it closes? Since the SSD overheats and no compatible fan control programs support Shared Memory, I have to use alerts to turn the fan on. It is currently only possible to set 1 level, and therefore it is too frightening when it turns up unexpectedly. That is fixed by having a message saying the fan will increase in 3 seconds. With the corner notification, only the notification can occupy the arguments within HWiNFO, and it does not appear the ps-run.VBS or Warning.PS1 can be configured to turn the fan up after it closes, unlike the regular VBS popup.
 

Attachments

  • SSD.zip
    771 bytes · Views: 2
Sorry for the late reply. You can fix this by adding this line at the end of the ps1 file:
Code:
$notify.dispose()
One the notification auto-hides, it, along with its icon in the systray, will disappear altogether.
It's not much of an issue since there are usually only a few, the main problem is hovering over the icons clears the notification history, which is desirable to not clear.

Shortly after the flood of icons, the notifications completely stopped working, only showing the icons and no actual notifications. Running the Set-ExecutionPolicy again does not work. The VBS file, the PS1 file, and the arguments have been examined at least 4 times for errors. Nothing can change it.

Thank you for this method that actually works! All the other references for the same thing do not work. If it didn't break for no reason, I would be able to take advantage of these useful instructions.
 
Back
Top