- Home
- Sitemap
- Product Forums
- Uniface®
- Uniface® Forum Home
- Accessing the windows notifications.
Accessing the windows notifications.
- March 25, 2022
- 10 replies
- 2 views
- Inspiring
We did write a VB dll to access the NotifyIcon class, but access to this has stopped working and my VB expert is on maternity leave.
If there were a standard method, that would be lovely.
Regards,
Iain
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
10 replies
- Participating Frequently
- March 28, 2022
We did write a VB dll to access the NotifyIcon class, but access to this has stopped working and my VB expert is on maternity leave.
If there were a standard method, that would be lovely.
Regards,
Iain
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
------------------------------
Jean-Marc Salis
Mp Services
Montauban Cedex FR
------------------------------
- Author
- Inspiring
- March 30, 2022
------------------------------
Jean-Marc Salis
Mp Services
Montauban Cedex FR
------------------------------
I'm looking for something which could be used to alert the user to look at the Uniface app even if they are not currently, and which doesn't require clicking on to move on with the uniface code (so, exactly like the 'new mail' popup in the bottom right of the windows screen (task bar "NotifyIcon" functionality).
If there's javascript which can trigger this popup, my google fu is inadequate to the task of finding it.
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
- Participating Frequently
- March 30, 2022
I'm looking for something which could be used to alert the user to look at the Uniface app even if they are not currently, and which doesn't require clicking on to move on with the uniface code (so, exactly like the 'new mail' popup in the bottom right of the windows screen (task bar "NotifyIcon" functionality).
If there's javascript which can trigger this popup, my google fu is inadequate to the task of finding it.
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
https://www.javascripttutorial.net/web-apis/javascript-notification/
With it, in a browser (and with the authorization) you can trigger OS notifications (tried it on Debian/GNOME and Windows). Depending on the possibilities of the browser/widget, you can also add an icon.
But it will be very dependant on the widget, and I'm not even sure it's possible :-)
(My Uniface HTML widget fu are very low)
------------------------------
Jean-Marc Salis
Mp Services
Montauban Cedex FR
------------------------------
- Participating Frequently
- March 30, 2022
We did write a VB dll to access the NotifyIcon class, but access to this has stopped working and my VB expert is on maternity leave.
If there were a standard method, that would be lovely.
Regards,
Iain
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
VB script can be replaced by powershell command, and you can find on google many examples like :
powershell -Command "Add-Type -AssemblyName System.Windows.Forms ; $global:balloon = New-Object System.Windows.Forms.NotifyIcon ;$path = (Get-Process -id $pid).Path;$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;$balloon.BalloonTipText = 'What do you think of this balloon tip?';$balloon.BalloonTipTitle = \\"Attention $Env:USERNAME\\" ;$balloon.Visible = $true ;$balloon.ShowBalloonTip(5000)"
You can run this by spawn or oscommand ... it's a bit longer but it works...ATTENTION : Do not use powershell script, it's block by Windows security...
Gilles .
------------------------------
Hortion Gilles
Agfa-Gevaert NV
------------------------------
- Author
- Inspiring
- March 30, 2022
VB script can be replaced by powershell command, and you can find on google many examples like :
powershell -Command "Add-Type -AssemblyName System.Windows.Forms ; $global:balloon = New-Object System.Windows.Forms.NotifyIcon ;$path = (Get-Process -id $pid).Path;$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;$balloon.BalloonTipText = 'What do you think of this balloon tip?';$balloon.BalloonTipTitle = \\"Attention $Env:USERNAME\\" ;$balloon.Visible = $true ;$balloon.ShowBalloonTip(5000)"
You can run this by spawn or oscommand ... it's a bit longer but it works...ATTENTION : Do not use powershell script, it's block by Windows security...
Gilles .
------------------------------
Hortion Gilles
Agfa-Gevaert NV
------------------------------
trigger detail
variables
string v_sql, v_line
endvariables
debug
v_sql = "powershell -Command %%"Add-Type -AssemblyName System.Windows.Forms ;"
v_sql = $concat(v_sql," $global:balloon = New-Object System.Windows.Forms.NotifyIcon ;")
v_sql = $concat(v_sql," $path = (Get-Process -id $pid).Path;")
v_sql = $concat(v_sql,"$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;")
v_sql = $concat(v_sql,"$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;")
v_sql = $concat(v_sql,"$balloon.BalloonTipText = 'What do you think of this balloon tip?';")
v_sql = $concat(v_sql,"$balloon.BalloonTipTitle = 'Attention $Env:USERNAME' ;")
v_sql = $concat(v_sql,"$balloon.Visible = $true ;")
v_sql = $concat(v_sql,"$balloon.ShowBalloonTip(5000)%%"")
activate "SYS_OSCOMMAND".COMMANDOUT(v_sql, v_line)
Which sets v_sql =
powershell -Command "Add-Type -AssemblyName System.Windows.Forms ; $global:balloon = New-Object System.Windows.Forms.NotifyIcon ; $path = (Get-Process -id $pid).Path;$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;$balloon.BalloonTipText = 'What do you think of this balloon tip?';$balloon.BalloonTipTitle = 'Attention $Env:USERNAME' ;$balloon.Visible = $true ;$balloon.ShowBalloonTip(5000)"
Running this from the command prompt does the popup. Running it from the OSCOMMAND signature, does nothing, and returns $status=0 and nothing in v_line)
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
- Participating Frequently
- March 30, 2022
trigger detail
variables
string v_sql, v_line
endvariables
debug
v_sql = "powershell -Command %%"Add-Type -AssemblyName System.Windows.Forms ;"
v_sql = $concat(v_sql," $global:balloon = New-Object System.Windows.Forms.NotifyIcon ;")
v_sql = $concat(v_sql," $path = (Get-Process -id $pid).Path;")
v_sql = $concat(v_sql,"$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;")
v_sql = $concat(v_sql,"$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;")
v_sql = $concat(v_sql,"$balloon.BalloonTipText = 'What do you think of this balloon tip?';")
v_sql = $concat(v_sql,"$balloon.BalloonTipTitle = 'Attention $Env:USERNAME' ;")
v_sql = $concat(v_sql,"$balloon.Visible = $true ;")
v_sql = $concat(v_sql,"$balloon.ShowBalloonTip(5000)%%"")
activate "SYS_OSCOMMAND".COMMANDOUT(v_sql, v_line)
Which sets v_sql =
powershell -Command "Add-Type -AssemblyName System.Windows.Forms ; $global:balloon = New-Object System.Windows.Forms.NotifyIcon ; $path = (Get-Process -id $pid).Path;$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;$balloon.BalloonTipText = 'What do you think of this balloon tip?';$balloon.BalloonTipTitle = 'Attention $Env:USERNAME' ;$balloon.Visible = $true ;$balloon.ShowBalloonTip(5000)"
Running this from the command prompt does the popup. Running it from the OSCOMMAND signature, does nothing, and returns $status=0 and nothing in v_line)
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
spawn "powershell -Command %%"Add-Type -AssemblyName System.Windows.Forms ; $global:balloon = New-Object System.Windows.Forms.NotifyIcon ;$path = (Get-Process -id $pid).Path;$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;$balloon.BalloonTipText = 'What do you think of this balloon tip?';$balloon.BalloonTipTitle = \\%%"Attention $Env:USERNAME\\%%" ;$balloon.Visible = $true ;$balloon.ShowBalloonTip(5000)%%""
Work also with oscommand by adding cmd /c :
activate "OSCOMMAND".command("cmd /c powershell -Command %%"Add-Type -AssemblyName System.Windows.Forms ; $global:balloon = New-Object System.Windows.Forms.NotifyIcon ;$path = (Get-Process -id $pid).Path;$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;$balloon.BalloonTipText = 'What do you think of this balloon tip?';$balloon.BalloonTipTitle = \\%%"Attention $Env:USERNAME\\%%" ;$balloon.Visible = $true ;$balloon.ShowBalloonTip(5000)%%"")
------------------------------
Hortion Gilles
Agfa-Gevaert NV
------------------------------
- Author
- Inspiring
- March 30, 2022
spawn "powershell -Command %%"Add-Type -AssemblyName System.Windows.Forms ; $global:balloon = New-Object System.Windows.Forms.NotifyIcon ;$path = (Get-Process -id $pid).Path;$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;$balloon.BalloonTipText = 'What do you think of this balloon tip?';$balloon.BalloonTipTitle = \\%%"Attention $Env:USERNAME\\%%" ;$balloon.Visible = $true ;$balloon.ShowBalloonTip(5000)%%""
Work also with oscommand by adding cmd /c :
activate "OSCOMMAND".command("cmd /c powershell -Command %%"Add-Type -AssemblyName System.Windows.Forms ; $global:balloon = New-Object System.Windows.Forms.NotifyIcon ;$path = (Get-Process -id $pid).Path;$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;$balloon.BalloonTipText = 'What do you think of this balloon tip?';$balloon.BalloonTipTitle = \\%%"Attention $Env:USERNAME\\%%" ;$balloon.Visible = $true ;$balloon.ShowBalloonTip(5000)%%"")
------------------------------
Hortion Gilles
Agfa-Gevaert NV
------------------------------
Haven't tried the javascript above yet though (more complex setup).
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
- Participating Frequently
- March 30, 2022
Haven't tried the javascript above yet though (more complex setup).
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
create a notification.bat :
powershell -windowstyle hidden -Command "Add-Type -AssemblyName System.Windows.Forms ; $global:balloon = New-Object System.Windows.Forms.NotifyIcon ;$path = (Get-Process -id $pid).Path;$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;$balloon.BalloonTipText = 'What do you think of this balloon tip?';$balloon.BalloonTipTitle = \\"Attention $Env:USERNAME\\" ;$balloon.Visible = $true ;$balloon.ShowBalloonTip(5000)"
create a notification.vbs file that calls the notification.bat file:
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "notification.bat" & Chr(34), 0
Set WinScriptHost = Nothing
then call notification.vbs:
spawn "notification.vbs"
------------------------------
Hortion Gilles
Agfa-Gevaert NV
------------------------------
- Author
- Inspiring
- March 31, 2022
https://www.javascripttutorial.net/web-apis/javascript-notification/
With it, in a browser (and with the authorization) you can trigger OS notifications (tried it on Debian/GNOME and Windows). Depending on the possibilities of the browser/widget, you can also add an icon.
But it will be very dependant on the widget, and I'm not even sure it's possible :-)
(My Uniface HTML widget fu are very low)
------------------------------
Jean-Marc Salis
Mp Services
Montauban Cedex FR
------------------------------
https://www.javascripttutorial.net/sample/webapis/notification/
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
- Author
- Inspiring
- March 31, 2022
create a notification.bat :
powershell -windowstyle hidden -Command "Add-Type -AssemblyName System.Windows.Forms ; $global:balloon = New-Object System.Windows.Forms.NotifyIcon ;$path = (Get-Process -id $pid).Path;$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning ;$balloon.BalloonTipText = 'What do you think of this balloon tip?';$balloon.BalloonTipTitle = \\"Attention $Env:USERNAME\\" ;$balloon.Visible = $true ;$balloon.ShowBalloonTip(5000)"
create a notification.vbs file that calls the notification.bat file:
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "notification.bat" & Chr(34), 0
Set WinScriptHost = Nothing
then call notification.vbs:
spawn "notification.vbs"
------------------------------
Hortion Gilles
Agfa-Gevaert NV
------------------------------
So I did some playing around, and there are a couple of things I thought would be useful to add to the code above.
params
numeric p_delay : IN
string p_heading : IN
string p_message : IN
string p_icon : IN
endparams
variables
string v_sql, v_line
numeric v_status
handle v_shell
endvariables
if(p_delay = "" | p_delay = 0)
p_delay = 5000
else
p_delay = p_delay*1000
endif
v_sql = "powershell -windowstyle hidden -Command %%"Add-Type -AssemblyName System.Windows.Forms ;"
v_sql = $concat(v_sql," $global:balloon = New-Object System.Windows.Forms.NotifyIcon ;")
v_sql = $concat(v_sql," $path = (Get-Process -id $pid).Path;")
v_sql = $concat(v_sql," $balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;")
v_sql = $concat(v_sql," $balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::None ;")
v_sql = $concat(v_sql," $balloon.BalloonTipText = '",$replace(p_message,1,"'","\\'",-1),"';")
v_sql = $concat(v_sql," $balloon.BalloonTipTitle = '",p_heading,"' ;")
v_sql = $concat(v_sql," $balloon.Visible = $true ;")
v_sql = $concat(v_sql," $balloon.ShowBalloonTip(",p_delay,");")
v_sql = $concat(v_sql," Start-Sleep -Milliseconds ",p_delay,";")
v_sql = $concat(v_sql," $global:balloon.Dispose();%%"")
newinstance "WSH_WSHSHELL",v_shell
v_shell->run(v_status,v_sql,0,0)
deleteinstance v_shell
Notes:-
- It seems the variable delay for notifications is deprecated, and now based on system accessibility settings. So all the p_delay in here is (basically) pointless.
- The code above left an icon in the system tray, which vanished on mouse over, but it was stacking icons up if left to run several times. So I instituted the $global:balloon.Dispose() to clear it. However, this seems to get rid of the resources before it can display the icon for the application, so I put in the Sleep command to keep the NotifyIcon around long enough to display the tooltip properly.
- Finally, I remembered we'd implemented the shell dll as a signature I could use the Wshell.run command rather than using files.
- This was to cope with the fact that I wanted to remove the files after use, and couldn't get it to delete itself, and/or get the timing right on deleting them from the app.
This is now working, as required, thank you.
Iain
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
Recent badge winners
Peter Restorickhas earned the badge First flight
Robert Redekophas earned the badge Network Contributor
Robert Redekophas earned the badge Orbit Established
Robert Redekophas earned the badge Consistent Trajectory
Doug Averchhas earned the badge Consistent Trajectory
Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.
Scanning file for viruses.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
OKThis file cannot be downloaded
Sorry, our virus scanner detected that this file isn't safe to download.
OK