Bonjour à tous !

Je suis actuellement sur un projet ayant comme objectif de récupérer le fichier MEMORY.DMP que créé WINDOWS dans le cas d'un crash system.

Pour pouvoir se faire, il faut après avoir rajouter une clé registre particulière, faire une combinaison de touche qui se trouve être CONTROL droit enfoncé + 2 fois SCROLL LOCK.

Pour se faire, j'ai utilisé la fonction SendInput.

Mon problème vient de fait que ma combinaison de touche n'est pas interprétée correctement.

Donc voila pourquoi je m'en remet à vous.

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
from ctypes import * #Pour l'utilisation des libraires en C
import time
#Structures utilisées pour l'appui des touches
class ki(Structure):
	_fields_ = [("wVk", c_ushort),
		        ("wScan", c_ushort),
			("dwFlags", c_ulong),
			("time", c_ulong),
			("dwExtraInfo", POINTER(c_ulong))]
 
class hi(Structure):
	_fields_ = [("uMsg", c_ulong),
			("wParamL", c_short),
			("wParamH", c_ushort)]
 
class mi(Structure):
	_fields_ = [("dx", c_long),
			("dy", c_long),
			("mouseData", c_ulong),
			("dwFlags", c_ulong),
			("time",c_ulong),
			("dwExtraInfo", POINTER(c_ulong))]
 
class Input_I(Union):
	_fields_ = [("ki", ki),
			("mi", mi),
			("hi", hi)]
 
class Input(Structure):
	_fields_ = [("type", c_ulong),
			("ii", Input_I)]
 
#Fonction de l'appui de la touche RCONTROL
def CONTROLUP():
	RCONTROLUPInput = Input
	RCONTROLUP      = Input_I()	
	RCONTROLUP.ki   = ki(163, 0, 0, 0, pointer(c_ulong(0))) #163
	RCONTROL	    = RCONTROLUPInput(1, RCONTROLUP)
	windll.user32.SendInput(1, pointer(RCONTROL), sizeof(RCONTROL))
	time.sleep(0.5)
	print "Appui enfonce de la touche RCONTROL"
 
 
#Fonction de l'appui et du relachement de la touche SCROLL
def SCROLL():	
	SCROLLInputs   = Input * 2
	i 			   = 0
	while i < 4:
		SCROLLUP      = Input_I()
		SCROLLUP.ki   = ki(145, 0, 0, 0, pointer(c_ulong(0)))
		SCROLLDOWN    = Input_I()
		SCROLLDOWN.ki = ki(145, 0, 2, 0, pointer(c_ulong(0)))
		SCROLL 		  = SCROLLInputs( (1, SCROLLUP), (1, SCROLLDOWN) )
		windll.user32.SendInput(2, pointer(SCROLL), sizeof(SCROLL[0]))
		i = i + 1
		time.sleep(0.5)
		if i == 1 or i == 3: 
			print "Appui de la touche SCROLL"
		else:
			print "Relachement de la touche SCROLL"
 
 
#Fonction du relachement de la touche RCONTROL
def CONTROLDOWN():
	RCONTROLDOWNInput  = Input
	RCONTROLDOWN       = Input_I()
	RCONTROLDOWN.ki    = ki(163, 0, 2, 0, pointer(c_ulong(0))) #163
	RCONTROL	   	   = RCONTROLDOWNInput(1, RCONTROLDOWN)
	windll.user32.SendInput(1, pointer(RCONTROL), sizeof(RCONTROL))
	print "Appui relache de la touche RCONTROL"
 
CONTROLUP()
SCROLL()
CONTROLDOWN()
Après cela, un collaborateur m'a dit de façon judicieuse de faire l'appui des touches en multi-threading, ce que j'ai fait en rajoutant ces quelques lignes.

Pour l'import des librairies
Code : Sélectionner tout - Visualiser dans une fenêtre à part
import threading	 #Pour la gestion des threads lors de l'appui des touches
Et tout à la fin pour l'exécution de la combinaison de touche.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
ThreadA = threading.Thread(None, CONTROLUP, None, (), {})
	 ThreadB = threading.Thread(None, SCROLL, None, (), {})
	 ThreadC = threading.Thread(None, CONTROLDOWN, None, (), {})
	 ThreadA.start()
	 ThreadB.start()
	 ThreadC.start()
Merci d'avance


Cordialement,


estudiante