Bonjour
avez-vous un exemple de programme pour sortir avec la touche escape d'un programme en cours d'exécution.
merci
Version imprimable
Bonjour
avez-vous un exemple de programme pour sortir avec la touche escape d'un programme en cours d'exécution.
merci
mettre keypreview à true sur le form
gérer tonform.keydown
si e.keycode = echap then system.windows.application.current.shutdown
je suis en visual basic.net
le code ne fonctionne pas?
avez-vous un exemple complet?
merci
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 ...
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:
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
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 ?
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