1 2 Previous Next 15 Replies Latest reply on Jan 25, 2017 8:29 PM by user19752

    Show notifications from variables on Windows 10 (using execute DDE)

    ekami

      Hello.

      On macOS, i use a calculated AppleScript to show notifications ( 10.9.0 or >) with 3 global variables:

       

      "set notificationTitle to the \""&$$Title&"\"¶
      set notificationSubTitle to \""&$$SubTitle&"\"¶
      set notificationMessage to \""&$$Body&"\"¶
      display notification notificationMessage with title  notificationTitle subtitle notificationSubTitle"

       

      I would like to do the same thing on windows 10

      I suppose i must use an "Execute DDE" statement, but i found no method to do this.

      The idea here is not to use a dialog box who generates an interruption.

       

      Thanks for your responses.

      Best regards, ekami.

        • 2. Re: Show notifications from variables on Windows 10 (using execute DDE)
          wimdecorte

          ekami wrote:

           

           

          I suppose i must use an "Execute DDE" statement,

           

          No.  Forget about "execute DDE".  It is there for backward compatibility but DDE has been dead technology for a very long time now.

           

          The FM platform unfortunately does not offer the equivalent of the "perform applescript" script step.  The closest thing we have on Windows is "send event".

           

          As user19752 indicates, you can use that script step to run a powershell (a native Windows script).  You could use the same mechanism to run a batch file or a VBscript file, all of which are native OS scripts.

          PowerShell is the more modern and the most powerful of those.

           

          The really great thing is that all of those OS scripts are just text files so you can even construct them completely from inside FM in a field, spit them out through the "export field contents' script step, followed by a 'send event' to execute it.

          1 of 1 people found this helpful
          • 3. Re: Show notifications from variables on Windows 10 (using execute DDE)
            ekami

            Many Thanks, i'll test some text files ( i need to find the correct extensions for batch / powershell files ) with the PowerShell scripts proposed by user19752 and turn back here to tell if it works with "send event" script step.

            • 4. Re: Show notifications from variables on Windows 10 (using execute DDE)
              ekami

              The problem i found is that PowerShell scripts execution is not allowed on the default config of W10, and next the "ExecutionPolicy" params have to be explicited manually to accept running scripts from ".ps1" files.

              I have no idea if there's another way to activate all this params other than manually.

              Next, the script proposed by user19752 have no bugs, but nothing happens when i run it in the Windows PowerShell ISE under Windows 10.

              So i have to give up here because at this point, my Windows competences are too limited.

              --

              P.S: please excuse my bad english, i do my best, but i'm frenchie ;-)

              • 5. Re: Show notifications from variables on Windows 10 (using execute DDE)
                user19752

                This worked on Windows7.

                In "Send Event" text

                powershell -Command "& {[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\");$objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon ;$objNotifyIcon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon(\"C:\Program Files\FileMaker\FileMaker Pro 15 Advanced\FileMaker Pro Advanced.exe\");$objNotifyIcon.BalloonTipIcon = \"Info\" ;$objNotifyIcon.BalloonTipText = \"This is message from FileMaker.\" ;$objNotifyIcon.BalloonTipTitle = \"Job is done\" ;$objNotifyIcon.Visible = $True ;$objNotifyIcon.ShowBalloonTip(10000)}"

                • 6. Re: Show notifications from variables on Windows 10 (using execute DDE)
                  ekami

                  Thanks, but sorry this doesn't works on windows 10. Seems like a quote char char is missing in the script but i can'y say where

                   

                  PS C:\Users\Moi> powershell -Command "& {[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\");$objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon ;$objNotifyIcon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon(\"C:\Program Files\FileMaker\FileMaker Pro 13 Advanced\FileMaker Pro Advanced.exe\");$objNotifyIcon.BalloonTipIcon = \"Info\" ;$objNotifyIcon.BalloonTipText = \"This is message from FileMaker.\" ;$objNotifyIcon.BalloonTipTitle = \"Job is done\" ;$objNotifyIcon.Visible = $True ;$objNotifyIcon.ShowBalloonTip(10000)}"

                  powershell : Le terminateur " est manquant dans la chaŒne.

                  Au caractère Ligne:1 : 1

                  + powershell -Command "& {[void] [System.Reflection.Assembly]::LoadWith ...

                  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                      + CategoryInfo          : NotSpecified: (Le terminateur ...dans la chaŒne.:String) [], RemoteException

                      + FullyQualifiedErrorId : NativeCommandError

                   

                      + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException

                      + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

                   

                  i probably do better searching for a plug-in to do this, or simply give up.

                  • 7. Re: Show notifications from variables on Windows 10 (using execute DDE)
                    ekami

                    I found a plug in able to display Dialog boxes ( Troi_Dialog ) but even if it can generate "flash" dialogs for a determinated duration, these kind of dialog generates an interruption, exactly what i don't want.

                    --

                    I've found an "equivalent" to Growl for windows, called snarl

                    https://www.tlhan-ghun.de/projects/snarl-command-line-tools/snarl_cmd-exe/

                     

                    I'll try using it in combination with this plug-in

                    BE_ExecuteSystemCommand – BaseElements Plugin Help Centre

                    -------

                    Well, i launched the .exe as admin, but impossible to know if it has installed anything usable, but for the moment it doesn't seems to work.

                    -------

                    But even if one of the methods founded here could work, it's not usable "out of the box" in my FileMaker pro runtime, so for the moment i abandon the idea of simply notifications under windows 10. This could be a nice native feature in a next version of FileMaker.

                    ------

                    Another way for me to show theses "notifications" would be to create a new window (floating as a palette with the only the close button) in FileMaker, to be closed manually by the user or by script, but without using a "suspend script" in order not to generate an interruption.

                    • 8. Re: Show notifications from variables on Windows 10 (using execute DDE)
                      philmodjunk
                      The really great thing is that all of those OS scripts are just text files so you can even construct them completely from inside FM in a field, spit them out through the "export field contents' script step, followed by a 'send event' to execute it.

                      Don't even need Send Event to execute it. Just specify the "automatically open" option when exporting the records. I do this to create "programmable" batch files in one of my solutions to mount needed shared directories etc.

                      • 9. Re: Show notifications from variables on Windows 10 (using execute DDE)
                        user19752

                        You put my "command line" on wrong space (power shell prompt). It will run on "command prompt" or "Send Event" in FM script, starting with "powershell" command itself.

                         

                        If you want to test it on powershell prompt,

                         

                        [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms");$objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon ;$objNotifyIcon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon("C:\Program Files\FileMaker\FileMaker Pro 15 Advanced\FileMaker Pro Advanced.exe");$objNotifyIcon.BalloonTipIcon = "Info" ;$objNotifyIcon.BalloonTipText = "This is message from FileMaker." ;$objNotifyIcon.BalloonTipTitle = "Job is done" ;$objNotifyIcon.Visible = $True ;$objNotifyIcon.ShowBalloonTip(10000)

                         

                        I also tested this first, then added escaping and quoting to use in -Command option.

                        • 10. Re: Show notifications from variables on Windows 10 (using execute DDE)
                          ekami

                          Capture d’écran 2017-01-23 à 23.40.51.jpg

                          YES ! Great, works fine on Windows 10.

                          I don't know how to handle this command line with my FileMaker global variables ( is that possible or not using the calculation option ?, this is still a mystery for me...)

                          The issue now is that PowerShell scripts execution is not allowed on the default config of W10, and  the "ExecutionPolicy" params have to be explicited manually to accept running command line or scripts from ".ps1" files.

                          As i can't ask the final user to activate PowerShell himself, i'll integrate this "send event" script step in "blind mode" without any insurance that the notifications will be effectively displayed.

                          But that's better than nothing...

                          • 11. Re: Show notifications from variables on Windows 10 (using execute DDE)
                            user19752

                            I rewrite it to custom function.

                            Called in "Send Event" calculation like as

                            ShowNotify ( "" ; "title text" ; "I don't know how long this message can be. OK?¶2nd line" ; "None" ; 10000 )

                             

                            //not completed

                            //can't get application file path stably (runtime)

                            //texts need to be more "quoted" if there are special chars, ", \, (and which?)

                             

                            /*

                            parameters;

                            TrayIcon: path to icon file *.ico or any file that have associated icon.

                            titleText: text for baloon title. Line break is ignored.

                            messageText: text for baloon message. Can have line break with ¶

                            messageIcon: text for baloon tip icon, choice from "Info" "Warning" "Error" "None".

                            duration: number as milliseconds

                            */

                             

                            Let ( [

                            fm = Get ( FileMakerPath ) ;

                            path = Case ( TrayIcon = "" ; Replace ( fm ; 1 ; 1 ; "" ) & "FileMaker Pro" & Case ( PatternCount ( fm ; "Advanced" ) ; " Advanced" ) & ".exe" ; TrayIcon ) ;

                            messageIcon = Case ( messageIcon = "" ; "None" ; messageIcon ) ;

                            duration = GetAsNumber ( duration ) ;

                            ps = "[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\");$objNotifyIcon=New-Object System.Windows.Forms.NotifyIcon;$objNotifyIcon.Icon=[System.Drawing.Icon]::ExtractAssociatedIcon(\"<<ti>>\");$objNotifyIcon.BalloonTipIcon=\"<<mi>>\";$objNotifyIcon.BalloonTipText=\"<<text>>\";$objNotifyIcon.BalloonTipTitle=\"<<title>>\";$objNotifyIcon.Visible=$True;$objNotifyIcon.ShowBalloonTip(<<ms>>)"

                            ] ;

                            "powershell -Command \"&{ " & Substitute ( ps ; [ "\"" ; "\\\"" ] ; [ "<<ti>>" ; path ] ; [ "<<title>>" ; titleText ] ; [ "<<text>>" ; messageText ] ; [ "<<mi>>" ; messageIcon ] ; [ "<<ms>>" ; duration ] ) & "}\""

                            )

                             

                            // I used <<name>> as template for substituting, so the text can't be used in text replaced previously, for example <<ms>> can't be in title text etc.. seems not worth for doing in this case.

                            1 of 1 people found this helpful
                            • 12. Re: Show notifications from variables on Windows 10 (using execute DDE)
                              ekami

                              Hello User19752, and many thanks for this Custom Function.

                              This is really amazing !

                              Works perfectly with quoted text, and local or global variables now,

                              Two screenshots to help newbies like me to illustrate this in action:

                               

                              Custom Function (File Menu -> Manage -> Custom functions... )

                              Capture d’écran 2017-01-24 à 12.57.20.jpg

                               

                              "Send Event" script step (Only for Windows platform, with Powershell activated)

                              Capture d’écran 2017-01-24 à 13.03.53.jpg

                              • 13. Re: Show notifications from variables on Windows 10 (using execute DDE)
                                user19752

                                I'm grad you get it worked.

                                 

                                An attention for using "Send Event" with user input data, it could be "command injection attack".

                                I'm not so experienced on powershell yet.

                                 

                                And I noticed tray icon stay somewhile after tooltip vanished, and disappear when mouse cursor hover it. This wouldn't problem but there may be resolution.

                                1 of 1 people found this helpful
                                • 14. Re: Show notifications from variables on Windows 10 (using execute DDE)
                                  ekami

                                  I don't plan using tray icon, only messageIcon.

                                  I noticed that the first attempt of launching script step "Send Event" doesn't displays the notification ( but the sound beeps correctly). After this "initialization launching", all the other notifications are displayed normally.

                                  Bizarre...bizarre... as we say in France

                                  1 2 Previous Next