def runLoop0(): from pynput.mouse import Button, Controller mouse = Controller() mousex = 0.00 mousey = 0.00 print('runloop0 started') while True: line = s.readline() #print(line) line2 = str(line) line3 = line2[:-5] line4 = line3.replace("b' ", "") #print(line4) if ('mouseclick' in line4): mouse.click(Button.left, 1) #!! if ('mousepress' in line4): mouse.press(Button.left) if ('mouserelease' in line4): mouse.release(Button.left) if ('rollmap' in line4): line5 = line4.replace("rollmap", "") line6 = line5.replace(" ", "") print(line6) if (float(line6) > 10): mousex = float(line6) / 4 elif (float(line6) < -10): mousex = float(line6) / 4 else: mousex = 0 if ('pitchmap' in line4): line5 = line4.replace("pitchmap", "") line6 = line5.replace(" ", "") print(line6) if (float(line6) > 10): mousey = float(line6) / 4 elif (float(line6) < -10): mousey = float(line6) / 4 else: mousey = 0 if ('lightvaldown' in line4): mouse.click(Button.right, 1) mouse.move(mousex, mousey)
class MouseController(): def __init__(self): pass self.mouse = Controller() def mouse_position(self): # Read pointer position print('The current pointer position is {0}'.format( self.mouse.position)) return self.mouse.position def mouse_postiion_set(self, x, y): # Set pointer position self.mouse.position = (x, y) print('Now we have moved it to {0}'.format(self.mouse.position)) def mouse_move(self, x, y): # Move pointer relative to current position self.mouse.move(x, y) def mouse_press(self, right=False): if right == True: self.mouse.press(Button.right) else: self.mouse.press(Button.left) def mouse_release(self, right=False): if right == True: self.mouse.release(Button.right) else: self.mouse.release(Button.left) def mouse_double_click(self, right=False): # Double click; this is different from pressing and releasing # twice on Mac OSX if right == 'right' or right == True: self.mouse.click(Button.right, 2) else: self.mouse.click(Button.right, 2) def mouse_scroll(self, x, y): # Scroll two steps down self.mouse.scroll(x, y)
def shubiao(jian): from pynput.mouse import Controller, Button mouse = Controller() #设置鼠标键 global kaiguan if kaiguan == 1: if jian in '7': print(jian) mouse.move(-20, -25) elif jian in '8': mouse.move(0, -20) elif jian in '9': mouse.move(20, -25) elif jian in '4': mouse.move(-20, 0) elif jian in '5': mouse.click(Button.left, 1) #左键在单击 elif jian in '6': mouse.move(30, 0) elif jian in '1': mouse.move(-30, 35) elif jian in '2': mouse.move(0, 15) elif jian in '3': mouse.move(30, 20) elif jian in '-': mouse.click(Button.right, 1) #左键双击 elif jian in '+': mouse.click(Button.left, 1) #右键单击 elif jian in '/': mouse.scroll(0, 20) #滚轮向下移动一个单位 elif jian in '*': mouse.scroll(0, -30) #轮向上移动一个单位 elif jian in '0' or jian in '.': mouse.click(Button.left) #左键在按住 else: kaiguan = 0
# f = open('demo.txt', 'a') # for item in abc.index: # print(abc[0][item]) # # f.write(abc[0][item] + ' --->>> ') # f.write('\n') url = 'instagram.com' wb.get().open_new_tab('https://instagram.com') from pynput.mouse import Button, Controller mouse = Controller() mouse.position = (1230, 40) time.sleep(5) mouse.click(Button.left, 1) mouse.position = (1170, 360) time.sleep(5) mouse.click(Button.left, 3) time.sleep(1) keyBoardCopy() altTab() # value = input('Enter value') # keyBoardPaste() # print(value)