Example #1
0
    def expose(self,widget,event):
        cr = widget.window.cairo_create()
        cr.set_operator(cairo.OPERATOR_CLEAR)
        # Makes the mask fill the entire window
        cr.rectangle(0.0, 0.0, pyautogui.size()[0],pyautogui.size()[1])
        # Deletes everything in the window (since the compositing operator is clear and mask fills the entire window
        cr.fill()

        cr.set_operator(cairo.OPERATOR_OVER)

        cr.set_source_rgb(1,1,1)
        cr.set_line_width(5)
        if self.droites!=None:
            for droite in self.droites:
                angle = droite[0]*math.pi/180
                x2=droite[1]
                y2=droite[2]
                if x2!=0:
                    y= math.tan(angle)*(0-x2)+y2
                    cr.move_to(0,y)
                    cr.line_to(x2,y2)
                    cr.stroke()
                else:
                    y= math.tan(angle)*(pyautogui.size()[0]-x2)+y2
                    cr.move_to(pyautogui.size()[0],y)
                    cr.line_to(x2,y2)
                    cr.stroke()

        if self.position!=None:
            cr.set_source_rgb(0,0,1)
            cr.arc(self.position[0], self.position[1],
                   15,0,math.pi*2)
            cr.fill()
Example #2
0
 def __init__(self):
     self.lock=RLock()
     self.droites=[]
     self.win = gtk.Window()
     self.win.fullscreen()
     self.win.set_app_paintable(True)
     self.drawing_area = gtk.DrawingArea()
     vbox=gtk.VBox()
     self.win.add(vbox)
     vbox.add(self.drawing_area)
     btn=gtk.Button("quit")
     erase=gtk.Button("erase")
     hbox=gtk.HBox()
     hbox.show()
     vbox.add(hbox)
     vbox.show()
     hbox.add(btn)
     hbox.add(erase)
     btn.show()
     erase.show()
     self.drawing_area.set_size_request(pyautogui.size()[0],pyautogui.size()[1]-50)
     self.drawing_area.connect("expose-event", self.expose)
     self.drawing_area.show()
     self.win.show()
     btn.connect("clicked",self.quit)
     erase.connect("clicked",self.erase)
Example #3
0
 def on_frame(self, controller):
     frame = controller.frame()
     finger = frame.fingers.frontmost
     stabilizedPosition = finger.stabilized_tip_position
     interactionBox = frame.interaction_box
     normalizedPosition = interactionBox.normalize_point(stabilizedPosition)
     if finger.type() == 1:
         pyautogui.moveTo(normalizedPosition.x * pyautogui.size()[0], pyautogui.size()[1] - normalizedPosition.y * pyautogui.size()[1], 0)
         for gesture in frame.gestures():
             if gesture.type is lib.Leap.Gesture.TYPE_SCREEN_TAP:
                 screen_tap = LlibLeap.ScreenTapGesture(gesture)
                 print screen_tap
Example #4
0
    def __init__(self):
        self.position=None
        self.droites=None
        self.win = gtk.Window()
        self.win.fullscreen()
        self.win.set_app_paintable(True)
        self.drawing_area = gtk.DrawingArea()
        self.drawing_area.set_size_request(pyautogui.size()[0],pyautogui.size()[1])
        self.win.add(self.drawing_area)

        self.drawing_area.connect("expose-event", self.expose)
        self.drawing_area.show()
        self.win.show()
Example #5
0
	def onClick(self, mouse_button):
		if mouse_button == 4: #scroll up
			prev = pyautogui.position()
			pyautogui.moveTo(0, pyautogui.size()[1], pause=False)
			pyautogui.scroll(1)
			pyautogui.moveTo(*prev, pause=False)
		elif mouse_button == 5: #scroll dn
			prev = pyautogui.position()
			pyautogui.moveTo(0, pyautogui.size()[1], pause=False)
			pyautogui.scroll(-1)
			pyautogui.moveTo(*prev, pause=False)
		else: #do nothing
			pass
Example #6
0
 def crop(x, y):
     w, h = pyautogui.size()
     x = max(x, 0)
     x = min(x, w-1)
     y = max(y, 0)
     y = min(y, h-1)
     return (x, y)
    def test_size(self):
        width, height = pyautogui.size()

        self.assertTrue(isinstance(width, int), 'Type of width is %s' % (type(width)))
        self.assertTrue(isinstance(height, int), 'Type of height is %s' % (type(height)))
        self.assertTrue(width > 0, 'Width is set to %s' % (width))
        self.assertTrue(height > 0, 'Height is set to %s' % (height))
    def test_onScreen(self):
        width, height = pyautogui.size()
        halfWidth = int(width / 2)
        halfHeight = int(height / 2)

        self.assertTrue(pyautogui.onScreen(0, 0))
        self.assertTrue(pyautogui.onScreen([0, 0]))

        self.assertTrue(pyautogui.onScreen(halfWidth, 0))
        self.assertTrue(pyautogui.onScreen([halfWidth, 0]))
        self.assertTrue(pyautogui.onScreen(0, halfHeight))
        self.assertTrue(pyautogui.onScreen([0, halfHeight]))
        self.assertTrue(pyautogui.onScreen(halfWidth, halfHeight))
        self.assertTrue(pyautogui.onScreen([halfWidth, halfHeight]))

        self.assertFalse(pyautogui.onScreen(-1, 0))
        self.assertFalse(pyautogui.onScreen([-1, 0]))
        self.assertFalse(pyautogui.onScreen(-1, -1))
        self.assertFalse(pyautogui.onScreen([-1, -1]))
        self.assertFalse(pyautogui.onScreen(0, -1))
        self.assertFalse(pyautogui.onScreen([0, -1]))

        self.assertFalse(pyautogui.onScreen(width, 0))
        self.assertFalse(pyautogui.onScreen([width, 0]))
        self.assertFalse(pyautogui.onScreen(0, height))
        self.assertFalse(pyautogui.onScreen([0, height]))
        self.assertFalse(pyautogui.onScreen(width, height))
        self.assertFalse(pyautogui.onScreen([width, height]))
Example #9
0
    def setUp(self):
        self.oldFailsafeSetting = pyautogui.FAILSAFE
        self.center = P(*pyautogui.size()) // 2

        pyautogui.FAILSAFE = False
        pyautogui.moveTo(*self.center) # make sure failsafe isn't triggered during this test
        pyautogui.FAILSAFE = True
Example #10
0
 def mover(self):
     self.screenSize = pyautogui.size()
     self.screenSize = list(self.screenSize)
     #print self.screenSize
     #self.move(10,10)
     tamano = self.geometry()
     #print tamano
     self.move(10, self.screenSize[1] - 275)
Example #11
0
def move_mouse(how_long_in_seconds):
    start_time = time.time()
    time_elapsed = time.time() - start_time
    xsize, ysize = pyautogui.size()
    
    while time_elapsed < how_long_in_seconds:
        x, y = random.randrange(xsize), random.randrange(ysize)
        pyautogui.moveTo(x, y, duration=0.2)
        time_elapsed = time.time() - start_time
def basic_api():

    cur_x, cur_y = pag.position()
    print(cur_x, cur_y)

    x, y = pag.size()
    print(x, y)

    '''
def move_the_mouse():
    """Function moves the cursor in the upper right corner and then 100 px
    to the right side"""
    # Get the screen size
    screen_width, screen_height = pyautogui.size()
    # Move the mouse in a rectange shape
    pyautogui.moveTo(60, 60, duration=0.50)
    pyautogui.moveTo(screen_width - 60, 60, duration=0.50)
    pyautogui.moveTo(screen_width - 60, screen_height - 60, duration=0.50)
    pyautogui.moveTo(60, screen_height - 60, duration=0.50)
Example #14
0
    def expose(self,widget,event):
        cr = widget.window.cairo_create()
        cr.set_operator(cairo.OPERATOR_CLEAR)
        # Makes the mask fill the entire window
        cr.rectangle(0.0, 0.0, pyautogui.size()[0],pyautogui.size()[1])
        # Deletes everything in the window (since the compositing operator is clear and mask fills the entire window
        cr.fill()

        cr.set_operator(cairo.OPERATOR_OVER)

        cr.set_source_rgb(1,1,1)
        cr.set_line_width(1)
        with self.lock:
            if self.droites!=None:
                for droite in self.droites:
                    if len(droite)!=0:
                        cr.move_to(droite[0][0],droite[0][1])
                        for pos in droite:
                            cr.line_to(pos[0],pos[1])
                        cr.stroke()
Example #15
0
 def go_standby(self):
   self.tv_shutdown = (Main.WAIT_TIME) #reset timer
   screensize = pyautogui.size()
   pyautogui.moveTo(screensize[0]-8, 8)
   time.sleep(1)
   pyautogui.click()
   time.sleep(1)
   pyautogui.moveRel(0, 215)
   time.sleep(1)
   pyautogui.click()
   time.sleep(10)
Example #16
0
def clickCenter (**options):

    displayMagnification = 2 if sysvar_ratina == True else 1

    if sysvar_right == 0:
        width, hegith = pyautogui.size()
        print(width, hegith)
        pyautogui.moveTo(width/2, hegith/2, 2)        
    else:
        pyautogui.moveTo((sysvar_top/displayMagnification) + ((sysvar_right-sysvar_left)/(displayMagnification*2)),
                         (sysvar_left/displayMagnification) + ((sysvar_bottom-sysvar_top)/(displayMagnification*2)),
                         2)
    pyautogui.click()
    pyautogui.moveTo(10, 10) # 10, 10 for avoid fail-safe
Example #17
0
def getCoordinatesForMSComponents():
    width, height = pyautogui.size()
    log("Screen size: %s x %s" %(width, height))

    # To get coordinate on the screen, presse Command+Shitft+4; press Esp button to
    # get out of this mode (Mac)
    coordinates = {
        'symbolEntry':        { 'x':  70, 'y': platform.offsetY + 78 }, 
        'daily':              { 'x': 220, 'y': platform.offsetY + 78 },
        'weekly':             { 'x': 290, 'y': platform.offsetY + 78 },
        'monthly':            { 'x': 360, 'y': platform.offsetY + 78 },
        'printButton':        { 'x': width - 107, 'y': platform.offsetY + 106 }   
    }
    return coordinates
Example #18
0
    def __init__(self):
        self.osName = platform.system()
        self.pcName = os.environ['computername']
        self.screenSize = pyautogui.size()
        print "Operation system is: ", self.osName
        print "PC name is: ", self.pcName

        self.mouseMap = ['left', 'middle', 'right']

        self.controller = pyautogui
        self.pyMouse = PyMouse()
        self.pyKeyboard = PyKeyboard()
        self.keyboardMap = {}
        self.initKeyboardMap()
def example():
    screenWidth, screenHeight = pag.size()
    currentMouseX, currentMouseY = pag.position()
    pag.moveTo(500, 550)
    pag.click()
    pag.moveRel(None, 10)  # move mouse 10 pixels down
    pag.doubleClick()
    # pag.moveTo(500, 500, duration=2, tween=pyautogui.tweens.easeInOutQuad)  # use tweening/easing function to move mouse over 2 seconds.
    pag.typewrite('Hello world!', interval=0.25)  # type with quarter-second pause in between each key
    pag.press('esc')
    pag.keyDown('shift')
    pag.press(['left', 'left', 'left', 'left', 'left', 'left'])
    pag.keyUp('shift')
    pag.hotkey('ctrl', 'c')
    delta_y = 50
def screenSetup():
    width, height = pyautogui.size() #get the width and height of the screen
    print(width)
    print(height)
    
    global qWidth
    global tHeight
    global q3Width
    qWidth = width/4
    q3Width = width/3
    tHeight = height/3
    
    dotSize = 26
    x1 = (numpy.mean([0, qWidth]) - (dotSize/2))
    y1 = (numpy.mean([0,tHeight]) - (dotSize/2))
    x2 = x1 + qWidth
    x3 = x2 + (qWidth/2)
    x4 = x2 + qWidth
    x5 = x4 + qWidth
    
    y2 = y1 + tHeight
    y3 = y2 +tHeight
    
    canvasFrame = Frame(root, bg = "red", width = width, height = (height - 100))
    instructionFrame = Frame(root, width = width, bg = "red", height = 50)
    canvas = Canvas(canvasFrame, width = width, height = (height - 100))
    canvas.create_oval(x1, y1, (x1 + dotSize), (y1 + dotSize), outline = "gray", fill = "gray") #top left
    canvas.create_oval(x3, y1, (x3 + dotSize), (y1 + dotSize), outline = "gray", fill = "gray") #top middle
    canvas.create_oval(x5, y1, (x5 + dotSize), (y1 + dotSize), outline = "gray", fill = "gray") #top right
    
    canvas.create_oval(x1, y2, (x1 + dotSize), (y2 + dotSize), outline = "gray", fill = "gray") #middle left
    canvas.create_oval(x2, y2, (x2 + dotSize), (y2 + dotSize), outline = "gray", fill = "gray") #middle second left
    canvas.create_oval(x4, y2, (x4 + dotSize), (y2 + dotSize), outline = "gray", fill = "gray") #middle third left
    canvas.create_oval(x5, y2, (x5 + dotSize), (y2 + dotSize), outline = "gray", fill = "gray") #middle right

    canvas.create_oval(x1, y3, (x1 + dotSize), (y3 + dotSize), outline = "gray", fill = "gray") #bottom left
    canvas.create_oval(x3, y3, (x3 + dotSize), (y3 + dotSize), outline = "gray", fill = "gray") #bottom middle
    canvas.create_oval(x5, y3, (x5 + dotSize), (y3 + dotSize), outline = "gray", fill = "gray") #botton right

    submitButton = Button(instructionFrame, text = "Submit", command = moveMouse)

    canvasFrame.grid()
    canvas.grid(sticky = W)
    instructionFrame.grid(row = 1)
    submitButton.grid()
Example #21
0
def initialize():
    # Initialize notifications
    notify2.init(app_name)
    #notify2.Notification(app_name, 'Initializing...').show()

    # Initialize GUI
    pyautogui.PAUSE = 1
    pyautogui.FAILSAFE = True

    # Screen size
    # (0,0) ---> X ++
    # |
    # |
    # v
    # Y ++
    global screenWidth, screenHeight
    screenWidth, screenHeight = pyautogui.size()
    print("Resolution: " + str(screenWidth) + "x" + str(screenHeight))
def move ():
    deadzone_x = 200
    deadzone_y = 200
    key_delay = 0.4
    
    screensize_x, screensize_y = pyautogui.size()
    print(screensize_x, screensize_y)
    
    PORT = "/dev/ttyACM1"
    #~ PORT = "/dev/serial/by-id/usb-MBED_MBED_CMSIS-DAP_9900023431864e45001210060000003700000000cc4d28bd-if01"
    BAUD = 115200
    
    s = serial.Serial(PORT)
    s.baudrate = BAUD
    s.parity = serial.PARITY_NONE
    s.databits = serial.EIGHTBITS
    s.stopbits = serial.STOPBITS_ONE
    
    while True:
        data = s.readline().decode('UTF-8')
        data_list = data.rstrip().split(' ')
        try:
            x, y, z, a, b = data_list
            
            #~ if (abs(int(x)) > deadzone_x) and (abs(int(y)) > deadzone_y):
            
            x_mapped = arduino_map(int(x), -1024, 1024, -960, 960)
            y_mapped = arduino_map(int(y), -1024, 1024, -540, 540)
        
            x_centre = screensize_x / 2
            y_centre = screensize_y / 2
        
            #~ print(x_mapped, y_mapped)
            #~ pyautogui.moveTo(x_centre + x_mapped, y_centre + y_mapped)
            pyautogui.moveTo(0, 0)
        
            
        except:
            pass
        
    s.close()
Example #23
0
    def test_onScreen(self):
        zero = P(0, 0)
        xone = P(1, 0)
        yone = P(0, 1)
        size = P(*pyautogui.size())
        half = size / 2

        on_screen = [
            zero,
            zero + xone,
            zero + yone,
            zero + xone + yone,
            half,
            size - xone - yone,
        ]
        off_screen = [
            zero - xone,
            zero - yone,
            zero - xone - yone,
            size - xone,
            size - yone,
            size,
        ]

        for value, coords in [(True, on_screen), (False, off_screen)]:
            for coord in coords:
                self.assertEqual(value, pyautogui.onScreen(*coord), 'onScreen({0}, {1}) should be {2}'.format(coord.x, coord.y, value))
                self.assertEqual(value, pyautogui.onScreen(list(coord)), 'onScreen([{0}, {1}]) should be {2}'.format(coord.x, coord.y, value))
                self.assertEqual(value, pyautogui.onScreen(tuple(coord)), 'onScreen(({0}, {1})) should be {2}'.format(coord.x, coord.y, value))
                self.assertEqual(value, pyautogui.onScreen(coord), 'onScreen({0}) should be {1}'.format(repr(coord), value))

        # These can raise either ValueError or TypeError.
        with self.assertRaises(ValueError):
            pyautogui.onScreen([0, 0], 0)
        with self.assertRaises(ValueError):
            pyautogui.onScreen((0, 0), 0)
        with self.assertRaises(TypeError):
            pyautogui.onScreen(0, 0, 0)
        with self.assertRaises(TypeError):
            pyautogui.onScreen(0)
Example #24
0
def process():
   global counter
   print('Requests Number:  %d  Biz (%s)\n----------------------------------------------------' % (counter,  datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
   
   print(pyautogui.size())
   print(pyautogui.position())
   
   ## 获取句柄
   hwnd = win32gui.FindWindow(None, u"微信")
   win32gui.SetForegroundWindow(hwnd)
   win32gui.SetForegroundWindow(hwnd)
   
   pyautogui.moveTo(x=first_ret[0], y=first_ret[1], duration=1)
   pyautogui.click(x=first_ret[0], y = first_ret[1])

   biz = gen()

   pyautogui.typewrite(" http://mp.weixin.qq.com/mp/getmasssendmsg?__biz=%s#wechat_webview_type=1&wechat_redirect" % biz, interval=0)

   pyautogui.keyDown('enter')
   pyautogui.moveTo(rel_link[0], rel_link[1], duration=1)
   pyautogui.click(x=rel_link[0], y=rel_link[1])
   counter = counter + 1
Example #25
0
oldRightEye = (0, 0, -1, -1)


# Learning rest position (do this for turns 0-(learnPhase - 1))
turns = 0
learnPhase = 64

restFace = (0, 0, -1, -1)
restLeftEye = (0, 0, -1, -1)
restRightEye = (0, 0, -1, -1)


# Moving
eyeHitBox = 8                        # If the box reaches this far, move it
move = (0, 0, 0, 0)                  # Up, Down, Left, Right
scrW, scrH = pyautogui.size()        # Screen size
speed = 16                           # How far to step each read
pyautogui.moveTo(scrW / 2, scrH / 2) # Mouse starts in middle


# Clicking
lClick = 0
notlClick = 0.0
lThreshold = 32
rClick = 0
notrClick = 0.0
rThreshold = 32


# HitBox calculation... remember that left and right are mirrored!
def hit(old, new):
Example #26
0
#!/usr/bin/env python
import webbrowser
import csv
import numpy as np
import sys
import os
import time
import pyautogui
#for installation of pyautogui on mac check out http://stackoverflow.com/questions/35051580/phyton3-pip-and-pyautogui-install-mac-remove-broken-python and go to the bottom 

pyautogui.size()
width,height = pyautogui.size()
b = webbrowser.get('safari')
#bashCommand = "/bin/bash kill.sh"
#bashCommand = "sudo killall 'Safari' "
#bashCommand = "sudo killall -r 'google'"
new = 2
new_file = []
file1 = open('text.txt')
for row in file1:
	new_file.append(row)
#p.transpose(new_file)
x = 0
#l = numpy.array(new_file)
new_file = np.matrix(new_file)
j = np.transpose(new_file)
for i in j:
    x += 1
    b.open(i,new=new)
    #webbrowser.open(i,new=new)
    time.sleep(5)
Example #27
0
    def getMouv(self):
        size=pyautogui.size()
        #position des cam
        poscam={"Bas_Gauche": (0,size[1]), "Bas_Droite": (size[0],size[1]), "Haut_Gauche": (0,0), "Haut_Droite": (size[0],0)}
        #ordre des camera
        vid= ["Bas_Droite", "Haut_Droite", "Haut_Gauche", "Bas_Gauche"]
        data = []
        errorframe = 0

        while not self.isStopped():
            toofast=False
            if (self.cw!=None):
                time.sleep(1)

            angles = self.CalcAngle.getAngles()
            if len(angles)>4:
                toofast=True
                angles=[]

            #affichage des droites pour le debug
            if (self.affichageDroite!=None):
                line=[]
                for angle in angles:
                        line.append(((int)(angle[0]),poscam[angle[1]][0],poscam[angle[1]][1]))
                self.affichageDroite.createline(line)

            #calcul pour la calibration
            if (self.cw!=None):
                if (len(angles)>=self.nbrCam-1):
                    cx=size[0]/2.0
                    cy=size[1]/2.0
                    correctionTermine=True
                    for angle in angles:
                        a = compute_angle_from_pos(cx,cy,poscam[angle[1]][0],poscam[angle[1]][1])
                        gestionCamera.correctionAngle[angle[1]]+=a-angle[0]
                        print gestionCamera.correctionAngle
                    gestionCamera.correction=True
                    self.cw.quit()
                    print "end"
                    self.calibrationMode(None)

            else:
                #il faut que toujours les meme camera capte le meme mouvement
                if len(self.angledebut)!=0:
                    anglesbis=[]
                    for angle in angles:
                        if (angle[1] in self.angledebut):
                            anglesbis.append(angle)
                    angles=anglesbis
                if (len(angles)>=3 and len(angles)<=4):
                    #print angles
                    #print angles
                    i=0
                    coords=[]
                    #calcul de toute les intersection
                    while(i<len(angles)-1):
                        j = i+1

                        while(j < len(angles)):
                            if ((("Haut_Droite" in angles[i][1]) and ("Bas_Gauche" in angles[j][1])) or (("Haut_Droite" in angles[j][1]) and ("Bas_Gauche" in angles[i][1])) or (("Bas_Droite" in angles[i][1] ) and ( "Haut_Gauche" in angles[j][1])) or (("Bas_Droite" in angles[j][1]) and ( "Haut_Gauche" in angles[i][1]))):
                                j=j+1
                                continue

                            coord = compute_intersect(angles[i][0],poscam[angles[i][1]][0],poscam[angles[i][1]][1], angles[j][0], poscam[angles[j][1]][0],poscam[angles[j][1]][1])
                            if coord is not None:
                                coords.append(coord)
                            j=j+1
                        i=i+1

                    if (len(coords)==0):
                        continue
                    #calcul de la position
                    x,y=compute_coord(coords)
                    #affichage positions souris
                    if (self.affichageDroite!=None):
                        self.affichageDroite.affichePositionSouris((x,y))
                    errorframe=0
                    touch=False
                    if (self.mouvend):
                        touch,data=check_touch(x,y,data)
                    else:
                        touch=True
                    #si l'on a touché la surface
                    if touch:
                        self.mouvend=False
                    if not self.mouvend:
                            if self.mouv==None:
                                for angle in angles:
                                    self.angledebut.append(angle[1])
                            #print x,y
                            if self.mouv==None:
                                self.mouv=Mouvements([[]])
                            #print self.mouvend
                            self.mouv.add_new_pos_to_finger(0,(x,y))
                            #print self.mouv.tabMouvementDoigts
                            return

                else:
                    #print len(angles)
                    if(errorframe<60 and not self.mouvend):
                        errorframe+=1
                    else:
                        if not toofast:
                            self.mouvend=True
                            self.angledebut=[]
                            if self.mouv!=None:
                                return

            #time.sleep(0.05)


        cv2.destroyAllWindows()
Example #28
0
def getMouv(GC=None,mouv=None, cam=None, nbrCam=None):
    if nbrCam == None:
        nbrCam=4
    size=pyautogui.size()
    poscam={"Bas_Gauche": (0,size[1]), "Bas_Droite": (size[0],size[1]), "Haut_Gauche": (0,0), "Haut_Droite": (size[0],0)}
    vid= ["Bas_Droite", "Haut_Droite", "Haut_Gauche", "Bas_Gauche"]
    mycam=[]
    if (cam==None):
        for i in range(1,nbrCam+1):
            mycam.append(cv2.VideoCapture(i))

    #i=0
    #while (i<1*12):
    #    (grabbed1, frame1) = cam1.read()
    #    i=i+1

    data = []
    tab=[]
    mouvbegin=False
    angledebut=[]
    errorframe = 0
    while True:
        #print errorframe
        if(GC != None):
            if (GC.isStopped()):
                break
        #print cam
        frame=[]
        if (cam==None):
            for c in mycam:
                frame.append(c.read()[1])
        else:
            for c in cam:
                frame.append(c.get_frame())

        angles=[]
        if (GC!= None and GC.cw!=None):
            time.sleep(1)
        for i in range(len(frame)):
            if (frame[i]!=None or not (gestionCamera.correction and gestionCamera.correctionAngle[vid[i]]==0)):
                a = find_angle_from_frame(frame[i], vid[i])
                if (a!=None):
                    angles.append((a, vid[i]))

        if (GC!= None and GC.affichageDroite!=None):
            line=[]
            for angle in angles:
                    line.append(((int)(angle[0]),poscam[angle[1]][0],poscam[angle[1]][1]))
            GC.affichageDroite.createline(line)

        if (GC!= None and GC.cw!=None):
            if (len(angles)>=nbrCam-1):
                cx=size[0]/2.0
                cy=size[1]/2.0
                correctionTermine=True
                for angle in angles:
                    a = compute_angle_from_pos(cx,cy,poscam[angle[1]][0],poscam[angle[1]][1])
                    gestionCamera.correctionAngle[angle[1]]+=a-angle[0]
                    print gestionCamera.correctionAngle
                gestionCamera.correction=True
                GC.cw.quit()
                print "end"
                GC.calibrationMode(None)

        else:
            #il faut que toujours les meme camera capte le meme mouvement
            if len(angledebut)!=0:
                anglesbis=[]
                for angle in angles:
                    if (angle[1] in angledebut):
                        anglesbis.append(angle)
                angles=anglesbis

            if (len(angles)>=3):
                #print angles
                i=0
                coords=[]
                while(i<len(angles)-1):
                    j = i+1
                    #calcul de toute les intersection
                    while(j < len(angles)):
                        if ((("Haut_Droite" in angles[i][1]) and ("Bas_Gauche" in angles[j][1])) or (("Haut_Droite" in angles[j][1]) and ("Bas_Gauche" in angles[i][1])) or (("Bas_Droite" in angles[i][1] ) and ( "Haut_Gauche" in angles[j][1])) or (("Bas_Droite" in angles[j][1]) and ( "Haut_Gauche" in angles[i][1]))):
                            j=j+1
                            continue

                        coord = compute_intersect(angles[i][0],poscam[angles[i][1]][0],poscam[angles[i][1]][1], angles[j][0], poscam[angles[j][1]][0],poscam[angles[j][1]][1])
                        if coord is not None:
                            coords.append(coord)
                        j=j+1
                    i=i+1

                if (len(coords)==0):
                    continue
                x,y=compute_coord(coords)
                if (GC!= None and GC.affichageDroite!=None):
                    GC.affichageDroite.affichePositionSouris((x,y))
                errorframe=0
                touch,data=check_touch(x,y,data)
                #print(touch)
                if touch:
                    mouvbegin=True
                if mouvbegin:
                        if len(tab)==0:
                            for angle in angles:
                                angledebut.append(angle[1])
                        #print x,y
                        tab.append((x,y))
                        if len(tab)>25:
                            mouvbegin=False
                            supertab=[]
                            supertab.append(tab)
                            mouv=Mouvements(supertab)
                            return mouv

                        #if mouv!=None:
                        #    mouv.add_new_pos_to_finger(0,(x,y))
                        #    return mouv
                        #else:
                            #supertab=[]
                            #supertab.append(tab)
                            #mouv=Mouvements(supertab)
                            #return Mouv

                        #cam1.release()
                        #cam2.release()
                        #print tab
            else:
                if(errorframe<10 and mouvbegin):
                    errorframe+=1
                else:
                    #print tab
                    mouvbegin=False
                    if (len(tab)!=0):
                        supertab=[]
                        supertab.append(tab)
                        mouv=Mouvements(supertab)
                        return mouv
                #else:
                #    return mouv

        time.sleep(0.05)


    cv2.destroyAllWindows()
Example #29
0
def test_size():
    width, height = pyautogui.size()

    return width, height
Example #30
0
def minimize_windows():

    width, height = pyautogui.size()
    pyautogui.click(x=width - 2, y=height - 2, button='left')
Example #31
0
@author: karth
"""

import subprocess
import pyautogui
import time

#get into lords mobile
#pyautogui.hotkey('win','s')
#pyautogui.typewrite('Lords Mobile', interval=0.1)
#pyautogui.press('enter')

time.sleep(7)

print(pyautogui.size())

time.sleep(3)
#make sure you hit the center position and click your castle
pyautogui.moveTo(1700, 520)
#drag left side
pyautogui.dragTo(300, 400, 1, button='left')
time.sleep(3)
#click gotoposition
pyautogui.click(1630, 310)
time.sleep(1)
#click on castle
pyautogui.click(950, 540)
time.sleep(1)
#click on enter turf
pyautogui.click(950, 640)

logging.basicConfig(filename='autopilot.log', level=logging.DEBUG)
logging.info('\n'+200*'-'+'\n'+'---- AUTOPILOT DATA '+180*'-'+'\n'+200*'-')


# In[4]:


PATH_LOG_FILES = None
PATH_KEYBINDINGS = None
KEY_MOD_DELAY = 0.010
KEY_DEFAULT_DELAY = 0.200
KEY_REPEAT_DELAY = 0.100
FUNCTION_DEFAULT_DELAY = 0.500
SCREEN_WIDTH, SCREEN_HEIGHT = size()

logging.info('PATH_LOG_FILES='+str(PATH_LOG_FILES))
logging.info('PATH_KEYBINDINGS='+str(PATH_KEYBINDINGS))
logging.info('KEY_MOD_DELAY='+str(KEY_MOD_DELAY))
logging.info('KEY_DEFAULT_DELAY='+str(KEY_DEFAULT_DELAY))
logging.info('KEY_REPEAT_DELAY='+str(KEY_REPEAT_DELAY))
logging.info('FUNCTION_DEFAULT_DELAY='+str(FUNCTION_DEFAULT_DELAY))
logging.info('SCREEN_WIDTH='+str(SCREEN_WIDTH))
logging.info('SCREEN_HEIGHT='+str(SCREEN_HEIGHT))


# ## Read ED logs

# ### Get latest log file
Example #33
0
def main():  #the main function
    '''serial port can output wrong values (not numbers) 
	so the try-except rerun the code if something goes wrong'''
    try:
        ser.close()
        print('Trying to connect device at ' + (ser.name))
        ser.open()
        while True:  #loop the function

            x = float(ser.readline().strip()
                      )  #the first readed value is the x axis value
            time.sleep(0.001)  #wait for 1 millisecond

            y = float(ser.readline().strip())  #the second is the y axis value
            time.sleep(0.001)
            while (x == 547
                   or y == 547):  #this value (547) is the left click input
                pyautogui.click(clicks=1)
                x = speed  #don't move the cursor (cannot move the cursor if you're clicking)
                y = speed
            while (x == 896
                   or y == 896):  #this value (896) is the right click input
                pyautogui.click(button='right')
                x = speed
                y = speed
            while (x == 354
                   or y == 354):  #this value (354) is the up scroll inpuyt
                pyautogui.scroll(scrollSpeed)
                x = speed  #don't move the cursor (cannot move the cursor if you're scrolling)
                y = speed
            while (x == 657
                   or y == 657):  #this value (657) is the down scroll input
                pyautogui.scroll(-scrollSpeed)
                x = speed  #don't move the cursor (cannot move the cursor if you're scrolling)
                y = speed
            '''some math to adjust the x and y values'''
            x = x - speed
            y = (y - speed) * -1
            if (x == 1 or x == -1):
                x = 0

            if (y == 1 or y == -1):
                y = 0

            a = str(x)
            b = str(y)
            print("X = " + a)
            print("Y = " + b)

            width, height = pyautogui.size()
            pyautogui.PAUSE = 0
            pyautogui.FAILSAFE = False
            pyautogui.moveRel(
                x, y, duration=0
            )  #move the cursor relatively to his current position by x and y values
    except:
        if (auto_rerun == True):
            print('An error occurred, rerun: on, rerunning code...')
            main()  #re-run the main()function
        else:
            print('An error occurred, rerun: off, closing...')
Example #34
0
def get_screen_size():
	
	screen_size = pyautogui.size()
	
	return screen_size
debug_mode = False  # set this to True if you experience issues and want to look at the screenshots the script creates (which normally get deleted again right away after being processed). will also disable clicking.

if debug_mode:
    print("Debug mode active")

try:
    from PIL import Image
except ImportError:
    import Image
import pytesseract

print(
    "THIS IS A HIGHLY EXPERIMENTAL SCRIPT!\nIf you haven't read the readme yet, do it now."
)

screenWidth, screenHeight = pyautogui.size()  # get screen resolution

top = 600
left = 720
height = 52
width = 470

#detects most properties, except crit chance: (also turned out not enough for longer names like "damage reduction vs area damage")
#top = 598
#left = 800
#height = 54
#width = 310


def clickhold(
        s):  # since you need to hold down the mouse a bit to reroll stats
import pyautogui 
screenWidth, screenHeight = pyautogui.size()  
pyautogui.moveTo(screenWidth/2, screenHeight/2)
currentMouseX, currentMouseY = pyautogui.position()
##pyautogui.click() 
##pyautogui.moveRel(None, 10) # move mouse 10 pixels down 
##pyautogui.doubleClick() 
###pyautogui.moveTo(500, 500, duration=2, tween=pyautogui.tweens.easeInOutQuad) # use tweening/easing function to move mouse over 2 seconds. 
##pyautogui.typewrite('Hello world!', interval=0.25) # type with quarter-second pause in between each key 
##pyautogui.press('esc') 
##pyautogui.keyDown('shift') 
##pyautogui.typewrite(['left', 'left', 'left', 'left', 'left', 'left']) 
##pyautogui.keyUp('shift') 
##pyautogui.hotkey('ctrl', 'c')

while True:
    currentMouseX1, currentMouseY1 = pyautogui.position()
    if ((currentMouseX1 - currentMouseX) or (currentMouseY1 - currentMouseY)):
        print pyautogui.position()
        currentMouseX, currentMouseY = currentMouseX1, currentMouseY1
Example #37
0
    def start(self):

        start = time.perf_counter()

        # GET THE SIZE OF THE MONITOR THAT WILL DISPLAY THE TOS APP
        screen_width, screen_length = pyautogui.size()

        # START_X AND START_Y ARE BOTH WHERE THE MOUSE ARROW WILL START ON SCREEN.
        # THIS SHOULD BE PLACED WITHIN THE SMA BAR GRAPH TO BE ABLE TO GET THE REPORTS.
        # WILL NEED TO BE ADJUSTED BASED ON SCREEN SIZE
        start_x = int(screen_width / 2.660194174757281)
        start_y = int(screen_length / 1.728)

        # GET AVERAGE ITERATION CYCLE TIME AND GET ESTIMATED TIME REMAINING
        cycles = []

        previous_cycle_time = None

        while self.watchlist_length != 0 and self.no_error:

            # SHOW REPORT BUTTON
            pyautogui.rightClick(start_x, start_y)  # ABSOLUTE

            time.sleep(self.delay)

            pyautogui.move(30, 90)  # RELATIVE

            time.sleep(self.delay + 0.25)

            pyautogui.click()

            # EXPORT FILE BUTTON
            pyautogui.move(520, 40)  # RELATIVE

            time.sleep(self.delay)

            pyautogui.click()

            # SAVE BUTTON (save strategy report to documents folder)
            pyautogui.move(-160, -90)  # RELATIVE

            time.sleep(self.delay)

            pyautogui.click()

            # # overwrite
            # pyautogui.move(-85, -575) # RELATIVE

            # time.sleep(self.delay)

            # pyautogui.click()

            time.sleep(self.delay)

            # CLOSE BUTTON (close out of the strategy report)
            pyautogui.move(200, 100)  # RELATIVE

            time.sleep(self.delay)

            pyautogui.click()

            time.sleep(self.delay)

            # NEXT SYMBOL (arrows down to next symbol in watchlist)
            pyautogui.press(['down'])

            time.sleep(self.delay + .3)

            ###############
            self.moveCSVFile()

            if self.no_error:

                middle = time.perf_counter()

                running_time = time.strftime('%H:%M:%S',
                                             time.gmtime(middle - start))

                if len(cycles) > 2:

                    time_remaining = time.strftime(
                        '%H:%M:%S',
                        time.gmtime(
                            statistics.mean(cycles) * self.watchlist_length))

                else:

                    time_remaining = "N/A"

                print(
                    f"REMAINING --> {self.watchlist_length} | RUNNING TIME: {running_time} | EST. TIME REMAINING: {time_remaining}"
                )

                if previous_cycle_time != None:

                    cycles.append((middle - start) - previous_cycle_time)

                previous_cycle_time = middle - start

        if self.no_error:

            end = time.perf_counter()

            # FINISHED

            print("\nFINISHED!")

            playsound("audio/alert_on_call.mp3")

            took = time.strftime('%H:%M:%S', time.gmtime(end - start))

            print(f"TOTAL RUN TIME: {took}")