Ejemplo n.º 1
0
def period_part(name, period):

    count_token = Counter.get_new_token('screens/period')
    local_counter = 0

    total, scale = folderSize('screens/period')
    #total = size_[0]
    #scale = size_[1]

    print('\nPeriod part is activated\nSize is {0} {1}\n'.format(
        round(total, 2), scale))
    while True:

        time.sleep(period)

        image = ImageGrab.grab()
        filename = 'screens/period/{0}={1}.png'.format(
            datetime.datetime.now().strftime('%m%d%Y,%H-%M-%S'), name)
        image.save(filename)
        # filename2 = 'screens/test_period/{0}={1}.png'.format(
        #     name, datetime.datetime.now().strftime('%m%d%Y,%H-%M-%S'))
        # image.save(filename2)
        print('_PERIOD_ : {0}'.format(filename))
        logMsgs('1', '_PERIOD_ : {0}'.format(filename))
        Counter.inc(count_token, filename)
        local_counter += 1
        print('PERIOD:{0}'.format(local_counter))
        pass

    pass
Ejemplo n.º 2
0
def press_part(name):

    count_token = Counter.get_new_token('screens/pressed')
    local_counter = 0

    total, scale = folderSize('screens/pressed')
    #total = size_[0]
    #scale = size_[1]

    print('\nPress part is activated\nSize is {0} {1}\n'.format(
        round(total, 2), scale))
    ind = 0

    last_time = datetime.datetime.now()

    while True:
        if keyboard.is_pressed('i') or keyboard.is_pressed(
                'o') or keyboard.is_pressed('p'):

            if last_time + datetime.timedelta(
                    seconds=1) > datetime.datetime.now():
                print('_PRESSED_ : Skipped once because of time')
                continue
                pass

            image = ImageGrab.grab()
            last_time = datetime.datetime.now()
            filename = 'screens/pressed/{0}={1}.png'.format(
                datetime.datetime.now().strftime('%m%d%Y,%H-%M-%S'), name)
            image.save(filename)
            # filename2 = 'screens/test_pressed/{0}={1}.png'.format(
            #     name, datetime.datetime.now().strftime('%m%d%Y,%H-%M-%S'))
            # image.save(filename2)
            print('_PRESSED_ : {0}'.format(filename))
            logMsgs('1', '_PRESSED_ : {0}'.format(filename))
            Counter.inc(count_token, filename)
            local_counter += 1
            print('PRESS:{0}'.format(local_counter))
        else:
            pass

        ind = ind + 1

        if ind == 3000:
            ind = 0
            time.sleep(0.5)
            pass
        pass

    pass
Ejemplo n.º 3
0
def random_part(name, time_limit):

    count_token = Counter.get_new_token('screens/randomly')
    local_counter = 0

    total, scale = folderSize('screens/randomly')
    #total = size_[0]
    #scale = size_[1]

    print('\nRandom part is activated\nSize is {0} {1}\n'.format(
        round(total, 2), scale))

    last_time = datetime.datetime.now() + datetime.timedelta(seconds=2)

    while datetime.datetime.now() < time_limit:
        tmp = random.randrange(0, 2000)
        # tmp = random.randrange(0,250)
        if tmp < 250:

            if last_time + datetime.timedelta(
                    seconds=1) > datetime.datetime.now():
                print('_LUCKYBOY_ : Skipped once because of time')
                continue
                pass

            image = ImageGrab.grab()
            last_time = datetime.datetime.now()
            filename = 'screens/randomly/{0}={1}.png'.format(
                datetime.datetime.now().strftime('%m%d%Y,%H-%M-%S'), name)
            image.save(filename)
            # filename2 = 'screens/test_randomly/{0}={1}.png'.format(
            #     name, datetime.datetime.now().strftime('%m%d%Y,%H-%M-%S'))
            # image.save(filename2)
            print('_LUCKYBOY_ : {0}'.format(filename))
            logMsgs('1', '_LUCKYBOY_ : {0}'.format(filename))
            Counter.inc(count_token, filename)
            local_counter += 1
            print('RANDOM:{0}'.format(local_counter))
        else:
            pass
        time.sleep(1)

    pass
Ejemplo n.º 4
0
def counter(token, item):
    Counter.inc(token, item)
    pass