IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

escape pour sortir d'un programme


Sujet :

VB.NET

  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Novembre 2008
    Messages
    428
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Novembre 2008
    Messages : 428
    Par défaut escape pour sortir d'un programme
    Bonjour
    avez-vous un exemple de programme pour sortir avec la touche escape d'un programme en cours d'exécution.
    merci

  2. #2
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 197
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 197
    Par défaut
    mettre keypreview à true sur le form
    gérer tonform.keydown
    si e.keycode = echap then system.windows.application.current.shutdown
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Novembre 2008
    Messages
    428
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Novembre 2008
    Messages : 428
    Par défaut
    je suis en visual basic.net
    le code ne fonctionne pas?
    avez-vous un exemple complet?
    merci

  4. #4
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 197
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 197
    Par défaut
    ca ne fait pas ce qu'il faut ? ca plante ? ca ne veut pas compiler ?

    le code que je vous donne c'est une idée de ce qu'il faut, c'est à vous d'adapter la syntaxe ...
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  5. #5
    Membre éclairé
    Profil pro
    Inscrit en
    Novembre 2008
    Messages
    428
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Novembre 2008
    Messages : 428
    Par défaut stopper l'execution d'un programme
    Bonjour,
    voici mon programme que j'aimerais bien pouvoir stopper avec une touche ou un autre programme mais je ne sais pas comment faire?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    Imports System
    Imports System.Diagnostics
    Imports System.Threading
     
    Public Class Form1
     
     
        Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
     
        Private Declare Function SetCursorPos Lib "user32" (ByVal x As Integer, ByVal y As Integer) As Integer
        Const MOUSEEVENTF_ABSOLUTE = &H150000
        Const MOUSEEVENTF_LEFTDOWN = &H2
        Const MOUSEEVENTF_LEFTUP = &H4
        Const MOUSEEVENTF_MIDDLEDOWN = &H20
        Const MOUSEEVENTF_MIDDLEUP = &H40
        Const MOUSEEVENTF_MOVE = &H1
        Const MOUSEEVENTF_RIGHTDOWN = &H8
        Const MOUSEEVENTF_RIGHTUP = &H10
        Const MOUSEEVENTF_WHEEL = &H80
        Const MOUSEEVENTF_XDOWN = &H100
        Const MOUSEEVENTF_XUP = &H200
        Const WHEEL_DELTA = 120
        Const XBUTTON1 = &H1
        Const XBUTTON2 = &H2
        Dim retval As Long
     
     
        Private Sub frmCard_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
     
            If e.KeyChar.Equals(Chr(27)) Then
                Me.Close()
                Me.Dispose(True)
                Application.Exit()
            End If
        End Sub
     
     
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim x, y As Integer
            'Dim compteur As Integer
            'compteur = 1
            'Do
            '1
            'Dim monprocess1 As New Process()
            'Process.Start("C:\Users\pascal\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Microsoft Office Outlook 2007") ' Ouvre outlook
            'System.Windows.Forms.Application.DoEvents()
            'Thread.Sleep(5000)
            'retval = SetCursorPos(638, 59)
            'Thread.Sleep(800)
            'Call mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            'Call mouse_event(MOUSEEVENTF_LEFTUP + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            'Thread.Sleep(800)
            'retval = SetCursorPos(608, 222)
            'Call mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            'Call mouse_event(MOUSEEVENTF_LEFTUP + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            'Thread.Sleep(800)
            'retval = SetCursorPos(952, 222)
            'Call mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            'Call mouse_event(MOUSEEVENTF_LEFTUP + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            'Thread.Sleep(800)
            'Thread.Sleep(10000)
     
     
     
            Thread.Sleep(1000)
            retval = SetCursorPos(300, 165)
            Thread.Sleep(800)
            Call mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Call mouse_event(MOUSEEVENTF_LEFTUP + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Thread.Sleep(1000)
            retval = SetCursorPos(1200, 334)
            Thread.Sleep(800)
            Call mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Call mouse_event(MOUSEEVENTF_LEFTUP + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Thread.Sleep(200)
            retval = SetCursorPos(1075, 334)
            Thread.Sleep(800)
            Call mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Call mouse_event(MOUSEEVENTF_LEFTUP + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Thread.Sleep(2000)
            retval = SetCursorPos(760, 497)
            Thread.Sleep(800)
            Call mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Call mouse_event(MOUSEEVENTF_LEFTUP + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Thread.Sleep(2000)
            retval = SetCursorPos(200, 1030)
            Call mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Call mouse_event(MOUSEEVENTF_LEFTUP + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Thread.Sleep(800)
            retval = SetCursorPos(300, 165)
            Call mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Call mouse_event(MOUSEEVENTF_LEFTUP + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            Thread.Sleep(800)
            SendKeys.Send("{DEL}")
            'Thread.Sleep(800)
            'retval = SetCursorPos(1652, 15)
            'Call mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            'Call mouse_event(MOUSEEVENTF_LEFTUP + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            'Thread.Sleep(800)
            'Thread.Sleep(800)
            'retval = SetCursorPos(1652, 15)
            'Call mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            'Call mouse_event(MOUSEEVENTF_LEFTUP + MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            'Thread.Sleep(800)
            'compteur = compteur + 1
            'Loop Until compteur = 4
            Application.Exit()
            Dim monprocess2 As New Process()
            Process.Start("C:\Users\pascal\Documents\Visual Studio 2008\Projects\click paye2\clickpaye2\clickpaye2\bin\Release\clickpaye2.exe") ' Ouvre outlook
     
     
     
     
     
     
     
     
     
     
     
     
     
        End Sub
    End Class

  6. #6
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 197
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 197
    Par défaut
    j'ai pas en mémoire la charte de ce forum, mais multiposter sur le meme sous forum dans la meme journée pour le meme problème doit etre interdit

    pourquoi ne pas plutot répondre à mes questions sur l'autre post ?
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  7. #7
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 197
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 197
    Par défaut
    en lisant tes nombreux posts avec ton code étrange, je comprends pourquoi ton code ne marche pas


    tu ne peux intercepter keypress que si ta form a le focus, or tu fais du sendkeys sur outlook ...

    il te faut un hook clavier via une api je pense
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

Discussions similaires

  1. Pour sortir d'un programme Perl legalement
    Par Pauli dans le forum Langage
    Réponses: 1
    Dernier message: 03/05/2007, 16h38
  2. Prob pour debbugage d'un programme
    Par firens dans le forum MFC
    Réponses: 6
    Dernier message: 06/03/2006, 16h30
  3. tabulation pour sortir d'un sous formulaire
    Par rapace dans le forum Access
    Réponses: 4
    Dernier message: 30/11/2005, 16h20
  4. [sbadecoder a dit].. C'est quoi pour vous un beau programme?
    Par seb.49 dans le forum Langages de programmation
    Réponses: 14
    Dernier message: 13/02/2004, 10h41

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo