Пример #1
0
 def focus(self):
     old_coord = mouse.get_position()
     self.current.set_focus()
     mouse.move(*old_coord)
     self.gasp()
Пример #2
0
        translated_text = ""
        try:
            translated_text = translator.translate(scanned_text, lang_src='it', lang_tgt='ru')
        except Exception as e:
            print(e)
        print(scanned_text)
        label.config(text=f"Original: {scanned_text}\nTranslated: {translated_text}")
        root.after(1000, scanImage)

    scanImage()


while True:
    try:
        if keyboard.is_pressed('ctrl+F6'):
            start_point_coordinates = [mouse.get_position()[0], mouse.get_position()[1]]

            while True:
                if mouse.is_pressed():
                    end_point_coordinates = [mouse.get_position()[0], mouse.get_position()[1]]

                    break
                time.sleep(0.002)

            if (end_point_coordinates[0] < start_point_coordinates[0]):
                start_point_coordinates[0], end_point_coordinates[0] = end_point_coordinates[0], \
                                                                       start_point_coordinates[0]
            if (end_point_coordinates[1] < start_point_coordinates[1]):
                start_point_coordinates[1], end_point_coordinates[1] = end_point_coordinates[1], \
                                                                       start_point_coordinates[1]
            root.geometry(f"+{250}+{250}")
Пример #3
0
def x():
    return mouse.get_position()[0]
Пример #4
0
import mouse
import random
import time

print(f"move your mouse into the upper left section of your screen now...")
print(
    f"to stop the program, just move the mouse around a lot, until the program stops."
)
time.sleep(3)
origin = mouse.get_position()
bounds = (500, 500)
print(f"starting at {origin}")
last_y = origin[1]
last_x = origin[0]
while True:
    next_x = random.randint(origin[0], origin[0] + bounds[0])
    next_y = random.randint(origin[1], origin[1] + bounds[1])
    delay = (random.randint(100, 500) + random.randint(0, 500) +
             random.randint(0, 500) + random.randint(0, 500)) / 1000
    print(f"moving to ({next_y}|{next_x})")
    mouse.move(y=next_y, x=next_x, absolute=True, duration=delay)

    loc = mouse.get_position()
    if abs(loc[1] - next_y) > 10 or abs(loc[0] - next_x) > 10:
        print("EXIT BECAUSE MOUSE WAS MOVED")
        exit(1)
    delay = (random.randint(100, 200) + random.randint(0, 100) +
             random.randint(0, 100) + random.randint(0, 100)) / 1000
    time.sleep(delay)
    last_y = next_y
    last_x = next_x
Пример #5
0
     try:
         times = int(times)
     except:
         print('Invalid amount of times. Try again')
     if times > 0:
         done = True
     else:
         print('Invalid amount of times. Try again')
 if mode == 'm':
     print(
         '---------------------------------------------------------------')
     print(
         'MOUSE MODE\nSelect Pos1 (Position of the box.) To select, navigate to the text box, hover over it, and press ALT+S.\n'
     )
     keyboard.wait('ALT+S')
     pos1 = mouse.get_position()
     pos1x = pos1[0]
     pos1y = pos1[1]
     print(
         '---------------------------------------------------------------')
     print(
         'Select Pos2 (Position of the send button.) To select, navigate to the send button, hover over it, and press ALT+S.\n'
     )
     keyboard.wait('ALT+S')
     pos2 = mouse.get_position()
     pos2x = pos2[0]
     pos2y = pos2[1]
     print(
         '---------------------------------------------------------------')
     print('Program in stand-by. Press SPACE to resume.')
     keyboard.wait('space')
def downCallback():
    xValOld, yValOld = mouse.get_position()
    list[0] = xValOld
    list[1] = yValOld
    def event(widget, Mode=False):
        global x, y
        if Mode:
            x = widget.x
            y = widget.y
        root.bind('<B1-Motion>', lambda e: event(e))
        root.geometry(
            '+%d+%d' %
            (mouse.get_position()[0] - x, mouse.get_position()[1] - y))

        ScreenWidth = root.winfo_screenwidth()  # screen width
        ScreenHeight = root.winfo_screenheight()  # screen height

        #print('Screen Width =', ScreenWidth)#################################
        #print('Screen Height =', ScreenHeight)###############################

        WindowWidth = root.winfo_width()  # window width
        WindowHeight = root.winfo_height()  # window height

        #print('Window Width =', WindowWidth)#################################
        #print('Window Height =', WindowHeight)###############################

        WindowX = root.winfo_x()  # window X position
        WindowY = root.winfo_y()  # window Y position

        #print('Window X =', WindowX)#########################################
        #print('Window Y =', WindowY)#########################################

        #while True: print(pyautogui.position())##############################
        mouseX, mouseY = pyautogui.position()
        #print('Mouse X =', mouseX)###########################################
        #print('Mouse Y =', mouseY)###########################################
        # keeps window on screen
        if WindowX <= int(-ScreenWidth + WindowWidth - 1):
            WindowX = int((-1 * ScreenWidth) + WindowWidth)
            root.geometry('%dx%d+%d+%d' %
                          (WindowWidth, WindowHeight, WindowX, WindowY))
            root.bind('<B1-Motion>', lambda e: event(e, Mode=True))
            root.bind('<ButtonRelease-1>', lambda e: standard_bind())

        if WindowY >= int(ScreenHeight - WindowHeight + 1):
            WindowY = int(ScreenHeight - WindowHeight)
            root.geometry('%dx%d+%d+%d' %
                          (WindowWidth, WindowHeight, WindowX, WindowY))
            root.bind('<B1-Motion>', lambda e: event(e, Mode=True))
            root.bind('<ButtonRelease-1>', lambda e: standard_bind())

        if WindowX >= int(ScreenWidth - WindowWidth + 1):
            WindowX = int(ScreenWidth - WindowWidth)
            root.geometry('%dx%d+%d+%d' %
                          (WindowWidth, WindowHeight, WindowX, WindowY))
            root.bind('<B1-Motion>', lambda e: event(e, Mode=True))
            root.bind('<ButtonRelease-1>', lambda e: standard_bind())

        if WindowY <= int(-1):
            WindowY = int(0)
            root.geometry('%dx%d+%d+%d' %
                          (WindowWidth, WindowHeight, WindowX, WindowY))
            root.bind('<B1-Motion>', lambda e: event(e, Mode=True))
            root.bind('<ButtonRelease-1>', lambda e: standard_bind())
            #   keeps mouse on window when dragging window
        if mouseX <= (WindowX):
            WindowX = mouseX - 5
            WindowY = WindowY + 5
            root.geometry('%dx%d+%d+%d' %
                          (WindowWidth, WindowHeight, WindowX, WindowY))
            #print(mouseX)####################################################
        if mouseX >= (WindowX + WindowWidth):
            WindowX = (mouseX - WindowWidth + 5)
            WindowY = WindowY - 5
            root.geometry('%dx%d+%d+%d' %
                          (WindowWidth, WindowHeight, WindowX, WindowY))
            #print(mouseX)####################################################
        if mouseY <= (WindowY):
            WindowY = mouseY - 5
            WindowX = WindowX + 5
            root.geometry('%dx%d+%d+%d' %
                          (WindowWidth, WindowHeight, WindowX, WindowY))
            #print(mouseY)####################################################
        if mouseY >= (WindowY + WindowHeight):
            WindowY = (mouseY - WindowWidth + 5)
            WindowX = WindowX - 5
            root.geometry('%dx%d+%d+%d' %
                          (WindowWidth, WindowHeight, WindowX, WindowY))
Пример #8
0
import mouse
import time
import keyboard

'''
while 1:
    # scroll lock for starting the process
    keyboard.wait(70)
    keyboard.press(29)
    for i in range(12):
        for j in range(5):
            mouse.move(2610 + 70 * i, 820 + 70 * j, absolute=True, duration=0.01)
            time.sleep(0.02)
            mouse.click()
    keyboard.release(29)
'''

while 1:
    time.sleep(0.5)
    print(mouse.get_position())
Пример #9
0
            'record = 0(note: press esc to stop the recording) run = 1 exit = 2 '
        ))
    if FI == '0':
        runCoordinates = True
        try:
            if not (os.path.isdir("macro folder")):
                os.makedirs(os.path.join('macroFolder'))
        except:
            pass
        path = './macroFolder'
        file = open(
            './macroFolder/macrofile_' + str(len(listdir(path))) + '.txt', "w")
        while runCoordinates:

            if mouse.is_pressed('right') == True:
                file.write(str(mouse.get_position()))
                file.write('PR' + '\n')
            elif mouse.is_pressed('left') == True:
                file.write(str(mouse.get_position()))
                file.write('PL' + '\n')
            else:
                file.write(str(mouse.get_position()) + '\n')
            time.sleep(0.1)
            if keyboard.is_pressed('Esc'):
                file.close()
                runCoordinates = False
    elif FI == '1':
        print(listdir('./macroFolder'))
        inp = int(input('for which macrofile would you like to play? '))
        File = open('./macroFolder/' + listdir('./macroFolder')[inp], 'r')
        LoCoor = File.read().split('\n')
Пример #10
0
 def position(self):
     return mouse.get_position()
Пример #11
0
 def getPos(self):
     """ Gets ``Location`` of cursor """
     from .Geometry import Location
     return Location(*mouse.get_position())
Пример #12
0
 def SubProcedure_MouseMoveDiff(self, data):
     pos = mouse.get_position()
     mouse.move(pos[0] + int(data[0]), pos[1] + int(data[1]))
     if len(data) > 2:
         time.sleep(float(data[2]) / 1000)
     return 1
Пример #13
0
        sleep(5)
        keyboard.send('enter')
        sleep(5)
    confirm = 'n'
    while confirm == 'n':
        print("Record 'Launch Meeting' button")
        confirm = input('Are you ready?\n(y/n)> ').lower()
        if confirm == 'y':
            print("Hover your cursor on 'Launch Meeting' button")
            n = 5
            while n >= 0:
                print(f'Recording in {n} seconds...')
                n -= 1
                sleep(1)
            CONFIG_DATA['zoom_launch_button_x'], CONFIG_DATA[
                'zoom_launch_button_y'] = mouse.get_position()
            print(
                f"({CONFIG_DATA['zoom_launch_button_x']}, {CONFIG_DATA['zoom_launch_button_y']})"
            )
            confirm = input('Is this correct?\n(y/n)> ').lower()
            if confirm == 'y':
                break
        elif confirm == 'n':
            continue
        else:
            error('Input must be y or n!')
            confirm = 'n'

    print()

    if CONFIG_DATA['browser'] == 'firefox':
Пример #14
0
def move(dx, dy):
    x, y = mouse.get_position()
    x += dx
    y += dy
    mouse.move(x, y)
Пример #15
0
 def test_position(self):
     self.assertEqual(mouse.get_position(), mouse._os_mouse.get_position())
Пример #16
0
from tkinter import *
from tkinter.ttk import *
from time import *
from datetime import *
from PIL import Image, ImageTk
import keyboard
import mouse
import ctypes

last_input = datetime.now()
lastPosition = mouse.get_position()


class GUI:
    def __init__(self):
        #check if more than one monitor
        user32 = ctypes.windll.user32
        width1 = user32.GetSystemMetrics(0)
        height1 = user32.GetSystemMetrics(1)
        width2 = user32.GetSystemMetrics(78)
        height2 = user32.GetSystemMetrics(79)

        gui = Tk()
        gui.geometry("600x400")  #'%sx%s+%s+%s'%(width1,height1,-width1,0))

        #GUI enteries
        canvasG = Canvas(gui, width=600, height=400)
        canvasG.pack(fill="both", expand=True)

        #Enable picture
        enableP = IntVar()
Пример #17
0
  def _get_mouse_position_on_click(self, ui_field):
    position_x, position_y = mouse.get_position()
    self.window.Element(ui_field).Update(str(position_x) + ',' + str(position_y))

    mouse.unhook_all()
Пример #18
0
    def moveArcToPosition(self):
        xc, yc = mouse.get_position()

        self.position['axc'] = xc
        self.position['ayc'] = yc
Пример #19
0
def configuration():
    mouse.move(0, 0, duration=0.2)
    return str(mouse.get_position())
Пример #20
0
def GetMousePosition():
    import mouse
    pos = mouse.get_position()
    return (pos)
Пример #21
0
import keyboard as key
import mouse as ms
import time

for i in range(100):
    print(ms.get_position())
    print("\n")
    time.sleep(0.1)
Пример #22
0
def click_and_return(pos):
    original_pos = mouse.get_position()
    mouse.move(*pos)
    mouse.click()
    mouse.move(*original_pos)
Пример #23
0
sr.timeout = 10  #specify timeout when using readline()
sr.open()
# py.moveTo(0, 756,duration=0.3886999)
while (True):

    try:
        if sr.is_open == True:
            a = sr.readline()
            a = ((a.decode()).strip()).split(',')
            data = np.array([])
            x = int(a[0]) - 521
            y = int(a[1]) - 526
            s = int(a[2])
            # if x==521 & y==526:
            #     mouse.move(0,0,absolute=True,duration=0.3887)
            #     exit
            print(x, y)
            cur_pos = mouse.get_position()
            new_x = cur_pos[0]
            new_y = cur_pos[1]
            x_new = x
            y_new = y
            print(x_new, y_new)
            py.moveRel(x_new, y_new, duration=0.25)
            if s == 0:
                py.click(x_new, y_new, button='Right')
            # events = mouse.record()
            # print(events)
    except KeyboardInterrupt:
        sr.close()
        sys.exit()
Пример #24
0
def mouse_coord_callback():
    coord_string = 'Mouse coordinates: ' + str(mouse.get_position())
    util.log(coord_string)
    return coord_string
Пример #25
0
 def register_position():
     while True:
         pos = get_position()
         queue.put(MoveCommand(pos, pos))
Пример #26
0
import mouse, sys
import time
import serial

mouse.FAILSAFE = False
ArduinoSerial = serial.Serial('com4', 9600)  #Specify the correct COM port
time.sleep(1)  #delay of 1 second

while 1:
    data = str(ArduinoSerial.readline().decode('ascii'))  #read the data
    (x, y, z) = data.split(":")  # assigns to x,y and z
    (X, Y) = mouse.get_position()  #read the cursor's current position
    (x, y) = (int(x), int(y))  #convert to int
    mouse.move(X + x, Y - y)  #move cursor to desired position
    if '1' in z:  # read the Status of the left click button
        mouse.click(
            button="left")  # clicks left button if the button was pressed
Пример #27
0
def y():
    return mouse.get_position()[1]
Пример #28
0
async def bounds(ctx):
    coords = m.get_position()
    m.move(1000000, 1000000)
    await ctx.send("The screen boundries are: 0,0 x " + str(m.get_position()[0]) + "," + str(m.get_position()[1]))
    m.move(coords[0], coords[1])
Пример #29
0
# teach_movements

print("El bot esta aprendiendo")

is_pressing = False
duration_click = 0
time_to_click = time()

while True:
    if keyboard.is_pressed('ESCAPE'):
        break
    if mouse.is_pressed():
        if not is_pressing:
            is_pressing = True
            clicks_down.append([mouse.get_position(), time() - time_to_click])
            duration_click = time()
    else:
        if is_pressing:
            is_pressing = False
            clicks_up.append([mouse.get_position(), time() - duration_click])
            time_to_click = time()

while keyboard.is_pressed('ESCAPE'):
    pass

# repeat_movements

print("El bot ha iniciara!")

finish = False
Пример #30
0
def get_cords():  #Gets the coordinates, used for debugging
    x, y = mouse.get_position()
    x = x - x_pad
    y = y - y_pad
    print(x, y)
    return (x, y)
Пример #31
0
port = "COM14"

ard = 0

try:
    ard = serial.Serial(port, 9600)
except Exception:
    ard = serial.Serial("COM3", 9600)

while (1):
    a = ard.readline().decode()

    cur = a.split("\t")
    cur[0] = int(cur[0])
    cur[1] = int(cur[1])
    cur[2] = int(cur[2][:-2])

    k = mouse.get_position()

    mouse.move(k[0] - cur[0] / 100, k[1] - cur[1] / 100)

    if (cur[2] == 2):
        mouse.click(button='left')
    elif (cur[2] == 1):
        mouse.click(button='right')
    #elif(cur[2]==3):
    #	mouse.double_click()
    #print(mouse.get_position())

    sleep(0.001)
Пример #32
0
import keyboard
import mouse
import enum
from playsound import playsound
import time


class StrafeDir(enum.Enum):
    left = 1
    right = 2
    NA = 3


previous_pos = mouse.get_position()
strafe_dir = StrafeDir.NA
a_pushed = False
d_pushed = False

negative_sync_adj = 2
positive_sync_adj = 1
current_sync_score = 0
previous_sync_score = 0
bad_sync_threshold = 250
test_interval = .1
start_time = time.time()

while True:

    current_pos = mouse.get_position()
    counter_strafe = False
    good_strafe = False