Soporte de pedidos: Periodic Event not Firing

Descripción

We are using a Watchdog script to automatically launch our WinForms application on SiteKiosk start and to restart the application if it closes/crashes. Lastly, we are also using it to ensure it stays maximized and this is where we are having an issue (CheckAppIsMinimized). If the window is minimized, it never gets maximized. This used to work although I can't say when it stopped working. Is there anything obvious in this script that could cause the issue? One thing I suspected was perhaps when the OnRemove function gets called, perhaps the handle for the window is invalidated?


SiteKiosk.WindowList.OnRemove = OnRemove; //fires if a window has been closed
SiteKiosk.WindowList.OnInsert = OnInsert; //fires if a windows is inserted
 
var gk_skwin; //global variable for the window object to monitor the application
 
SiteKiosk.Scheduler.AddDelayedEvent(500, StartMyApp); //starts the desired application the first time after 500 ms
SiteKiosk.Scheduler.AddPeriodicEvent(1000, CheckAppIsMinimized); //monitors whether application is minimzed every 1000 ms
SiteKiosk.Scheduler.AddDelayedEvent(1000, StartScreenCaptures); //starts screen capture which runs in its own loop

function StartMyApp(){
    SiteKiosk.ExternalApps.Run("C:\\Program Files\\FrontEdge\\Kiosk\\CheckinKiosk.exe", true);
}

function StartScreenCaptures(){
	SiteKiosk.ExternalApps.Run("C:\\Program Files\\FrontEdge\\ScreenCapture\\FrontEdgeKioskScreenCapture.exe", false);
}

function OnInsert(skwin){
    //check if our application has been started
    if(skwin.ItemText === "FrontEdge Check-In"){
        gk_skwin = skwin; //application has been started, assign returned window object to global variable
    }
}
  
function OnRemove(skwin){
    //checks if the application that should run has been closed
    if(skwin.ItemText === "FrontEdge Check-In"){
        //the application has been closed, restart it again
        SiteKiosk.Scheduler.AddDelayedEvent(30000, StartMyApp); //starts the desired application the next time after 30000 ms
    }
}
 
function CheckAppIsMinimized(){
   //use try/catch in case our application is not started and can therefore not be monitored
   try{
        //check if application is minimized
        if(SiteKiosk.WindowList.IsMinimized(gk_skwin.Handle)){
            //maximize the minimzed application
            SiteKiosk.WindowList.Maximize(gk_skwin.Handle);
        }
   }catch(e){}
}

Respuesta: (1)

Re: Periodic Event not Firing 28/04/2023 15:30
Hello,

Thank you for your inquiry. Generally, coding support is not provided in Support Forum. Considering this is related to a Dev Blog article, I will explain a few common misconceptions - https://devblog.provisio.com/post/2017/12/18/How-to-Build-an-Extended-Script-Watchdog-for-External-Applications.aspx

This feature in the script, the function "CheckAppIsMinimized", still works but depends on the "OnInsert" function where the object "gk_skwin" follows the window title. This window title is in the title bar of the window like "Untitled - Notepad", when you first open Notepad app. You can find this also in the Windows Taskbar by mouse hover.

If this value or title changes, then SiteKiosk is unable to take action on this window. You could close SiteKiosk and observe this application to see changes over app usage examples. You then, through coding (no further support), could account for those changes. Hopefully, this helps.

Best regards,
Andre.
Mi Cuenta
Entrar
Idioma (Billetes):