include get.e include dll.e include misc.e include machine.e without warning -- Library: SendMouse -- Author: Guillermo Bonvehi (pampeano@rocketmail.com) -- Version: 0.4 -- Description: It allows to send mouse commands instead of having to input them -- Comments: Inspired on Sendkeys by Thomas Parslow include dll.e constant smUSER32 = open_dll("user32.dll") constant smMouseEvent = define_c_proc(smUSER32,"mouse_event",{C_UCHAR,C_LONG,C_ULONG,C_ULONG,C_ULONG}), smGetSystemMetrics = define_c_func(smUSER32,"GetSystemMetrics",{C_INT},C_LONG) -- Send Mouse Left Click global procedure SendMouseLClick() c_proc(smMouseEvent,{#2,0,0,0,0}) -- Left button down c_proc(smMouseEvent,{#4,0,0,0,0}) -- Left button up end procedure -- Send Mouse Middle Click global procedure SendMouseMClick() c_proc(smMouseEvent,{#20,0,0,0,0}) -- Middle button down c_proc(smMouseEvent,{#40,0,0,0,0}) -- Middle button down end procedure -- Send Mouse Right Click global procedure SendMouseRClick() c_proc(smMouseEvent,{#8,0,0,0,0}) -- Right button down c_proc(smMouseEvent,{#10,0,0,0,0}) -- Right button down end procedure -- Send Mouse Relative Move (it's relative to where the cursor is) global procedure SendMouseRMove(atom x, atom y) c_proc(smMouseEvent,{#0001,x,y,0,0}) -- Movement end procedure -- Send Mouse Absolute Move global procedure SendMouseAMove(atom x, atom y) atom cx, cy cx=c_func(smGetSystemMetrics,{0}) cy=c_func(smGetSystemMetrics,{1}) cx = 65535/cx -- Absolute coords range from 0 to 65535 so cy = 65535/cy -- we have to change to pixel coords c_proc(smMouseEvent,{#8001,cx*x,cy*y,0,0}) -- Absolute + Movement end procedure -- Send Mouse Wheel Movement (Positive forwards, negative backwards) global procedure SendMouseWheel(atom z) c_proc(smMouseEvent,{#800,0,0,z,0}) end procedure constant gdi=open_dll("gdi32"), user=open_dll("user32"), kernel=open_dll("kernel32"), DeleteDC_=define_c_func(gdi,"DeleteDC",{C_INT},C_INT), GetDesktopWindow_=define_c_func(user,"GetDesktopWindow",{},C_INT), GlobalLock_=define_c_func(kernel,"GlobalLock",{C_POINTER},C_POINTER), GlobalUnlock_=define_c_func(kernel,"GlobalUnlock",{C_POINTER},C_POINTER), CreateCompatibleDC_=define_c_func(gdi,"CreateCompatibleDC",{C_INT},C_POINTER), CreateDIBSection_=define_c_func(gdi,"CreateDIBSection",{C_INT,C_POINTER,C_UINT,C_POINTER,C_INT,C_UINT},C_POINTER), SelectObject_=define_c_func(gdi,"SelectObject",{C_INT,C_INT},C_INT), DeleteObject_=define_c_func(gdi,"DeleteObject",{C_POINTER},C_INT), GetObject_=define_c_func(gdi,"GetObjectA",{C_INT,C_INT,C_POINTER},C_INT), BitBlt_=define_c_func(gdi,"BitBlt",repeat(C_INT,8)&C_UINT,C_INT), EnumWindows_=define_c_func(user,"EnumWindows",{C_POINTER,C_POINTER},C_INT), GetClassName_=define_c_func(user,"GetClassNameA",{C_INT,C_POINTER,C_INT},C_INT), GetWindowText_=define_c_func(user,"GetWindowTextA",{C_INT,C_POINTER,C_INT},C_INT), GetWindowRect_=define_c_func(user,"GetWindowRect",{C_INT,C_POINTER},C_INT), GetDC_=define_c_func(user,"GetDC",{C_INT},C_INT), GetClientRect_=define_c_func(user,"GetClientRect",{C_INT,C_POINTER},C_INT), SizeOf_bmi_bmiHeader=40, biSize=0,--DWORD biWidth=4,--LONG biHeight=8,--LONG biPlanes=12,--WORD biBitCount=14,--WORD biCompression=16,--DWORD biSizeImage=20,--DWORD biXPelsPerMeter=24,--LONG biYPelsPerMeter=28,--LONG biClrUsed=32,--DWORD biClrImportant=36,--DWORD BI_RGB=0, DIB_RGB_COLORS=0, SRCCOPY=#CC0020, bmType=0,--LONG bmWidth=4,--LONG bmHeight=8,--LONG bmWidthBytes=12,--LONG bmPlanes=16,--WORD bmBitsPixel=18,--WORD bmBits=20--LPVOID 24+40+8 atom junk function serialize(sequence a) sequence ret ret={} for i = 1 to length(a) do if atom(a[i]) then ret&=a[i] else ret&=serialize(a[i]) end if end for return ret end function constant unchecked_square=serialize( { repeat(255,15*3)&repeat(192,1*3), repeat(255,14*3)&repeat(192,1*3)&repeat(128,1*3) }& repeat(repeat(255,2*3)&repeat(192,12*3)&repeat(128,2*3),12)& { repeat(255,1*3)&repeat(192,1*3)&repeat(128,14*3), repeat(192,1*3)&repeat(128,15*3)}), checked_square0= {128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,128,128,128,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,128, 128,128,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,128,128,128,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,128,128,128,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,128,128, 128,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192}, checked_square2={128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 192,192,192,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0, 0,128,0,192,192,192,192,192,192,192,192,192,192,192,192,128,128,128, 192,192,192,192,192,192,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128, 0,0,128,0,0,128,0,0,128,0,0,128,0,192,192,192,192,192,192,192,192,192, 128,128,128,192,192,192,192,192,192,0,128,0,0,128,0,0,128,0,192,192, 192,192,192,192,192,192,192,192,192,192,0,128,0,0,128,0,0,128,0,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,0,128,0,0,128,0,0,128,0,192,192,192,192,192,192,192, 192,192,128,128,128,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,0,128,0,0,128,0,0,128,0,0,128,0, 192,192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,0,128,0,0,128,0, 0,128,0,0,128,0,0,128,0,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192,0,128, 0,0,128,0,0,128,0,0,128,0,0,128,0,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192, 192,192,192,192,0,128,0,0,128,0,0,128,0,0,128,0,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,128,128,128,192,192,192,192,192,192,0,128,0,0,128, 0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128, 0,0,128,0,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192}, checked_square4={128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 192,192,192,192,192,192,128,0,0,128,0,0,128,0,0,192,192,192,128,0,0, 128,0,0,128,0,0,192,192,192,192,192,192,192,192,192,192,192,192,128, 128,128,192,192,192,192,192,192,192,192,192,192,192,192,128,0,0,128, 0,0,128,0,0,192,192,192,128,0,0,128,0,0,128,0,0,192,192,192,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,128,0,0,128,0,0,128,0,0,192,192,192,192,192,192,128,0,0,128, 0,0,128,0,0,192,192,192,192,192,192,192,192,192,192,192,192,128,128, 128,192,192,192,192,192,192,192,192,192,128,0,0,128,0,0,128,0,0,192, 192,192,192,192,192,128,0,0,128,0,0,128,0,0,192,192,192,192,192,192, 192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,128,0,0, 128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128, 0,0,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192, 192,192,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128, 0,0,128,0,0,128,0,0,192,192,192,192,192,192,192,192,192,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,128,0,0,128,0,0,128,0,0,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,128,0,0,128,0,0,128,0,0,192,192,192,192,192,192,192,192,192,192, 192,192,128,128,128,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,128,0,0,128,0,0,128, 0,0,192,192,192,192,192,192,192,192,192,192,192,192,128,128,128,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,128,0,0,128,0,0,128,0,0,192,192,192,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,128,128,128,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192}, checked_square3={128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0, 255,192,192,192,192,192,192,192,192,192,192,192,192,128,128,128,192, 192,192,192,192,192,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255, 0,0,255,0,0,255,0,0,255,0,0,255,192,192,192,192,192,192,192,192,192, 128,128,128,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,255,0,0,255, 0,0,255,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,0,0,255,0,0,255,0,0,255,192,192,192,192, 192,192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0, 255,192,192,192,192,192,192,192,192,192,192,192,192,128,128,128,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,255,0,0, 255,0,0,255,0,0,255,0,0,255,0,0,255,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 0,0,255,0,0,255,0,0,255,192,192,192,192,192,192,192,192,192,128,128, 128,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,0,0,255,0,0,255,0,0,255, 192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192, 192,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255, 0,0,255,0,0,255,192,192,192,192,192,192,192,192,192,128,128,128,192, 192,192,192,192,192,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255, 0,0,255,0,0,255,0,0,255,192,192,192,192,192,192,192,192,192,192,192, 192,128,128,128,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,128,128, 128,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192}, checked_square8={128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 192,192,192,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,192,192,192,192,192,192,192, 192,192,192,192,192,128,128,128,192,192,192,192,192,192,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,192,192,192,192,192,192,192, 192,192,128,128,128,192,192,192,192,192,192,128,128,128,128,128,128, 128,128,128,192,192,192,192,192,192,192,192,192,192,192,192,128,128, 128,128,128,128,128,128,128,192,192,192,192,192,192,192,192,192,128, 128,128,192,192,192,192,192,192,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,128,128,128,128,128, 128,128,128,128,192,192,192,192,192,192,192,192,192,128,128,128,192, 192,192,192,192,192,192,192,192,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,192,192, 192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192, 192,192,192,192,192,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,192,192,192,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,128, 128,128,128,128,128,128,128,128,192,192,192,192,192,192,192,192,192, 192,192,192,128,128,128,128,128,128,128,128,128,192,192,192,192,192, 192,192,192,192,128,128,128,192,192,192,192,192,192,128,128,128,128, 128,128,128,128,128,192,192,192,192,192,192,192,192,192,192,192,192, 128,128,128,128,128,128,128,128,128,192,192,192,192,192,192,192,192, 192,128,128,128,192,192,192,192,192,192,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,192,192,192,192,192,192,192,192,192,128,128, 128,192,192,192,192,192,192,192,192,192,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192}, checked_square5={128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0, 128,0,0,128,192,192,192,192,192,192,192,192,192,128,128,128,192,192, 192,192,192,192,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0, 128,0,0,128,0,0,128,0,0,128,192,192,192,192,192,192,192,192,192,128, 128,128,192,192,192,192,192,192,0,0,128,0,0,128,0,0,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192, 192,192,0,0,128,0,0,128,0,0,128,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,128,192,192,192,192,192,192,0,0,128,0,0,128, 0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,192,192,192, 192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192, 192,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128, 0,0,128,0,0,128,192,192,192,192,192,192,192,192,192,128,128,128,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,0,0,128,0,0,128,0,0,128,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,0,0,128,0,0,128,0,0,128,192,192,192,192,192,192,192,192, 192,128,128,128,192,192,192,192,192,192,0,0,128,0,0,128,0,0,128,0,0, 128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,192,192,192,192, 192,192,192,192,192,128,128,128,192,192,192,192,192,192,0,0,128,0,0, 128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128,192,192, 192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192}, checked_square6={128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 192,192,192,128,128,0,128,128,0,128,128,0,128,128,0,128,128,0,128,128, 0,128,128,0,128,128,0,192,192,192,192,192,192,192,192,192,192,192,192, 128,128,128,192,192,192,192,192,192,128,128,0,128,128,0,128,128,0,128, 128,0,128,128,0,128,128,0,128,128,0,128,128,0,128,128,0,192,192,192, 192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192, 192,128,128,0,128,128,0,128,128,0,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,128,192,192,192,192,192,192,128,128,0,128,128, 0,128,128,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,128, 128,128,192,192,192,192,192,192,128,128,0,128,128,0,128,128,0,128,128, 0,128,128,0,128,128,0,128,128,0,128,128,0,128,128,0,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 128,128,0,128,128,0,128,128,0,128,128,0,128,128,0,128,128,0,128,128, 0,128,128,0,128,128,0,128,128,0,192,192,192,192,192,192,192,192,192, 128,128,128,192,192,192,192,192,192,128,128,0,128,128,0,128,128,0,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,0,128,128,0,128, 128,0,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192, 192,192,128,128,0,128,128,0,128,128,0,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,0,128,128,0,128,128,0,192,192,192,192,192,192, 192,192,192,128,128,128,192,192,192,192,192,192,128,128,0,128,128,0, 128,128,0,128,128,0,128,128,0,128,128,0,128,128,0,128,128,0,128,128, 0,128,128,0,192,192,192,192,192,192,192,192,192,128,128,128,192,192, 192,192,192,192,192,192,192,128,128,0,128,128,0,128,128,0,128,128,0, 128,128,0,128,128,0,128,128,0,128,128,0,192,192,192,192,192,192,192, 192,192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,128,128,128,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,128, 128,128,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192}, checked_square7={128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192, 192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,128,128, 128,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,128, 128,128,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,0, 0,0,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 128,128,128,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0, 0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,128,128,128,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192}, checked_square1={128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,255,0,0, 255,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,128,128,128,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,255,0,0,255,0,0,255,0,0,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,255,0,0, 255,0,0,255,0,0,255,0,0,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,192,192,192,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,128, 128,128,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,255,0,0,255,0,0,255,0,0,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,255,0,0,255, 0,0,255,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,255,0,0,255,0,0,255,0,0,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,128,128, 128,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,255,0,0,255,0,0,255,0,0,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192, 192,192,192,192,192,192,192,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0, 255,0,0,255,0,0,192,192,192,192,192,192,192,192,192,192,192,192,128, 128,128,192,192,192,192,192,192,192,192,192,192,192,192,255,0,0,255, 0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,192,192,192,192,192,192, 192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,128,128,128,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 128,128,128,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192}, found_bomb={128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0, 255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,128,128,128,0,0, 255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,0,0,0,255,0, 0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,128,128,128,0,0,255,0, 0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,0,0,0,255,0,0,255, 0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,128,128,128,0,0,255,0,0,255, 0,0,255,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0, 0,255,0,0,255,0,0,255,128,128,128,0,0,255,0,0,255,0,0,255,0,0,255,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,255,0,0,255,0,0, 255,128,128,128,0,0,255,0,0,255,0,0,255,0,0,0,0,0,0,255,255,255,255, 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,255,0,0,255,128,128, 128,0,0,255,0,0,255,0,0,255,0,0,0,0,0,0,255,255,255,255,255,255,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,255,0,0,255,128,128,128,0,0,255, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,255,128,128,128,0,0,255,0,0,255,0,0,255,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,255,0,0,255,128, 128,128,0,0,255,0,0,255,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,255,0,0,255,0,0,255,128,128,128,0,0,255,0,0,255, 0,0,255,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0, 0,255,0,0,255,0,0,255,128,128,128,0,0,255,0,0,255,0,0,255,0,0,0,0,0, 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,0,255,0,0,255,0,0, 255,128,128,128,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0, 255,0,0,0,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,128, 128,128,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0, 0,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,128,128,128, 0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0, 255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255}, question_square={255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,192,192,192,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,192,192,192,128,128,128,255,255,255,255,255,255, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,128,128,128,128,128,128,255,255,255,255,255,255,192,192,192, 192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192, 192,192,192,192,192,192,192,192,192,192,128,128,128,128,128,128,255, 255,255,255,255,255,192,192,192,192,192,192,192,192,192,0,0,0,0,0,0, 192,192,192,192,192,192,0,0,0,0,0,0,192,192,192,192,192,192,192,192, 192,128,128,128,128,128,128,255,255,255,255,255,255,192,192,192,192, 192,192,192,192,192,0,0,0,0,0,0,192,192,192,192,192,192,0,0,0,0,0,0, 192,192,192,192,192,192,192,192,192,128,128,128,128,128,128,255,255, 255,255,255,255,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,0,0,0,0,0,0,192,192,192,192,192,192, 192,192,192,128,128,128,128,128,128,255,255,255,255,255,255,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0, 0,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,128,128,128, 128,128,128,255,255,255,255,255,255,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,0,0,0,0,0,0,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,128,128,128,255,255,255, 255,255,255,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,128,128,128,128,128,128,255,255,255,255,255,255,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,128, 128,128,128,128,128,255,255,255,255,255,255,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,128,128,128,128,128,128,255, 255,255,255,255,255,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,128,128,128,128,255,255,255,255,255,255,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,128,128,128,128,128,128,255,255,255,192,192,192,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,192,192,192,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128}, flagged_square={255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,192,192,192,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,192,192,192,128,128,128,255,255,255,255,255,255, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,128,128,128,128,128,128,255,255,255,255,255,255,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,0,0,255,0,0,255,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,128,128,128, 128,128,128,255,255,255,255,255,255,192,192,192,192,192,192,192,192, 192,0,0,255,0,0,255,0,0,255,0,0,255,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,128,128,128,128,128,128,255,255,255,255, 255,255,192,192,192,192,192,192,0,0,255,0,0,255,0,0,255,0,0,255,0,0, 255,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,128, 128,128,128,128,128,255,255,255,255,255,255,192,192,192,192,192,192, 192,192,192,0,0,255,0,0,255,0,0,255,0,0,255,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,128,128,128,128,128,128,255,255, 255,255,255,255,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,0,0,255,0,0,255,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,128,128,128,128,128,128,255,255,255,255,255,255,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,128, 128,128,128,128,128,255,255,255,255,255,255,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,128,128,128,128, 255,255,255,255,255,255,192,192,192,192,192,192,192,192,192,192,192, 192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,192, 192,192,128,128,128,128,128,128,255,255,255,255,255,255,192,192,192, 192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192, 192,192,192,192,128,128,128,128,128,128,255,255,255,255,255,255,192, 192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 192,192,192,192,192,192,128,128,128,128,128,128,255,255,255,255,255, 255,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,128,128,128,128,128,128,255,255,255,192,192,192,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,192,192,192,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128}, other_bomb={128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,128,128,128,192,192,192,192,192,192,192,192,192,0,0,0,192,192,192, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,192,192,192,192,192, 192,192,192,192,128,128,128,192,192,192,192,192,192,192,192,192,192, 192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,0,0,0,0,0,0,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192, 192,192,192,192,192,0,0,0,0,0,0,255,255,255,255,255,255,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,128,128,128,192, 192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192, 192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192,192, 192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192, 192,192,192,192,192,192,192,192,192,192,128,128,128,192,192,192,192, 192,192,192,192,192,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 192,192,192,0,0,0,192,192,192,192,192,192,192,192,192,128,128,128,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,128,128,128,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,128,128,128,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192} function peek_2d3b(sequence src, sequence rect)--src=ptr,width,height, rect=left,top,width,height sequence ret atom dptr,sptr ret=repeat(0,rect[3]*rect[4]*3) dptr=1 sptr=src[1]+((src[3]-rect[2]-1)*src[2]+rect[1])*3 --? ((src[3]-rect[2]-1)*src[2]+rect[1])*3 --? rect --? src for y= 1 to rect[4] do ret[dptr..dptr+rect[3]*3-1]=peek({sptr,rect[3]*3}) dptr+=rect[3]*3 sptr-=src[2]*3 end for return ret end function function get_num_us(sequence tiles,atom x,atom y) atom us sequence todo us=0 todo={{-1,-1},{0,-1},{1,-1},{-1,0},{1,0},{-1,1},{0,1},{1,1}} for i = 1 to length(todo) do if y+todo[i][2]>=1 and y+todo[i][2]<=length(tiles) then if x+todo[i][1]>=1 and x+todo[i][1]<=length(tiles[todo[i][2]+y]) then us+=tiles[todo[i][2]+y][todo[i][1]+x]='u' end if end if end for return us end function function get_num_fs(sequence tiles,atom x,atom y) atom us sequence todo us=0 todo={{-1,-1},{0,-1},{1,-1},{-1,0},{1,0},{-1,1},{0,1},{1,1}} for i = 1 to length(todo) do if y+todo[i][2]>=1 and y+todo[i][2]<=length(tiles) then if x+todo[i][1]>=1 and x+todo[i][1]<=length(tiles[todo[i][2]+y]) then us+=tiles[todo[i][2]+y][todo[i][1]+x]='F' end if end if end for return us end function function get_num_nums(sequence tiles,atom x,atom y) atom us sequence todo us=0 todo={{-1,-1},{0,-1},{1,-1},{-1,0},{1,0},{-1,1},{0,1},{1,1}} for i = 1 to length(todo) do if y+todo[i][2]>=1 and y+todo[i][2]<=length(tiles) then if x+todo[i][1]>=1 and x+todo[i][1]<=length(tiles[todo[i][2]+y]) then us+=find(tiles[todo[i][2]+y][todo[i][1]+x],"0123456789")!=0 end if end if end for return us end function function add_prob(sequence tiles,sequence prob, atom x, atom y, atom proba) sequence todo todo={{-1,-1},{0,-1},{1,-1},{-1,0},{1,0},{-1,1},{0,1},{1,1}} for i = 1 to length(todo) do if y+todo[i][2]>=1 and y+todo[i][2]<=length(tiles) then if x+todo[i][1]>=1 and x+todo[i][1]<=length(tiles[todo[i][2]+y]) and tiles[todo[i][2]+y][todo[i][1]+x]='u' then if proba>prob[todo[i][2]+y][todo[i][1]+x] then prob[todo[i][2]+y][todo[i][1]+x]=proba end if end if end if end for return prob end function function set_good(sequence good, atom x, atom y) sequence todo todo={{-1,-1},{0,-1},{1,-1},{-1,0},{1,0},{-1,1},{0,1},{1,1}} for i = 1 to length(todo) do if y+todo[i][2]>=1 and y+todo[i][2]<=length(good) then if x+todo[i][1]>=1 and x+todo[i][1]<=length(good[todo[i][2]+y]) then good[todo[i][2]+y][todo[i][1]+x]=1 end if end if end for return good end function with trace function get_prob(sequence tiles) sequence prob,goods atom found,num_us,probnum,num_fs,num_nums goods=repeat(repeat(0,length(tiles[1])),length(tiles)) prob=repeat(repeat(0,length(tiles[1])),length(tiles)) for y= 1 to length(tiles) do for x= 1 to length(tiles[y]) do found=find(tiles[y][x],"12345678") --if not found then found=8 end if if found then num_us=get_num_us(tiles,x,y) num_fs=get_num_fs(tiles,x,y) if num_fs1 then trace(1) end if prob=add_prob(tiles,prob,x,y,probnum) elsif num_us then goods=set_good(goods,x,y) end if else num_nums=get_num_nums(tiles,x,y) if num_nums=0 then if prob[y][x]<9 then prob[y][x]=9 end if end if end if end for end for -- ? prob for y= 1 to length(tiles) do for x= 1 to length(tiles[y]) do if goods[y][x] and tiles[y][x]='u' then prob[y][x]=0 end if end for end for -- ? goods -- sleep(1) return prob end function function screen_to_tiles(atom hwnd, atom hDC, sequence rect) atom space,hMemDC,hMemBmp,bmi,bm,bitmap,bm_Width,bm_Height sequence ret,tiles,temp,txy -- space=allocate(16) txy={(rect[3]-20),rect[4]-63}/16 if not integer(txy[1]) then return 0 end if if not integer(txy[2]) then return 0 end if if txy[1]<1 then return 0 end if if txy[2]<1 then return 0 end if tiles=repeat(repeat(0,txy[1]),txy[2]) hMemDC=c_func(CreateCompatibleDC_,{hDC}) bmi=allocate(40) poke4(bmi+biSize,SizeOf_bmi_bmiHeader) poke4(bmi+biWidth,rect[3]) poke4(bmi+biHeight,rect[4]) poke4(bmi+biPlanes,1) poke4(bmi+biBitCount,24) poke4(bmi+biCompression,BI_RGB) hMemBmp = c_func(CreateDIBSection_,{hMemDC, bmi, DIB_RGB_COLORS, 0, 0, 0}) junk=c_func(GlobalLock_,{hMemBmp}) --puts(1,"GlobalLock_ ") ? junk junk=c_func(SelectObject_,{hMemDC,hMemBmp}) --puts(1,"SelectObject_ ") ? junk bm=allocate(84) junk=c_func(GetObject_,{hMemBmp, 84, bm}) --puts(1,"GetObject_ ") ? junk --? {peek4s(bm+bmWidth),peek4s(bm+bmHeight)} junk=c_func(BitBlt_,{hMemDC, 0, 0, peek4s(bm+bmWidth), peek4s(bm+bmHeight), hDC, rect[1], rect[2], SRCCOPY}) --puts(1,"BitBlt_ ") ? junk --ret=peek({peek4u(bm+bmBits), 3*peek4s(bm+bmWidth)*peek4s(bm+bmHeight)}) bitmap=allocate(3*peek4s(bm+bmWidth)*peek4s(bm+bmHeight)) mem_copy(bitmap,peek4u(bm+bmBits),3*peek4s(bm+bmWidth)*peek4s(bm+bmHeight)) bm_Width=peek4s(bm+bmWidth) bm_Height=peek4s(bm+bmHeight) junk=c_func(DeleteDC_,{hMemDC}) junk=c_func(GlobalUnlock_,{hMemBmp}) junk=c_func(DeleteObject_,{hMemBmp}) free(bm) free(bmi) if 0 then if equal(peek_2d3b({peek4u(bm+bmBits),peek4s(bm+bmWidth),peek4s(bm+bmHeight)},{0,0,500,3}),repeat(255,500*3*3)) then puts(1,"Good Border1\n") else puts(1,"Bad Border1\n") return 0 end if if equal(peek_2d3b({peek4u(bm+bmBits),peek4s(bm+bmWidth),peek4s(bm+bmHeight)},{0,0,3,319}),repeat(255,319*3*3)) then puts(1,"Good Border2\n") else puts(1,"Bad Border2\n") return 0 end if if equal(peek_2d3b({peek4u(bm+bmBits),peek4s(bm+bmWidth),peek4s(bm+bmHeight)},{3,3,497,6}),repeat(192,497*6*3)) then puts(1,"Good Border3\n") else puts(1,"Bad Border3\n") return 0 end if if equal(peek_2d3b({peek4u(bm+bmBits),peek4s(bm+bmWidth),peek4s(bm+bmHeight)},{3,3,6,316}),repeat(192,6*316*3)) then puts(1,"Good Border4\n") else puts(1,"Bad Border4\n") return 0 end if end if --? peek_2d3b({peek4u(bm+bmBits),peek4s(bm+bmWidth),peek4s(bm+bmHeight)},{12,55,16,1}) --? peek_2d3b({peek4u(bm+bmBits),peek4s(bm+bmWidth),peek4s(bm+bmHeight)},{28,55,16,16}) for y=1 to txy[2] do--55 16 tiles for x=1 to txy[1] do--12 30 tiles tiles[y][x]=find(peek_2d3b({bitmap,bm_Width,bm_Height},{12+(x-1)*16,55+(y-1)*16,16,16}), { checked_square0, checked_square1, checked_square2, checked_square3, checked_square4, checked_square5, checked_square6, checked_square7, checked_square8, unchecked_square,found_bomb,other_bomb,flagged_square,question_square}) temp={'_','0','1','2','3','4','5','6','7','8','u','x','y','F','?'} tiles[y][x]=temp[1+tiles[y][x]] end for if find('_',tiles[y]) then free(bitmap) return 0 end if --puts(1,tiles[y]&10) end for free(bitmap) return tiles end function function fetch_screen(atom hwnd,atom hDC, sequence rect)--rect=left,top,width,height atom hMemDC,bmi,hMemBmp,bm,tot,fn,space,lp sequence ret,temp,winrect,probtiles,leastprob,to_flag,to_check object tiles if not rect[3] then return 1 end if if not rect[4] then return 1 end if tiles=screen_to_tiles(hwnd,hDC,rect) if atom(tiles) then return 0 end if space=allocate(16) junk=c_func(GetWindowRect_,{hwnd,space}) winrect=peek4s({space,4}) free(space) for y=1 to length(tiles) do if find('y',tiles[y]) then SendMouseAMove(winrect[1]+(winrect[3]-winrect[1])/2,winrect[2]+73) SendMouseLClick() return 0 end if end for for y=1 to length(tiles) do if find('x',tiles[y]) then SendMouseAMove(winrect[1]+(winrect[3]-winrect[1])/2,winrect[2]+73) SendMouseLClick() return 0 end if end for probtiles=tiles!='u' + tiles='u'*.5 leastprob={0,0} lp=100 probtiles=get_prob(tiles) to_flag={} to_check={} for y=1 to length(tiles) do for x=1 to length(tiles[y]) do if tiles[y][x]='u' and probtiles[y][x]