Beispiel #1
0
def mouse_return_accuracy():
    # when the mouse is moved relative, and then reversed relative again, confirm
    # that the cursor returns to the same position
    pydirectinput.moveTo(300, 300)
    time.sleep(1)
    pydirectinput.move(100, 0)
    time.sleep(1)
    pydirectinput.move(-100, 0)
Beispiel #2
0
def Shoot(mid_x, mid_y):
    x = int(mid_x * width)
    #y = int(mid_y*height)
    y = int(mid_y * height + height / 9)
    print(x, y)
    print(pydirectinput.position())
    pydirectinput.move(x - 428, y - 267)

    pydirectinput.click()
Beispiel #3
0
def wasd_movement():
    pydirectinput.keyDown('w')
    time.sleep(1)
    pydirectinput.keyUp('w')
    time.sleep(1)
    pydirectinput.keyDown('d')
    time.sleep(0.25)
    pydirectinput.keyUp('d')
    time.sleep(1)
    pydirectinput.move(300, None)
Beispiel #4
0
def yawPitchLoop(interval, invert):
    global XMOVE
    global YMOVE
    if invert:
        yMul = -1
    else:
        yMul = 1
    while True:
        if XMOVE != 0 or YMOVE != 0:
            pydirectinput.move(XMOVE, YMOVE * yMul)
        time.sleep(interval)
Beispiel #5
0
async def on_message(message):
    if str(message.channel) == 'pc-control':
        message.content = message.content.lower()

        if message.content in KEYS:
            control.keyDown(message.content)
            sleep(0.4)
            control.keyUp(message.content)

        else:
            if message.content == 'mup':
                control.move(0, -200)
            if message.content == 'mdown':
                control.move(0, 200)
            if message.content == 'mleft':
                control.move(-200, 0)
            if message.content == 'mright':
                control.move(200, 0)
            if message.content == 'm1':
                control.click(button='left')
            if message.content == 'm2':
                control.click(button='right')
            if message.content.startswith('say'):
                keyboard.type(message.content[4:])

        await message.delete()
def execute_clicks(matrix, targets, offset_matrix_x, offset_matrix_y):
    pydirectinput.move(-10000, -10000, relative=True)
    last_position = [0, 0]
    for target in targets:
        matrix_target = matrix[target[1]][target[0]]

        # We get the target coordinates in the space of the cut sub-image and need to calculate screen coordinates
        position_x = round(matrix_target.position[0] + offset_matrix_x)
        position_y = round(matrix_target.position[1] + offset_matrix_y)

        # Calculate the difference to the last position since we can't use absolute coordinates
        relative_x = position_x - last_position[0]
        relative_y = position_y - last_position[1]
        pydirectinput.moveRel(relative_x, relative_y, relative=True)
        pydirectinput.click()
        last_position = [position_x, position_y]
Beispiel #7
0
    def run(self):
        while True:
            
            

            pydirectinput.move(1,1)
            pydirectinput.click(self.x,self.y)
            time.sleep(0.2)
            for move in range(642):
                pydirectinput.move(1,0)
                
                #For harvesting
                pydirectinput.keyDown("f")
            pydirectinput.keyUp("f")
            
            for move in range(316):
                pydirectinput.move(-2,0)
                pydirectinput.mouseDown()
                pass
            pydirectinput.mouseUp()

            pydirectinput.keyDown("s")
            time.sleep(0.1)
            pydirectinput.keyUp("s")
            time.sleep(0.5)
            print("Complete")
            pass
Beispiel #8
0
        demo_playback_name_location = pyautogui.locateOnScreen(
            str(demo_playback_name_path), confidence=0.9)
    except pyautogui.ImageNotFoundException:
        print("couldn't find demo playback name")
        quit(1)
    if demo_playback_name_location is None:
        print("couldn't find demo playback name")
        quit(1)
    pydirectinput.moveTo(
        demo_playback_name_location.left + demo_playback_name_location.width +
        100,
        int(demo_playback_name_location.top +
            demo_playback_name_location.height / 2))
    pydirectinput.mouseDown(button='left')
    time.sleep(1.0)
    pydirectinput.move(-215, -324)
    pydirectinput.mouseUp(button='left')

    # start playback and recording
    pydirectinput.moveTo(
        int(console_text_entry_location.left +
            console_text_entry_location.width / 3),
        int(console_text_entry_location.top +
            console_text_entry_location.height / 2))
    pydirectinput.click()
    #pyautogui.write('mirv_streams previewEnd\n')
    #time.sleep(0.5)
    pyautogui.write('demo_resume\n')
    pydirectinput.moveTo(30, 30)
    pydirectinput.press('`')
    pydirectinput.press('F1')
        nothing()
        continue
    else:
        try:
            for message in new_messages:
                msg = message['message'].lower()
                msg_preserve_caps = message['message']
                username = message['username'].lower()
                usr = username.decode()

            def obs():
                print(msg_preserve_caps + ' (' + usr + ')')

            if msg in ['left', 'l']:
                obs()
                pydirectinput.move(-100, 0)
            if msg in ['light left', 'light l']:
                obs()
                pydirectinput.move(-25, 0)
            if msg in ['right', 'r']:
                obs()
                pydirectinput.move(100, 0)
            if msg in ['light right', 'light r']:
                obs()
                pydirectinput.move(25, 0)
            if msg in ['up', 'u']:
                obs()
                pydirectinput.move(0, -100)
            if msg in ['light up', 'light u']:
                obs()
                pydirectinput.move(0, -25)
Beispiel #10
0
 def moveMouseRelative_software(self, x: int, y: int):
     pydirectinput.move(x, y)
     sleep(2)
Beispiel #11
0
def set_pos(x, y):
    pydirectinput.move(x, y)
Beispiel #12
0
 def check_status(self):
     self.statusThread = threading.Timer(0.2, self.check_status)
     self.statusThread.start()
     for key in self.currentDetectors:
         if isinstance(key, extremity_trigger.ExtremityTrigger):
             eventType = self.currentDetectors.get(key)[1]
             eventContent = self.currentDetectors.get(key)[2]
             if key.status == 1:
                 self.records[1][key.triggerName] = (
                     key.pos, self.records[1][key.triggerName][1] + 0.2)
                 if eventType == "keypress":
                     pydirectinput.keyDown(eventContent)
                     key.isPressed = True
                 elif eventType == "mouse":
                     if eventContent == "click":
                         pydirectinput.click()
                     elif eventContent == "move-left":
                         pydirectinput.move(-1, None)
                     elif eventContent == "move-right":
                         pydirectinput.move(1, None)
                     elif eventContent == "move-up":
                         pydirectinput.move(None, -1)
                     elif eventContent == "move-down":
                         pydirectinput.move(None, 1)
                 elif eventType == "brightness":
                     sbc.set_brightness(100)
             elif key.status == 0 and key.isPressed == True:
                 if eventType == "keypress":
                     pydirectinput.keyUp(eventContent)
                     key.isPressed = False
             else:
                 if eventType == "brightness":
                     sbc.set_brightness(-25)
         else:
             eventType = self.currentDetectors.get(key)[0]
             eventContent = self.currentDetectors.get(key)[1]
             if key.status == 1 and self.isMoving:
                 self.records[0][
                     key.motionType] = self.records[0][key.motionType] + 0.2
                 if eventType == "keypress":
                     pydirectinput.keyDown(eventContent)
                     key.isPressed = True
                     # self.t0 = round(time()*1000)
                     # self.testingLog.write("KeyPressed:"+str(self.t0) + "\n")
                 elif eventType == "mouse":
                     if eventContent == "click":
                         pydirectinput.click()
                     elif eventContent == "move-left":
                         pydirectinput.move(-1, None)
                     elif eventContent == "move-right":
                         pydirectinput.move(1, None)
                     elif eventContent == "move-up":
                         pydirectinput.move(None, -1)
                     elif eventContent == "move-down":
                         pydirectinput.move(None, 1)
                 elif eventType == "brightness":
                     sbc.set_brightness(100)
             elif (not self.isMoving
                   or key.status == 0) and key.isPressed == True:
                 # self.t0=round(time()*1000)
                 # self.testingLog.write("KeyReleased:" + str(self.t0) + "\n")
                 if eventType == "keypress":
                     pydirectinput.keyUp(eventContent)
                     key.isPressed = False
             else:
                 if eventType == "brightness":
                     sbc.set_brightness(-25)