예제 #1
0
        public void songTimer_OnTick(object source, ElapsedEventArgs e)
        {
            try
            {
                determinerParent();
            }
            catch (Exception ex)
            {
                return;
            }

            //Déterminer Handle tempsRestant
            IntPtr hRestant = FindWindowEx(arbre, IntPtr.Zero, null, null);
            while (index < 11)
            {
                hRestant = FindWindowEx(arbre, hRestant, null, null);
                index++;
            }
            index = 0;

            //Déterminer Handle tempsEcoule
            IntPtr hEcoule = FindWindowEx(arbre, IntPtr.Zero, null, null);
            while (index < 4)
            {
                hEcoule = FindWindowEx(arbre, hEcoule, null, null);
                index++;
            }
            index = 0;

            //Déterminer Handle tempsTotal
            IntPtr hTotal = FindWindowEx(arbre, IntPtr.Zero, null, null);
            while (index < 14)
            {
                hTotal = FindWindowEx(arbre, hTotal, null, null);
                index++;
            }
            index = 0;

            //Déterminer Handle heure_prochainTitre
            IntPtr hNext = FindWindowEx(arbre, IntPtr.Zero, null, null);
            while (index < 1)
            {
                hNext = FindWindowEx(arbre, hNext, null, null);
                index++;
            }
            index = 0;

            //Déterminer Handle titre
            IntPtr hTitre = FindWindowEx(racine, IntPtr.Zero, null, null);
            while (index < 5)
            {
                hTitre = FindWindowEx(racine, hTitre, null, null);
                index++;
            }
            index = 0;

            //Déterminer Handle titreSuivant
            IntPtr hTitreSuivant = FindWindowEx(racine, IntPtr.Zero, null, null);
            while (index < 4)
            {
                hTitreSuivant = FindWindowEx(racine, hTitreSuivant, null, null);
                index++;
            }
            index = 0;

            MRM_Data info = new MRM_Data();
            SetActiveWindow(hRestant);
            info.tempsRestant = getWindowValue(hRestant);
            info.tempsEcoule = getWindowValue(hEcoule);
            info.tempsTotal = getWindowValue(hTotal);
            info.heure_prochainTitre = getWindowValue(hNext);
            info.titreSuivant = getWindowValue(hTitreSuivant);
            info.titre = getWindowValue(hTitre);

            if (info.titre != nowPlaying)
            {
                info.trackChanged = true;
                nowPlaying = info.titre;
            }

            IntPtr lecture = FindWindowEx(arbre, IntPtr.Zero, null, "Lecture");
            while (index < 0)
            {
                button = FindWindowEx(arbre, lecture, null, "Lecture");
            }
            index = 0;

            if (window.ToInt32() > 0)
            {
                info.isRunning = true;
            }
            else
            {
                info.isRunning = false;
            }

            if (lecture.ToInt32() == 0 && info.isRunning && info.titre != "Default IME" && info.titre != "Aucun fic")
            {
                info.isPlaying = true;
            }
            else
            {
                info.isPlaying = false;
            }

            if(TOH_Watch)
            {
                if (DateTime.Now.Minute >= TOH_Minute)
                {
                    TOH_Debut = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, TOH_Minute, 0);
                    TOH_Fin = TOH_Debut.AddMinutes((double)TOH_Timespan);
                }

                bool inTimespan = DateTime.Now >= TOH_Debut && DateTime.Now <= TOH_Fin;

                if (info.titre.Contains(TOH_Contains))
                {
                    TOH_Playing = true;
                }
                else
                {
                    TOH_Playing = false;
                }

                if (info.trackChanged && TOH_Playing)
                {
                    TOH_Alert = false;
                }

                if (TOH_Playing == true && TOH_Alert == false)
                {
                    TOH_Alert = true;
                    if(inTimespan) {
                        TOH_Detected = true;
                    }
                    info.TOH_Detected = true;

                    // Signaler la détection du top
                    Form1.LogEvent("Top horaire détecté");
                }

                if (inTimespan)
                {
                    TOH_WaitForNext = false;
                }

                if (DateTime.Now > TOH_Fin && TOH_WaitForNext != true)
                {
                    if(TOH_Detected == false) {
                        // Déclenchement de l'alerte
                        Form1.LogEvent("[ALERTE] Top horaire non détecté !");

                        if(TOH_SendAlert && !string.IsNullOrEmpty(TOH_AlertURL)) {
                            httpGet(TOH_AlertURL);
                        }
                    }
                    TOH_Detected = false;
                    TOH_Alert = false;
                    TOH_WaitForNext = true;
                }
            }

            stCallback(info);
        }
예제 #2
0
 private void SongTick(MRM_Data info)
 {
     if(info.TOH_Detected) {
         toolStripStatusLabel1.Text = "Top horaire détecté !";
     }
     else if (info.isPlaying)
     {
         toolStripStatusLabel1.Text = "En cours: "+ info.titre + " (Restant: " + info.tempsRestant + ")";
     }
     else
     {
         toolStripStatusLabel1.Text = "Prêt";
     }
 }