Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import ctypes
- ##from ctypes import *
- ## I don't like this. I like to import.
- time.sleep(2)
- # Set up the User32 and GDI32
- User32 = ctypes.WinDLL('User32', use_last_error=True)
- GDI32 = ctypes.WinDLL('GDI32', use_last_error=True)
- # Set up Fx to be used.
- GetForegroundWindow = User32.GetForegroundWindow
- GetWindowDC = User32.GetWindowDC
- GetPixel = GDI32.GetPixel
- ReleaseDC = User32.ReleaseDC
- # main code
- foreground_window = GetForegroundWindow()
- dc = GetWindowDC(foreground_window)
- # set timer to see how fast it runs.
- t0 = time.clock()
- for i in range(50):
- rgb = GetPixel(dc, 10, 10)
- #print(rgb)
- r = rgb & 0xff
- g = (rgb >> 8) & 0xff
- b = (rgb >> 16) & 0xff
- ## print("RGB(%d, %d, %d)" % (r, g, b))
- print(time.clock() - t0)
- ReleaseDC(foreground_window, dc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement