Example #1
0
def mouse_script():
    print("Right click to start and stop recording your mouse")

    mouse.wait('right')
    
    print("recording...")

    record = mouse.record(button='right')

    print("recording finished")

    return record
Example #2
0
def detectPosition():
    '''
    Waits until client presses middle button, then parses the mouse position to variables used by clickPosition().
    '''
    print(
        'Position your mouse where the claiming button is. When you are ready, click the middle button on your mouse to confirm the location'
    )
    mouse.wait(button='middle')
    pos = mouse.get_position()

    detectPosition.x = pos[0]
    detectPosition.y = pos[1]
Example #3
0
def enter_temp_stop():
    deactivate_hotkeys()
    # restart when the mouse button is stroken
    mouse.wait()
    activate_hotkeys()
Example #4
0
def enter_temp_stop():
    deactivate_hotkeys(mine_hotkey, flask_hotkey)
    # restart when the mouse button is stroken
    mouse.wait()
    activate_hotkeys(mine_hotkey, flask_hotkey, flasks_use)
Example #5
0
 def test_get_mouse_location(self):
     import mouse
     print('left click to print mouse position')
     mouse.wait('left')
     print(mouse.get_position())
Example #6
0
while liczenie <= 30:

    time.sleep(0.2)
    keyboard.press_and_release('down')

    time.sleep(0.1)
    keyboard.press_and_release('up')

    time.sleep(0.1)
    keyboard.press_and_release('ctrl + alt + r')
    time.sleep(0.1)

    keyboard.wait('shift + -')
    keyboard.write(gmina)
    time.sleep(0.1)
    mouse.wait(button='left')
    #keyboard.wait('enter')

    time.sleep(0.1)
    keyboard.press_and_release('up')
    time.sleep(0.1)

    keyboard.press_and_release('ctrl + s')
    time.sleep(0.1)
    keyboard.press_and_release('enter')
    time.sleep(0.1)
    #keyboard.press_and_release('down')

    time.sleep(0.1)

    print('zapisywanie', liczenie)
def downCallback():
    xValOld, yValOld = mouse.get_position()
    list[0] = xValOld
    list[1] = yValOld
    # print(xValOld ,' ', yValOld, ' pressed')


def upCallback():
    xVal, yVal = mouse.get_position()
    # print(xVal ,' ', yVal, ' released')
    # print(list)
    # print('\b' * list[2], end='', flush=True)
    printString = '({0}, {1}, {2}, {3})'.format(list[0], list[1],
                                                xVal - list[0], yVal - list[1])
    list[2] = len(printString)
    print(printString)


mouse.on_button(downCallback, (), mouse.LEFT, mouse.DOWN)

mouse.on_button(upCallback, (), mouse.LEFT, mouse.UP)

# while True:
#     x, y = mouse.get_position()
#     positionStr = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4)
#     print(positionStr, end='')
#     print('\b' * len(positionStr), end='', flush=True)

mouse.wait(button=None, target_types=None)
Example #8
0
        textbox_location = (config.mouse_width_typebox, bounding_box[3] +
                            config.mouse_offset_of_change_display_typebox)
        while not typist.is_finished():
            typo_flag = wait_for_text_to_be_written(3, textbox_location)
            if typist.is_finished():
                typo_flag = False
                break
            if typo_flag:
                break
        typist.stop_typing()

        if typo_flag:
            append = "typo"
            unsuccessful_types += 1
        else:
            append = "correct"
            successful_types += 1

        with open("quotes_log_" + append + ".txt", 'a') as f:
            f.write(text + "\n")

        time.sleep(0.3)
        print("Sucessful: {} | Unsuccessful: {}".format(
            successful_types, unsuccessful_types))


if __name__ == "__main__":
    keyboard.send(0)
    mouse.wait(target_types=(mouse.DOWN))
    # print(mouse.get_position())
    race_bot()
Example #9
0
def analyze():

    pic_folder = pathlib.Path('../figures/combinedorbit2')
    pics = os.listdir(pic_folder)
    pic_paths = [os.path.join(pic_folder, pic) for pic in pics]

    pic_date_format = int(
        input(
            'What is the format for the date in the pictures?\n 1 - "Year-DOYTHour", 2 - "YearDOY_HourMinute"\n '
        ))
    naming_format = {
        1: {
            'size': [-15, -4],
            'format': '%Y-%jT%H'
        },
        2: {
            'size': [-16, -4],
            'format': '%Y%j_%H%M'
        }
    }
    date_format_index = naming_format[pic_date_format]['size']
    date_strip_format = naming_format[pic_date_format]['format']

    start_date = str(
        input(
            'What date(Y-M-DTH) would you like to start with?\nTo start from the beginning picture press Enter - '
        ))

    if start_date == '':
        pic_num = 0
    else:
        start_date_doy = datetime.datetime.strptime(start_date, '%Y-%m-%dT%H')
        print(start_date_doy)
        for num, pic in enumerate(pic_paths):
            if datetime.datetime.strptime(
                    pic[date_format_index[0]:date_format_index[1]],
                    date_strip_format) == start_date_doy:
                pic_num = num
                print(num)
                break

    time_list = []
    pos_list = [0]
    for i in range(0, 21600 + 1):
        time_list.append(
            datetime.datetime(1998, 6, 1, 0) + datetime.timedelta(seconds=i))
    for i in range(1, len(time_list)):
        pos_list.append(i / len(time_list))

    time_list_6 = [
        time_list[i].hour + time_list[i].minute / 60 +
        time_list[i].second / 3600 for i in range(len(time_list))
    ]
    time_list_12 = [i + 6 for i in time_list_6]
    time_list_18 = [i + 6 for i in time_list_12]
    time_list_24 = [i + 6 for i in time_list_18]

    p = subprocess.Popen(
        ["C:\Program Files\Honeyview\Honeyview.exe", pic_paths[pic_num]])

    print('please specify graph area')
    print('leftmost x-axis portion')
    mouse.wait('left')

    pos = pyautogui.position()
    graph_area = [pos.x]

    time.sleep(.5)

    print('rightmost x-axis portion')
    mouse.wait('left')
    pos = pyautogui.position()
    graph_area.append(pos.x)

    time.sleep(.4)

    print('Graph area defined')
    while True:
        #Sheath to Sphere using nums?

        if keyboard.is_pressed('esc'):
            p.kill()
            break

        if keyboard.is_pressed('3'):
            print('Select new graph area')

            print('leftmost x-axis portion')
            mouse.wait('left')
            pos = pyautogui.position()
            graph_area = [pos.x]

            time.sleep(.5)

            print('rightmost x-axis portion')
            mouse.wait('left')
            pos = pyautogui.position()
            graph_area.append(pos.x)
            time.sleep(.1)

            print('Graph area defined')

        if mouse.is_pressed('left'):
            win = pyautogui.getActiveWindow()
            mouse_pos = pyautogui.position()
            graph_len = graph_area[1] - graph_area[0]

            if mouse_pos.x >= graph_area[
                    1] and mouse_pos.x <= win.left + win.width:
                print('Next image')
                pic_num += 1
                p.kill()
                p = subprocess.Popen([
                    "C:\Program Files\Honeyview\Honeyview.exe",
                    pic_paths[pic_num]
                ])
                time.sleep(0.5)

            elif mouse_pos.x >= win.left and mouse_pos.x <= graph_area[0]:
                print('Previous image')
                pic_num -= 1
                p.kill()
                p = subprocess.Popen([
                    "C:\Program Files\Honeyview\Honeyview.exe",
                    pic_paths[pic_num]
                ])
                time.sleep(0.5)

            if mouse_pos.x >= graph_area[0] and mouse_pos.x <= graph_area[1]:
                print(
                    'Would you like to record this point as a crossing? Press 1 for yes and 2 for no'
                )

                while True:
                    if keyboard.is_pressed('1'):
                        record = True
                        print('Yes')
                        break
                    elif keyboard.is_pressed('2'):
                        record = False
                        print('No')
                        break

                if record: pass
                elif not record: continue
                time.sleep(0.6)

                mouse_rel_pos = (mouse_pos.x - graph_area[0]) / graph_len

                date_time_stamp = datetime.datetime.strptime(
                    pic_paths[pic_num]
                    [date_format_index[0]:date_format_index[1]],
                    date_strip_format)
                record_date = date_time_stamp.date()

                closest_pos = min(
                    range(len(pos_list)),
                    key=lambda j: abs(pos_list[j] - mouse_rel_pos))

                if date_time_stamp.hour == 0:
                    graph_time_stamp = time_list_6[closest_pos]
                elif date_time_stamp.hour == 6:
                    graph_time_stamp = time_list_12[closest_pos]
                elif date_time_stamp.hour == 12:
                    graph_time_stamp = time_list_18[closest_pos]
                elif date_time_stamp.hour == 18:
                    graph_time_stamp = time_list_24[closest_pos]

                print(
                    'What type of crossing is this? 1-To sheath 2-To magnetosphere'
                )
                while True:
                    if keyboard.is_pressed('1'):
                        record_type = 'Sheath'
                        break
                    elif keyboard.is_pressed('2'):
                        record_type = 'Magnetosphere'
                        break

                temp_hr = int(graph_time_stamp)
                temp_min = int((graph_time_stamp * 60) % 60)
                temp_sec = int((graph_time_stamp * 3600) % 60)

                record_time = datetime.datetime.strptime(
                    f'{temp_hr}:{temp_min}:{temp_sec}', '%H:%M:%S').time()

                print(
                    f'{record_type} crossing at {record_date} {record_time} recorded.'
                )

                with open('jno_crossings.dat', 'a') as crossing:
                    crossing.writelines(
                        f'\n{record_date},{record_time},{record_type}')
                crossing.close()
                print('Continue analyzing images')
Example #10
0
 def t():
     mouse.wait()
     lock.release()
Example #11
0
    # SetSystemCursor = windll.user32.SetSystemCursor  # reference to function
    # SetSystemCursor.restype = c_int  # return
    # SetSystemCursor.argtype = [c_int, c_int]  # arguments
    # hCursor = win32api.LoadCursor(0, win32con.OCR_APPSTARTING)

    check = True

    while True:
        # Check if alt+t was pressed
        if keyboard.is_pressed('alt+t'):
            print('alt+t Key was pressed')

            # if SetSystemCursor(hCursor, win32con.OCR_CROSS) == 0:
            #     print('Error in setting the cursor')

            mouse.wait()
            x_start = mouse.get_position()[0]
            y_start = mouse.get_position()[1]

            worker = threading.Thread(
                target=draw_rectangle,
                args=(x_start, y_start),
            )
            worker.start()

            time.sleep(1)
            mouse.wait()
            x_end = mouse.get_position()[0]
            y_end = mouse.get_position()[1]

            # if SetSystemCursor(hCursor, win32con.OCR_NORMAL) == 0:
Example #12
0
from PIL import ImageGrab
import requests
import time
import hashlib
import base64
from urllib import parse
import mouse

print('请在图像左上角位置点击鼠标')
mouse.wait(button='left', target_types=('down'))
x = mouse.get_position()
print('采集左上角坐标成功,请在图像右下角位置点击鼠标')
mouse.wait(button='left', target_types=('down'))
y = mouse.get_position()
print(x, y)
print('采集图像位置成功,请在喜欢位置点击鼠标')
mouse.wait(button='left', target_types=('down'))
l = mouse.get_position()
print('采集喜欢位置成功,请在不喜欢位置点击鼠标')
mouse.wait(button='left', target_types=('down'))
b = mouse.get_position()
print('采集不喜欢位置成功,采集结束!')

AppID = '2110221337'
AppKey = 'gz2ngtWEEkrJ8DCL'
ApiUrl = 'https://api.ai.qq.com/fcgi-bin/face/face_detectface'


def getReqSign(params):
    url = ''
    for key in sorted(params.keys()):
Example #13
0
 def mouse_background_thread(self):
     mouse.hook(self.que_mouse_event)
     while self.threads_active is True:
         mouse.wait()
     self.log.warning('mouse event thread exited.')