<commit_before>'''

A pure python windows automation library loosely modeled after Java's Robot Class.


TODO:
	* Mac support  
	* Allow window section for relative coordinates.
	* ability to 'paint' target window. 



I can never remember how these map... 
----  LEGEND ----

BYTE      = c_ubyte
WORD      = c_ushort
DWORD     = c_ulong
LPBYTE    = POINTER(c_ubyte)
LPTSTR    = POINTER(c_char) 
HANDLE    = c_void_p
PVOID     = c_void_p
LPVOID    = c_void_p
UNIT_PTR  = c_ulong
SIZE_T    = c_ulong

'''


import sys
import time
import ctypes 
import multiprocessing 
from ctypes import *
from ctypes.wintypes import *



class WIN32CON(object):
	def __init__(self):
		self.LEFT_DOWN = 0x0002
		self.LEFT_UP = 0x0004
		self.MIDDLE_DOWN = 0x0020
		self.MIDDLE_UP = 0x0040
		self.MOVE = 0x0001
		self.RIGHT_DOWN = 0x0008
		self.RIGHT_UP = 0x0010
		self.WHEEL = 0x0800
		self.XDOWN = 0x0080
		self.XUP = 0x0100
		self.HWHEEL = 0x01000


class BITMAP(ctypes.Structure):
	_fields_ = [
		('bmType', c_int),
		('bmWidth', c_int),
		('bmHeight', c_int),
		('bmHeightBytes', c_int),
		('bmPlanes', c_short),
		('bmBitsPixel', c_short),
		('bmBits', c_void_p),
	]

class BITMAPFILEHEADER(ctypes.Structure):
	_fields_ = [
		('bfType', ctypes.c_short),
		('bfSize', ctypes.c_uint32),
		('bfReserved1', ctypes.c_short),
		('bfReserved2', ctypes.c_short),
		('bfOffBits', ctypes.c_uint32)
	]

class BITMAPINFOHEADER(ctypes.Structure):
	_fields_ = [
		('biSize', ctypes.c_uint32),
		('biWidth', ctypes.c_int),
		('biHeight', ctypes.c_int),
		('biPlanes', ctypes.c_short),
		('biBitCount', ctypes.c_short),
		('biCompression', ctypes.c_uint32),
		('biSizeImage', ctypes.c_uint32),
		('biXPelsPerMeter', ctypes.c_long),
		('biYPelsPerMeter', ctypes.c_long),
		('biClrUsed', ctypes.c_uint32),
		('biClrImportant', ctypes.c_uint32)
	]

class BITMAPINFO(ctypes.Structure):
	_fields_ = [
		('bmiHeader', BITMAPINFOHEADER),
		('bmiColors', ctypes.c_ulong * 3)
	]


class MOUSEINPUT(Structure):
	_fields_ = [
		('dx', LONG),
		('dy', LONG),
		('mouseData', DWORD),
		('dwFlags', DWORD),
		('time', DWORD),
		('dwExtraInfo', POINTER(ULONG)),
	]

class KEYBDINPUT(Structure):
	_fields_ = [
		('wVk', WORD),
		('wScan', WORD),
		('dwFlags', DWORD),
		('time', DWORD),
		('dwExtraInfo', POINTER(ULONG)),
	]

class HARDWAREINPUT(Structure):
	_fields_ = [
		('uMsg', DWORD),
		('wParamL', WORD),
		('wParamH', DWORD)
	]

class INPUT(Structure):
	class _I(Union):
		_fields_ = [
			('mi', MOUSEINPUT),
			('ki', KEYBDINPUT),
			('hi', HARDWAREINPUT),
		]

	_anonymous_ = 'i'
	_fields_ = [
		('type', DWORD),
		('i', _I),
	]


class KeyConsts(object):
	def __init__(self):
		# No. I refuse to shorten this! 
		# You can't make me!
		# Pep8 Schmep 8!
		self.key_names = [" ", "left_mouse_button", "right_mouse_button", "control-break_processing", "middle_mouse_button_(three-button_mouse)", "x1_mouse_button", "x2_mouse_button", "undefined", "backspace", "tab", "reserved", "clear", "enter", "undefined", "shift", "ctrl", "alt", "pause", "caps_lock", "ime_kana_mode", "ime_hanguel_mode_(maintained_for_compatibility;_use_vk_hangul)", "ime_hangul_mode", "undefined", "ime_junja_mode", "ime_final_mode", "ime_hanja_mode", "ime_kanji_mode", "undefined", "esc", "ime_convert", "ime_nonconvert", "ime_accept", "ime_mode_change_request", "spacebar", "page_up", "page_down", "end", "home", "left_arrow", "up_arrow", "right_arrow", "down_arrow", "select", "print", "execute", "print_screen", "ins", "del", "help", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "undefined", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "left_windows__(natural_board)", "right_windows__(natural_board)", "applications__(natural_board)", "reserved", "computer_sleep", "numeric_pad_0", "numeric_pad_1", "numeric_pad_2", "numeric_pad_3", "numeric_pad_4", "numeric_pad_5", "numeric_pad_6", "numeric_pad_7", "numeric_pad_8", "numeric_pad_9", "multiply", "add", "separator", "subtract", "decimal", "divide", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", "f24", "unassigned", "num_lock", "scroll_lock", "oem_specific", "unassigned", "left_shift", "right_shift", "left_control", "right_control", "left_menu", "right_menu", "browser_back", "browser_forward", "browser_refresh", "browser_stop", "browser_search", "browser_favorites", "browser_start_and_home", "volume_mute", "volume_down", "volume_up", "next_track", "previous_track", "stop_media", "play/pause_media", "start_mail", "select_media", "start_application_1", "start_application_2", "reserved", ";", "=", ",", "-",".","/","`", "reserved", "unassigned", "[", "\\", "]", "'", "used_for_miscellaneous_characters;_it_can_vary_by_board.", "reserved", "oem_specific", "either_the_angle_bracket__or_the_backslash__on_the_rt_102-_board", "oem_specific", "ime_process", "oem_specific", "used_to_pass_unicode_characters_as_if_they_were_strokes._the_vk_packet__is_the_low_word_of_a_32-bit_virtual_key_value_used_for_non-board_input_methods._for_more_information,_see_remark_in_keybdinput,_sendinput,_wm_keydown,_and_wm_keyup", "unassigned", "oem_specific", "attn", "crsel", "exsel", "erase_eof", "play", "zoom", "reserved", "pa1", "clear"]
		self.vk_codes = [0x20, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0C, 0x0D, 0x0E, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x15, 0x15, 0x16, 0x17, 0x18, 0x19, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A-40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x90, 0x91, 0x92, 0x97, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xD8, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9,0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE]
		self.special_keys = '~ ! @ # $ % ^ & * ( ) _ + | } { " : ? > <'.split()
		self.special_map  = "` 1 2 3 4 5 6 7 8 9 0 - = \\ ] [ ' ; / . ,".split()

class Keys(object): 
	space=32;left_mouse_button=1;right_mouse_button=2;control_break_processing=3;middle_mouse_button_three_button_mouse=4;x1_mouse_button=5;x2_mouse_button=6;undefined=7;backspace=8;tab=9;reserved=10;clear=12;enter=13;undefined=14;shift=16;ctrl=17;alt=18;pause=19;caps_lock=20;undefined=22;undefined=26;esc=27;spacebar=32;page_up=33;page_down=34;end=35;home=36;left_arrow=37;up_arrow=38;right_arrow=39;down_arrow=40;select=41;print_key=42;execute=43;print_screen=44;ins=45;delete=46;help_key=47;zero=48;one=49;two=50;three=51;four=52;five=53;six=54;seven=55;eight=56;nine=57;undefined=18;a=65;b=66;c=67;d=68;e=69;f=70;g=71;h=72;i=73;j=74;k=75;l=76;m=77;n=78;o=79;p=80;q=81;r=82;s=83;t=84;u=85;v=86;w=87;x=88;y=89;z=90;left_windows__natural_board=91;right_windows__natural_board=92;applications__natural_board=93;reserved=94;computer_sleep=95;numeric_pad_0=96;numeric_pad_1=97;numeric_pad_2=98;numeric_pad_3=99;numeric_pad_4=100;numeric_pad_5=101;numeric_pad_6=102;numeric_pad_7=103;numeric_pad_8=104;numeric_pad_9=105;multiply=106;add=107;separator=108;subtract=109;decimal=110;divide=111;f1=112;f2=113;f3=114;f4=115;f5=116;f6=117;f7=118;f8=119;f9=120;f10=121;f11=122;f12=123;f13=124;f14=125;f15=126;f16=127;f17=128;f18=129;f19=130;f20=131;f21=132;f22=133;f23=134;f24=135;unassigned=136;num_lock=144;scroll_lock=145;oem_specific=146;unassigned=151;left_shift=160;right_shift=161;left_control=162;right_control=163;left_menu=164;right_menu=165;browser_back=166;browser_forward=167;browser_refresh=168;browser_stop=169;browser_search=170;browser_favorites=171;browser_start_and_home=172;volume_mute=173;volume_down=174;volume_up=175;next_track=176;previous_track=177;stop_media=178;play_pause_media=179;start_mail=180;select_media=181;start_application_1=182;start_application_2=183;reserved=184;semicolon=186;equals=187;comma=188;minus=189;peiod=190;forward_slash=191;back_tick=192;reserved=193;unassigned=216;open_brace=219;backslash=220;close_brace=221;apostrophe=222;reserved=224;oem_specific=225;either_the_angle_bracket__or_the_backslash__on_the_rt_102__board=226;oem_specific=227;oem_specific=230;unassigned=232;oem_specific=233;attn=246;crsel=247;exsel=248;erase_eof=249;play=250;zoom=251;reserved=252;pa1=253;clear=254;

class Robot(object):
	'''
	A pure python windows automation library loosely modeled after Java's Robot Class.
	'''

	def __init__(self):
		self.windll =windll.kernel32
		self.cdll = cdll.msvcrt
		self.win32con = WIN32CON()
		self.press_events = {
			'left' :  (self.win32con.LEFT_DOWN, None, None, None, None), 
			'right':  (self.win32con.RIGHT_DOWN, None, None, None, None), 
			'middle': (self.win32con.MIDDLE_DOWN, None, None, None, None)
		}

		self.release_events = {
			'left' :  (self.win32con.LEFT_UP, None, None, None, None), 
			'right':  (self.win32con.RIGHT_UP, None, None, None, None), 
			'middle': (self.win32con.MIDDLE_UP, None, None, None, None)
		}

		self.keys = KeyConsts()

	def set_mouse_pos(self, x, y):
		'''
		Moves mouse pointer to given screen coordinates.
		'''
		windll.user32.SetCursorPos(x,y)

	def get_mouse_pos(self):
		'''
		Returns current mouse coordinates
		'''
		coords = pointer(c_long(0))
		windll.user32.GetCursorPos(coords)
		return (coords[0], coords[1])

	def get_pixel(self, x, y):
		'''
		Returns the pixel color of the given screen coordinate
		'''
		gdi= windll.gdi32
		RGBInt = gdi.GetPixel(
			windll.user32.GetDC(0),
			x, y
		)<commit_msg>Make 'KeyConsts' better, because yays.<commit_after>'''

A pure python windows automation library loosely modeled after Java's Robot Class.


TODO:
	* Mac support  
	* Allow window section for relative coordinates.
	* ability to 'paint' target window. 



I can never remember how these map... 
----  LEGEND ----

BYTE      = c_ubyte
WORD      = c_ushort
DWORD     = c_ulong
LPBYTE    = POINTER(c_ubyte)
LPTSTR    = POINTER(c_char) 
HANDLE    = c_void_p
PVOID     = c_void_p
LPVOID    = c_void_p
UNIT_PTR  = c_ulong
SIZE_T    = c_ulong

'''


import sys
import time
import ctypes 
import multiprocessing 
from ctypes import *
from ctypes.wintypes import *



class WIN32CON(object):
	def __init__(self):
		self.LEFT_DOWN = 0x0002
		self.LEFT_UP = 0x0004
		self.MIDDLE_DOWN = 0x0020
		self.MIDDLE_UP = 0x0040
		self.MOVE = 0x0001
		self.RIGHT_DOWN = 0x0008
		self.RIGHT_UP = 0x0010
		self.WHEEL = 0x0800
		self.XDOWN = 0x0080
		self.XUP = 0x0100
		self.HWHEEL = 0x01000


class BITMAP(ctypes.Structure):
	_fields_ = [
		('bmType', c_int),
		('bmWidth', c_int),
		('bmHeight', c_int),
		('bmHeightBytes', c_int),
		('bmPlanes', c_short),
		('bmBitsPixel', c_short),
		('bmBits', c_void_p),
	]

class BITMAPFILEHEADER(ctypes.Structure):
	_fields_ = [
		('bfType', ctypes.c_short),
		('bfSize', ctypes.c_uint32),
		('bfReserved1', ctypes.c_short),
		('bfReserved2', ctypes.c_short),
		('bfOffBits', ctypes.c_uint32)
	]

class BITMAPINFOHEADER(ctypes.Structure):
	_fields_ = [
		('biSize', ctypes.c_uint32),
		('biWidth', ctypes.c_int),
		('biHeight', ctypes.c_int),
		('biPlanes', ctypes.c_short),
		('biBitCount', ctypes.c_short),
		('biCompression', ctypes.c_uint32),
		('biSizeImage', ctypes.c_uint32),
		('biXPelsPerMeter', ctypes.c_long),
		('biYPelsPerMeter', ctypes.c_long),
		('biClrUsed', ctypes.c_uint32),
		('biClrImportant', ctypes.c_uint32)
	]

class BITMAPINFO(ctypes.Structure):
	_fields_ = [
		('bmiHeader', BITMAPINFOHEADER),
		('bmiColors', ctypes.c_ulong * 3)
	]


class MOUSEINPUT(Structure):
	_fields_ = [
		('dx', LONG),
		('dy', LONG),
		('mouseData', DWORD),
		('dwFlags', DWORD),
		('time', DWORD),
		('dwExtraInfo', POINTER(ULONG)),
	]

class KEYBDINPUT(Structure):
	_fields_ = [
		('wVk', WORD),
		('wScan', WORD),
		('dwFlags', DWORD),
		('time', DWORD),
		('dwExtraInfo', POINTER(ULONG)),
	]

class HARDWAREINPUT(Structure):
	_fields_ = [
		('uMsg', DWORD),
		('wParamL', WORD),
		('wParamH', DWORD)
	]

class INPUT(Structure):
	class _I(Union):
		_fields_ = [
			('mi', MOUSEINPUT),
			('ki', KEYBDINPUT),
			('hi', HARDWAREINPUT),
		]

	_anonymous_ = 'i'
	_fields_ = [
		('type', DWORD),
		('i', _I),
	]


class KeyConsts(object):
	key_names = [" ", "left_mouse_button", "right_mouse_button", "control-break_processing", "middle_mouse_button_(three-button_mouse)", "x1_mouse_button", "x2_mouse_button", "undefined", "backspace", "tab", "reserved", "clear", "enter", "undefined", "shift", "ctrl", "alt", "pause", "caps_lock", "ime_kana_mode", "ime_hanguel_mode_(maintained_for_compatibility;_use_vk_hangul)", "ime_hangul_mode", "undefined", "ime_junja_mode", "ime_final_mode", "ime_hanja_mode", "ime_kanji_mode", "undefined", "esc", "ime_convert", "ime_nonconvert", "ime_accept", "ime_mode_change_request", "spacebar", "page_up", "page_down", "end", "home", "left_arrow", "up_arrow", "right_arrow", "down_arrow", "select", "print", "execute", "print_screen", "ins", "del", "help", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "undefined", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "left_windows__(natural_board)", "right_windows__(natural_board)", "applications__(natural_board)", "reserved", "computer_sleep", "numeric_pad_0", "numeric_pad_1", "numeric_pad_2", "numeric_pad_3", "numeric_pad_4", "numeric_pad_5", "numeric_pad_6", "numeric_pad_7", "numeric_pad_8", "numeric_pad_9", "multiply", "add", "separator", "subtract", "decimal", "divide", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", "f24", "unassigned", "num_lock", "scroll_lock", "oem_specific", "unassigned", "left_shift", "right_shift", "left_control", "right_control", "left_menu", "right_menu", "browser_back", "browser_forward", "browser_refresh", "browser_stop", "browser_search", "browser_favorites", "browser_start_and_home", "volume_mute", "volume_down", "volume_up", "next_track", "previous_track", "stop_media", "play/pause_media", "start_mail", "select_media", "start_application_1", "start_application_2", "reserved", ";", "=", ",", "-",".","/","`", "reserved", "unassigned", "[", "\\", "]", "'", "used_for_miscellaneous_characters;_it_can_vary_by_board.", "reserved", "oem_specific", "either_the_angle_bracket__or_the_backslash__on_the_rt_102-_board", "oem_specific", "ime_process", "oem_specific", "used_to_pass_unicode_characters_as_if_they_were_strokes._the_vk_packet__is_the_low_word_of_a_32-bit_virtual_key_value_used_for_non-board_input_methods._for_more_information,_see_remark_in_keybdinput,_sendinput,_wm_keydown,_and_wm_keyup", "unassigned", "oem_specific", "attn", "crsel", "exsel", "erase_eof", "play", "zoom", "reserved", "pa1", "clear"]
	vk_codes = [0x20, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0C, 0x0D, 0x0E, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x15, 0x15, 0x16, 0x17, 0x18, 0x19, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A-40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x90, 0x91, 0x92, 0x97, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xD8, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9,0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE]
	special_keys = '~ ! @ # $ % ^ & * ( ) _ + | } { " : ? > <'.split()
	special_map  = "` 1 2 3 4 5 6 7 8 9 0 - = \\ ] [ ' ; / . ,".split()

class Keys(object): 
	space=32;left_mouse_button=1;right_mouse_button=2;control_break_processing=3;middle_mouse_button_three_button_mouse=4;x1_mouse_button=5;x2_mouse_button=6;undefined=7;backspace=8;tab=9;reserved=10;clear=12;enter=13;undefined=14;shift=16;ctrl=17;alt=18;pause=19;caps_lock=20;undefined=22;undefined=26;esc=27;spacebar=32;page_up=33;page_down=34;end=35;home=36;left_arrow=37;up_arrow=38;right_arrow=39;down_arrow=40;select=41;print_key=42;execute=43;print_screen=44;ins=45;delete=46;help_key=47;zero=48;one=49;two=50;three=51;four=52;five=53;six=54;seven=55;eight=56;nine=57;undefined=18;a=65;b=66;c=67;d=68;e=69;f=70;g=71;h=72;i=73;j=74;k=75;l=76;m=77;n=78;o=79;p=80;q=81;r=82;s=83;t=84;u=85;v=86;w=87;x=88;y=89;z=90;left_windows__natural_board=91;right_windows__natural_board=92;applications__natural_board=93;reserved=94;computer_sleep=95;numeric_pad_0=96;numeric_pad_1=97;numeric_pad_2=98;numeric_pad_3=99;numeric_pad_4=100;numeric_pad_5=101;numeric_pad_6=102;numeric_pad_7=103;numeric_pad_8=104;numeric_pad_9=105;multiply=106;add=107;separator=108;subtract=109;decimal=110;divide=111;f1=112;f2=113;f3=114;f4=115;f5=116;f6=117;f7=118;f8=119;f9=120;f10=121;f11=122;f12=123;f13=124;f14=125;f15=126;f16=127;f17=128;f18=129;f19=130;f20=131;f21=132;f22=133;f23=134;f24=135;unassigned=136;num_lock=144;scroll_lock=145;oem_specific=146;unassigned=151;left_shift=160;right_shift=161;left_control=162;right_control=163;left_menu=164;right_menu=165;browser_back=166;browser_forward=167;browser_refresh=168;browser_stop=169;browser_search=170;browser_favorites=171;browser_start_and_home=172;volume_mute=173;volume_down=174;volume_up=175;next_track=176;previous_track=177;stop_media=178;play_pause_media=179;start_mail=180;select_media=181;start_application_1=182;start_application_2=183;reserved=184;semicolon=186;equals=187;comma=188;minus=189;peiod=190;forward_slash=191;back_tick=192;reserved=193;unassigned=216;open_brace=219;backslash=220;close_brace=221;apostrophe=222;reserved=224;oem_specific=225;either_the_angle_bracket__or_the_backslash__on_the_rt_102__board=226;oem_specific=227;oem_specific=230;unassigned=232;oem_specific=233;attn=246;crsel=247;exsel=248;erase_eof=249;play=250;zoom=251;reserved=252;pa1=253;clear=254;

class Robot(object):
	'''
	A pure python windows automation library loosely modeled after Java's Robot Class.
	'''

	def __init__(self):
		self.windll =windll.kernel32
		self.cdll = cdll.msvcrt
		self.win32con = WIN32CON()
		self.press_events = {
			'left' :  (self.win32con.LEFT_DOWN, None, None, None, None), 
			'right':  (self.win32con.RIGHT_DOWN, None, None, None, None), 
			'middle': (self.win32con.MIDDLE_DOWN, None, None, None, None)
		}

		self.release_events = {
			'left' :  (self.win32con.LEFT_UP, None, None, None, None), 
			'right':  (self.win32con.RIGHT_UP, None, None, None, None), 
			'middle': (self.win32con.MIDDLE_UP, None, None, None, None)
		}

		self.keys = KeyConsts

	def set_mouse_pos(self, x, y):
		'''
		Moves mouse pointer to given screen coordinates.
		'''
		windll.user32.SetCursorPos(x,y)

	def get_mouse_pos(self):
		'''
		Returns current mouse coordinates
		'''
		coords = pointer(c_long(0))
		windll.user32.GetCursorPos(coords)
		return (coords[0], coords[1])

	def get_pixel(self, x, y):
		'''
		Returns the pixel color of the given screen coordinate
		'''
		gdi= windll.gdi32
		RGBInt = gdi.GetPixel(
			windll.user32.GetDC(0),
			x, y
		)
{'fraction_non_alphanumeric': 0.18132443071403656, 'fraction_numerical': 0.11430564552294584, 'mean_word_length': 6.935943060498221, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1483588', 'n_tokens_mistral': 10576, 'n_tokens_neox': 8896, 'n_words': 1445}