Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import time
  2. import ctypes
  3. ##from ctypes import *
  4. ## I don't like this. I like to import.
  5.  
  6. time.sleep(2)
  7.  
  8. # Set up the User32 and GDI32
  9. User32 = ctypes.WinDLL('User32', use_last_error=True)
  10. GDI32 = ctypes.WinDLL('GDI32', use_last_error=True)
  11.  
  12. # Set up Fx to be used.
  13. GetForegroundWindow = User32.GetForegroundWindow
  14. GetWindowDC = User32.GetWindowDC
  15. GetPixel = GDI32.GetPixel
  16. ReleaseDC = User32.ReleaseDC
  17.  
  18.  
  19. # main code
  20. foreground_window = GetForegroundWindow()
  21. dc = GetWindowDC(foreground_window)
  22.  
  23. # set timer to see how fast it runs.
  24. t0 = time.clock()
  25.  
  26. for i in range(50):
  27. rgb = GetPixel(dc, 10, 10)
  28. #print(rgb)
  29. r = rgb & 0xff
  30. g = (rgb >> 8) & 0xff
  31. b = (rgb >> 16) & 0xff
  32. ## print("RGB(%d, %d, %d)" % (r, g, b))
  33.  
  34. print(time.clock() - t0)
  35. ReleaseDC(foreground_window, dc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement