def quit_apps(): pc.unlock() pc.homeButton() # includes tap command pc.tap() for x in range(0, 4): pc.scrollWayUp() pc.homeButton() sleep(2) pc.zero() pc.onOff()
def buienradar(): pc.unlock() pc.move(xy.app(2, 5)) pc.tap() pc.getOutTheWay() sleep(6) pc.homeButton() pc.zero() sleep(1) pc.onOff()
def twit_likes(): pc.unlock() pc.move(xy.app(3, 2)) pc.tap() a = 0 while a < 20: theart.lookForTwitHearts() pc.scrollUp() pc.getOutTheWay() a += 1 theart.lookForTwitHearts() # one last lookfor hearts pc.homeButton() pc.zero() sleep(1) pc.onOff()
def reddit_upvote(): pc.unlock() pc.move(xy.app(3, 4)) pc.tap() pc.getOutTheWay() pc.sleep(2) a = 0 while a < 15: pc.scrollUp() pc.getOutTheWay() lfrl.lookForLikes() a += 1 pc.homeButton() pc.zero() sleep(1) pc.onOff()
def tweet(a): pc.unlock() pc.move(xy.app(3, 2)) pc.tap() # open twitter pc.movexy(2850, 3000) pc.lightTap() # hit tweet button sleep(4) # wait for keyboard to come up pc.type(a) pc.movexy(2800, 6350) # hit tweet button pc.tap() pc.getOutTheWay() sleep(5) pc.homeButton() pc.zero() sleep(1) pc.onOff()
def fb_likes(): pc.unlock() pc.move(xy.app(2, 3)) pc.tap() pc.getOutTheWay() pc.sleep(2) a = 0 while a < 15: pc.scrollUp() pc.getOutTheWay() lffb.lookForLikes() a += 1 pc.homeButton() pc.zero() sleep(1) pc.onOff()
def insta_likes( ): # Yo! lfh.lookForHearts has the commenting functionality built into it. pc.unlock() pc.move(xy.app(2, 1)) # instagram app pc.tap() # look for unliked insta posts a = 0 while a < 20: pc.scrollUp() pc.getOutTheWay() lfh.lookForHearts() a += 1 pc.homeButton() pc.zero() sleep(1) pc.onOff()
def insta_followers(): pc.unlock() pc.move(xy.app(2, 1)) pc.tap() # open insta sleep(4) # wait for insta to load pc.movexy(2850, 2700) pc.tap() # hit profile pc.movexy(2200, 6100) pc.tap() #hit followers pc.move(xy.homeButton) a = 0 while a < 15: instaFollowers.followBack() pc.scrollUp() pc.getOutTheWay() a += 1 pc.movexy(950, 6400) pc.tap() # back to profile pc.movexy(1000, 2650) pc.tap() # back to main instagram feed pc.homeButton()
def lookForHearts(): #Create a memory stream so photos doesn't need to be saved in a file stream = io.BytesIO() camW = 1280 camH = 960 #Get the picture (low resolution, so it should be quite fast) #Here you can also specify other parameters (e.g.:rotate the image) with picamera.PiCamera() as camera: camera.resolution = (camW, camH) # 4:3 1280:960 also works camera.capture(stream, format='jpeg') #Convert the picture into a numpy array buff = numpy.fromstring(stream.getvalue(), dtype=numpy.uint8) #Now creates an OpenCV image image = cv2.imdecode(buff, 1) #crops in on image to search for hearts only in the left bit of the phone roiX = 640 roiY = 300 roiYMax = 800 roi = image[roiY:roiYMax, 640:750] # height range, width range (weird) #Load a cascade file for detecting faces heart_cascade = cv2.CascadeClassifier('camera/heart_cascade_level_16.xml') #Convert to grayscale gray = cv2.cvtColor(roi, cv2.COLOR_BGR2GRAY) # look for hearts within roi #Look for faces in the image using the loaded cascade file hearts = heart_cascade.detectMultiScale( roi) # previously looked at gray instead of cropped roi numHearts = len(hearts) print "Found " + str(numHearts) + " heart(s)" if numHearts == 1: print "one heart" #Draw a rectangle around every found heart for (x, y, w, h) in hearts: heartX = roiX + x + w / 2 # around the heart plus the distance from the edge to the roi heartY = roiY + y + h / 2 cv2.rectangle(image, (x + roiX, y + roiY), (x + w + roiX, y + h + roiY), (255, 0, 0), 2) # draw a point at the center of the heart cv2.line(image, (heartX, heartY), (heartX, heartY), (0, 0, 255), 5) cv2.imwrite('result.jpg', image) # save image print "heartX, heartY = (%d, %d)" % (heartX, heartY) toY = mapValues.myMap(heartY) print "toY = %d" % toY pc.movexy(900, toY) pc.lightTap() pc.checkStatus() b = random.randint(1, 100) #tapped the heart, now decide whether to comment or not print "random number = %d" % b if b <= 20: pc.x(1100) # move over to the comment button pc.tap() pc.type("nice") pc.movexy(2800, 4300) #post comment pc.tap() sleep(2) pc.movexy(900, 6300) # back to stream pc.tap() if b > 20 and b <= 40: pc.x(1100) # move over to the comment button pc.tap() pc.type('great pic') pc.movexy(2800, 4300) #post comment pc.tap() sleep(2) pc.movexy(900, 6300) #back to stream pc.tap() return (toY) else: print "no hearts found"