We Recommend

Learning Python Learning Python
The authors of Learning Python show you enough essentials of the Python scripting language to enable you to begin solving problems right away, then reveal more powerful aspects of the language one at a time. This approach is sure to appeal to programmers and system administrators who have urgent problems and a preference for learning by semi-guided experimentation.


Posted By

buscarini on 07/18/06


Tagged

mediaencoder trabajo grabaciones pywinauto automatizar


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

anayhk


Manejar Windows Media Encoder con pywinauto


Published in: Python 


  1. import pywinauto
  2. from pywinauto import application
  3. import sys
  4. import time
  5.  
  6.  
  7. app = application.Application()
  8.  
  9. #TODO en vez de hacer start conectar a la aplicacion si ya esta en marcha
  10. #app.start_("c:/Archivos de Programa/Windows Media Components/Encoder/wmenc.exe")
  11. try:
  12. app.connect_(title_re = ".*Codificador de Windows Media.*") # Probar en espanyol
  13. except:
  14. try:
  15. app.connect_(title_re = ".*Windows Media Encoder .*") # Probar en ingles
  16. except:
  17. try:
  18. app.start_("c:/Archivos de Programa/Windows Media Components/Encoder/wmenc.exe")
  19. except:
  20. print("Windows Media Encoder no encontrado")
  21. sys.exit(1)
  22.  
  23.  
  24. ventana = app.MSWindowsMediaEncoder
  25.  
  26. while not(ventana.Exists()):
  27. time.sleep(0.1)
  28.  
  29. propiedades = ventana.ScrollDockHolder
  30.  
  31. time.sleep(0.1)
  32.  
  33. # Todo ver cómo sacar la ventana de propiedades de la sesión si no está abierta
  34.  
  35. # Tomar el control de pestañas
  36. tabs = ventana.Tab1
  37.  
  38. # Seleccionar la pestaña de salida
  39. tabs.Select(1)
  40.  
  41. time.sleep(0.1)
  42.  
  43. # FIXME Al parecer lo siguiente no activa el nombre de archivo -> comprobar y ver si se puede arreglar
  44. # Elegir almacenamiento en archivo
  45. checkbox = ventana.Almacenarenarchivo
  46.  
  47. # Marcar el checkbox si no estaba activado
  48. if (checkbox.GetCheckState()!=1):
  49. checkbox.Click()
  50.  
  51. time.sleep(0.1)
  52.  
  53. nombrearchivo = ventana.NombredearchivoEdit
  54. nombrearchivo.SetText("c:/video.wmv") # Ponerle un nombre de archivo para grabar ahí
  55. # archivoanterior = nombrearchivo.TextBlock() # guardarnos el nombre de archivo anterior

Report this snippet 

You need to login to post a comment.