79 lines
2.2 KiB
Python
Executable File
79 lines
2.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Test simple de capture d'événements
|
|
"""
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent / "geniusia2"))
|
|
|
|
from core.event_capture import EventCapture
|
|
from core.logger import Logger
|
|
|
|
def main():
|
|
print("\n" + "="*60)
|
|
print(" 🧪 TEST SIMPLE DE CAPTURE")
|
|
print("="*60 + "\n")
|
|
|
|
logger = Logger()
|
|
capture = EventCapture(logger=logger, pattern_threshold=3)
|
|
|
|
def on_pattern(pattern):
|
|
print(f"\n🎯 PATTERN DÉTECTÉ !")
|
|
print(f" Répétitions: {pattern['repetitions']}")
|
|
print(f" Fenêtre: {pattern.get('window', 'Unknown')}")
|
|
|
|
capture.register_pattern_callback(on_pattern)
|
|
|
|
print("📋 Configuration:")
|
|
print(f" Pattern threshold: 3")
|
|
print(f" Max history: 1000")
|
|
print()
|
|
|
|
print("🚀 Démarrage de la capture...")
|
|
success = capture.start()
|
|
|
|
if not success:
|
|
print("❌ Échec du démarrage")
|
|
return
|
|
|
|
print("✅ Capture démarrée !")
|
|
print()
|
|
print("💡 Instructions:")
|
|
print(" 1. Clique 3 fois n'importe où")
|
|
print(" 2. Attends quelques secondes")
|
|
print(" 3. Tu devrais voir 'PATTERN DÉTECTÉ !'")
|
|
print()
|
|
print(" Appuie sur Ctrl+C pour arrêter")
|
|
print()
|
|
|
|
try:
|
|
while True:
|
|
time.sleep(1)
|
|
|
|
# Afficher le nombre d'événements capturés
|
|
events = capture.get_recent_events(10)
|
|
if events:
|
|
print(f"\r📊 Événements capturés: {len(events)}", end="", flush=True)
|
|
|
|
except KeyboardInterrupt:
|
|
print("\n\n⏹️ Arrêt...")
|
|
capture.stop()
|
|
|
|
events = capture.get_recent_events(100)
|
|
print(f"\n📊 Total d'événements capturés: {len(events)}")
|
|
|
|
if events:
|
|
print("\n📝 Derniers événements:")
|
|
for i, event in enumerate(events[-5:], 1):
|
|
print(f" {i}. {event['type']} dans {event.get('window', 'Unknown')}")
|
|
else:
|
|
print("\n❌ Aucun événement capturé")
|
|
print(" Vérifie que pynput est installé")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|