Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/02/2011, 15:17
Avatar de razpeitia
razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: SendMessage y SendKeys

Código Python:
Ver original
  1. #### Script to try to write something down in notepad
  2. import win32api
  3. import win32gui
  4. import win32con
  5. import time
  6.  
  7. # get the window handle of the blank, minimized notepad window
  8. hwnd = win32gui.FindWindowEx(0, 0, 0, "probando.txt: Bloc de notas")
  9.  
  10. # print it just for kicks
  11. print hwnd
  12.  
  13. win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL)
  14. #this restores the proper window, so we know we have correct handle
  15.  
  16. #just to give it a little pause
  17. time.sleep(2)
  18.  
  19. print "trying to post message"
  20.  
  21. #try to send it a return key
  22. for i in range(26):
  23.     win32api.keybd_event(ord('A')+i, 0) #see http://msdn.microsoft.com/en-us/library/ms646304(VS.85).aspx

No se que trates de hacer pero hay mejores formas de trabajar con archivos.