Bonjour voila je lis une vidéo avec un shell et j'aimerait ensuite qu'il lise une deuxieme video a la suite...
Mais comment savoir si un shell a finit son action (savoir que la 1ère video est terminé ?
Merci d'eclairer ma lanterne
Bonjour voila je lis une vidéo avec un shell et j'aimerait ensuite qu'il lise une deuxieme video a la suite...
Mais comment savoir si un shell a finit son action (savoir que la 1ère video est terminé ?
Merci d'eclairer ma lanterne
désolé
tu veut parler de cet question ?
Comment lancer un exécutable et reprendre la main quand il a fini ?
Avec mon code j'arrive a récuperer la main mais je souhaiterait que Windows Medi player se ferme afin de s'ouvrir avec la nouvelle vidéo... Ou encore mieux, que la vidéo suivant se lance directement (sans devoir fermer et réouvrir mon WMP)
voici mon code
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141 Const HKEY_CLASSES_ROOT = &H80000000 Const HKEY_CURRENT_USER = &H80000001 Const HKEY_LOCAL_MACHINE = &H80000002 Const HKEY_USERS = &H80000003 Const HKEY_DYN_DATA = &H80000004 Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Private Declare Function WaitForSingleObject Lib "kernel32" _ (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Private Declare Function CloseHandle Lib "kernel32" _ (ByVal hObject As Long) As Long Private Declare Function OpenProcess Lib "kernel32" _ (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Private Const INFINITE = -1& Private Const SYNCHRONIZE = &H100000 Public Enum HCle HKeyLocalMachine = 0 HKeyCurrentUser = 1 HKeyClassesRoot = 2 HKeyUsers = 3 HKeyDynamicData = 4 End Enum 'pour créer ou ouvrir une clé Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" _ (ByVal HKey As Long, _ ByVal lpSubKey As String, _ phkResult As Long) As Long 'pour lire une valeur Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _ (ByVal HKey As Long, _ ByVal lpValueName As String, _ ByVal lpReserved As Long, _ lpType As Long, _ lpData As Any, _ lpcbData As Long) As Long Private Sub bt_select_Click() CD1.ShowOpen If CD1.FileName <> "" Then listclip.AddItem (CD1.FileName) End If End Sub Private Sub Command1_Click() Dim extension As String Dim pos As Integer Dim tmp1 As String Dim tmp2 As String Dim i As Integer Dim iTask As Long, ret As Long, pHandle As Long i = 0 While i < listclip.ListCount tmp2 = "" textfichier = listclip.List(i) pos = InStrRev(textfichier.Text, ".") extension = Right(textfichier.Text, Len(textfichier.Text) - pos + 1) Debug.Print "extension :" & extension tmp1 = LireValeur(HKeyClassesRoot, extension, "") tmp2 = LireValeur(HKeyClassesRoot, tmp1 & "\shell\open\command", "") tmp2 = Replace(tmp2, "%SystemRoot%", WinDirectory) tmp2 = Replace(tmp2, Chr(34) & "%1" & Chr(34), Chr(34) & textfichier.Text & Chr(34)) tmp2 = Replace(tmp2, "%L", textfichier.Text) Debug.Print tmp1 Debug.Print tmp2 iTask = Shell(tmp2, vbNormalFocus) pHandle = OpenProcess(SYNCHRONIZE, False, iTask) ret = WaitForSingleObject(pHandle, INFINITE) ret = CloseHandle(pHandle) killprocess (iTask) i = i + 1 Wend End Sub Public Function LireValeur(HK As HCle, Chemin As String, Valeur As String) As String Dim lng As Long Dim Buff As Long Buff = 0 Buff = RegCreateKey(HKConvert(HK), Chemin, lng) If Buff = 0 Then RegQueryValueEx lng, Valeur, 0&, 1, 0&, Buff If Buff < 2 Then LireValeur = "" Exit Function End If LireValeur = String(Buff + 1, " ") RegQueryValueEx lng, Valeur, 0&, 1, ByVal LireValeur, Buff LireValeur = Left(LireValeur, Buff - 1) End Function Private Function HKConvert(ByVal HK As HCle) As Long If HK = 2 Then HKConvert = HKEY_CLASSES_ROOT If HK = 1 Then HKConvert = HKEY_CURRENT_USER If HK = 0 Then HKConvert = HKEY_LOCAL_MACHINE If HK = 3 Then HKConvert = HKEY_USERS If HK = 4 Then HKConvert = HKEY_DYN_DATA End Function Sub killprocess(processid) Dim hProcess, Termine& 'On le numéro de son Process hProcess = OpenProcess(1, False, processid) ' On Ferme le process lancé par un TerminateProcess Termine& = TerminateProcess(hProcess, 4) End Sub
Quelqun as t'il une idée ? c'est la première fois que je traite des process
Recherche sur google: shell wait
premier lien trouvé voici ce que je trouve
ensuite il suffit de lancer la fonction shellWait
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 '***************** Code Start ****************** 'This code was originally written by Terry Kreft. 'It is not to be altered or distributed, 'except as part of an application. 'You are free to use it in any application, 'provided the copyright notice is left unchanged. ' 'Code Courtesy of 'Terry Kreft Private Const STARTF_USESHOWWINDOW& = &H1 Private Const NORMAL_PRIORITY_CLASS = &H20& Private Const INFINITE = -1& Private Type STARTUPINFO cb As Long lpReserved As String lpDesktop As String lpTitle As String dwX As Long dwY As Long dwXSize As Long dwYSize As Long dwXCountChars As Long dwYCountChars As Long dwFillAttribute As Long dwFlags As Long wShowWindow As Integer cbReserved2 As Integer lpReserved2 As Long hStdInput As Long hStdOutput As Long hStdError As Long End Type Private Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessID As Long dwThreadID As Long End Type Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _ hHandle As Long, ByVal dwMilliseconds As Long) As Long Private Declare Function CreateProcessA Lib "kernel32" (ByVal _ lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _ lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _ ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _ ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _ lpStartupInfo As STARTUPINFO, lpProcessInformation As _ PROCESS_INFORMATION) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal _ hObject As Long) As Long Public Sub ShellWait(Pathname As String, Optional WindowStyle As Long) Dim proc As PROCESS_INFORMATION Dim start As STARTUPINFO Dim ret As Long ' Initialize the STARTUPINFO structure: With start .cb = Len(start) If Not IsMissing(WindowStyle) Then .dwFlags = STARTF_USESHOWWINDOW .wShowWindow = WindowStyle End If End With ' Start the shelled application: ret& = CreateProcessA(0&, Pathname, 0&, 0&, 1&, _ NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc) ' Wait for the shelled application to finish: ret& = WaitForSingleObject(proc.hProcess, INFINITE) ret& = CloseHandle(proc.hProcess) End Sub '***************** Code End ****************
Merci de faire une recherche pour trouvé certaines réponse
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 shellwait "C:\monfichier.wmv" shellwait "C:\monfichier2.wmv"
Merci encore désolé mais la procédure ne lance pas la video...
j'ai mit le code que tu ma fourni dans un module
la prcoedure je l'ai nommé ShellWaiting
voici ensuite le reste de mon code
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 Private Sub Command1_Click() i = 0 While i < listclip.ListCount ShellWaiting (listclip.List(i)) i = i + 1 Wend End Sub Private Sub bt_select_Click() CD1.ShowOpen If CD1.FileName <> "" Then listclip.AddItem (CD1.FileName) End If End Sub
essaye avec ceci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 ShellWait "C:\Program Files\Windows Media Player\Wmplayer.exe C:\windows\bureau\test.wmv", 3
Ok ca fonctionne enfin ma vidéo se lance, mais j'arrive pas a passer a la seconde vidéo directement il faut que je ferme le Windows media player
par exemple quand je fait ça
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 ShellWaiting "C:\Program Files\Windows Media Player\mplayer2.exe C:\Documents and Settings\administrateur\Bureau\test.wmv", 3 ShellWaiting "C:\Program Files\Windows Media Player\mplayer2.exe C:\Documents and Settings\administrateur\Bureau\autretest.wmv", 3
il faut fermer le mplayer mannuellement. Ton code ne peux pas savoir si c'est terminer de jouer (le vidéo), il permet seulement de savoir quand que mplayer est fermer.
Ok merci d'avoir prit le temps de ma répondre
Si je comprend bien je peut pas avec mon code faire une "playlist" de video ?
Ne peut-on pas fermer le windows media player avec VB ? ou la suite du code ne s'effectue qu'apres fermeture du Windows Medi Player ?
la suite du coté s'effectue seulement quand tu ferme mplayer.
Ok et tu n'aurait pas une idée alors pour faire une playlist de video sans utiliser shell...
En tous cas merci pour cet aide j'aurait au moins approcher de loin les process
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager