Afficher une infobulle, uniquement si un fichier internet l'autorise!

julien2424 Messages postés 76 Date d'inscription mardi 8 août 2006 Statut Membre Dernière intervention 24 avril 2012 - 9 août 2009 à 17:27
julien2424 Messages postés 76 Date d'inscription mardi 8 août 2006 Statut Membre Dernière intervention 24 avril 2012 - 10 août 2009 à 08:15
Bonjour à vous tous,

Je suis face à un problème que je ne suis pas capable de résoudre, et j'espère que parmi vous, certains on la clé à mon problème.
Pas facile d'être débutant ^^

Je souhaiterai que mon programme affiche une info bulle, UNIQUEMENT, si la page internet ou un fichier.txt stocké sur mon serveur internet contient les lettres "OK".
Si le fichier ou la page internet et vide alors, le programme n'affichera rien.

Voici mon code (Seul le début pose problème car ca ne marche pas, car l'affichage de l'info bulle fonctionne parfaitement):

Dim ResponseStream As IO.StreamReader = New IO.StreamReader("http://pagesperso-orange.fr/jmcreations/infos1.htm")
        Dim contenu As String = ResponseStream.ReadToEnd().ToString
        ResponseStream.Close()
        Dim mot As String
        If mot = contenu.Substring("OK") Then
            NotifyIcon1.Icon = My.Resources.notifyicon
            NotifyIcon1.Visible = True
            NotifyIcon1.ShowBalloonTip(20, "Message d'information:", GetHTMLPage("http://pagesperso-orange.fr/jmcreations/infos_saviezvous_3.xx_et_4.xx.htm"), ToolTipIcon.Info)
        End If
        temps_affichage_infobulle.Stop()
        NotifyIcon1.Text = "JMC Surveillance météorologique 4 Professional Edition"


Est-il possible de forcer mon programme à exécuter une action, depuis internet (fichier ou page web)???

Bonne soirée à tous
ET très bonne fin de week end!


Jules

2 réponses

PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
10 août 2009 à 02:03
salut,


tu sembles utiliser une fonction GETHTMLPAGE..., pas valable aussi pour ton test?

en attendant :
http://www.codyx.org/snippet_recuperer-source-page-dans-variable-string-api_620.aspx#2328

    Public Function DownloadSource(ByVal address As String) As String
        Dim Result As String
        Using NetC As New System.Net.WebClient()
            Result = NetC.DownloadString(address)
        End Using
        Return Result
    End Function

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        With NotifyIcon1
            .Text = "JMC Surveillance météorologique 4 Professional Edition"

            If DownloadSource("http://pagesperso-orange.fr/jmcreations/infos1.htm").Contains("OK") Then
                .Icon = My.Resources.notifyicon
                .Visible = True
                .ShowBalloonTip(20, "Message d'information:", GetHTMLPage("http://pagesperso-orange.fr/jmcreations/infos_saviezvous_3.xx_et_4.xx.htm"), ToolTipIcon.Info)
            End If
        End With
        temps_affichage_infobulle.Stop()
    End Sub


++
[hr]
0
julien2424 Messages postés 76 Date d'inscription mardi 8 août 2006 Statut Membre Dernière intervention 24 avril 2012
10 août 2009 à 08:15
J'ai trouvé cette méthode, je sais pas si c'est la meilleure, mais ça marche
En tout cas, merci beaucoup pour ton aide

        Dim objWebRequest2 As System.Net.WebRequest = System.Net.HttpWebRequest.Create("http://pagesperso-orange.fr/jmcreations/infos_bulles/Alerte.htm")
        Dim objWebResponse2 As System.Net.WebResponse = objWebRequest2.GetResponse()
        Dim objStreamReader2 As System.IO.StreamReader = Nothing
        Try
            objStreamReader2 = New System.IO.StreamReader(objWebResponse2.GetResponseStream())
            Invisible.Text = objStreamReader2.ReadToEnd()
        Finally
            If Not objWebResponse2 Is Nothing Then
                objWebResponse2.Close()
            End If
        End Try
        Dim objWebRequest3 As System.Net.WebRequest = System.Net.HttpWebRequest.Create("http://pagesperso-orange.fr/jmcreations/infos_bulles/Alerte1.htm")
        Dim objWebResponse3 As System.Net.WebResponse = objWebRequest3.GetResponse()
        Dim objStreamReader3 As System.IO.StreamReader = Nothing
        Try
            objStreamReader3 = New System.IO.StreamReader(objWebResponse3.GetResponseStream())
            Invisible2.Text = objStreamReader3.ReadToEnd()
        Finally
            If Not objWebResponse3 Is Nothing Then
                objWebResponse3.Close()
            End If
        End Try
        Dim objWebRequest4 As System.Net.WebRequest = System.Net.HttpWebRequest.Create("http://pagesperso-orange.fr/jmcreations/infos_bulles/Actualites.htm")
        Dim objWebResponse4 As System.Net.WebResponse = objWebRequest4.GetResponse()
        Dim objStreamReader4 As System.IO.StreamReader = Nothing
        Try
            objStreamReader4 = New System.IO.StreamReader(objWebResponse4.GetResponseStream())
            Invisible3.Text = objStreamReader4.ReadToEnd()
        Finally
            If Not objWebResponse4 Is Nothing Then
                objWebResponse4.Close()
            End If
        End Try
        Dim objWebRequest5 As System.Net.WebRequest = System.Net.HttpWebRequest.Create("http://pagesperso-orange.fr/jmcreations/infos_bulles/Actualites1.htm")
        Dim objWebResponse5 As System.Net.WebResponse = objWebRequest5.GetResponse()
        Dim objStreamReader5 As System.IO.StreamReader = Nothing
        Try
            objStreamReader5 = New System.IO.StreamReader(objWebResponse5.GetResponseStream())
            Invisible4.Text = objStreamReader5.ReadToEnd()
        Finally
            If Not objWebResponse5 Is Nothing Then
                objWebResponse5.Close()
            End If
        End Try
        If My.Settings.afficher_infosbulles = True Then
            If My.Settings.explication_infobulle = True Then
                NotifyIcon1.Icon = My.Resources.notifyicon
                NotifyIcon1.Visible = True
                NotifyIcon1.ShowBalloonTip(20, "Message d'information:", "Voici une nouveauté de la version 4 de JMC Surveillance météorologique." & Chr(13) + Chr(10) & "Grâce à cette info-bulle, vous pourrez être prévenu par nos serveurs d'évènements météorologiques dangereux, d'évènements importants concernant votre logiciel ou bien JM Créations.", ToolTipIcon.Info)
                NotifyIcon1.Text = "JMC Surveillance météorologique 4 Professional Edition"
                My.Settings.explication_infobulle = False
                My.Settings.Save()
            ElseIf Invisible.Text = Invisible2.Text Then
                NotifyIcon1.Icon = My.Resources.notifyicon
                NotifyIcon1.Visible = True
                NotifyIcon1.ShowBalloonTip(20, "Alerte météorologique:", GetHTMLPage("http://pagesperso-orange.fr/jmcreations/infos_bulles/informations.htm"), ToolTipIcon.Warning)
                NotifyIcon1.Text = "JMC Surveillance météorologique 4 Professional Edition"
            ElseIf Invisible3.Text = Invisible4.Text Then
                NotifyIcon1.Icon = My.Resources.notifyicon
                NotifyIcon1.Visible = True
                NotifyIcon1.ShowBalloonTip(20, "Message d'information:", GetHTMLPage("http://pagesperso-orange.fr/jmcreations/infos_bulles/informations_jmc.htm"), ToolTipIcon.Info)
                NotifyIcon1.Text = "JMC Surveillance météorologique 4 Professional Edition"
            End If
        End If
        temps_affichage_infobulle.Stop()
    End Sub


Jules
0
Rejoignez-nous