def run(): print '--> mission Dawning The Slavers (2 of 2)' if not ship.enableDefense(): return False result = None begin = time.time() while not result and time.time() - begin < 5: time.sleep(0.5) result = findAtFull('close') if result: mouse.leftClickAtP(result) if not drones.launchSmall(): return False overview.seekAndDestory() if not drones.back(): return False if not overview.activateAccelerationGate(): return False if not drones.launchSmall(): return False overview.seekAndDestory() if not drones.back(): return False print '<-- mission Dawning The Slavers (2 of 2)\n' return True
class ReactionSimple(ReactionBase): def __init__(self): ReactionBase.__init__(self) self.recongnition = Recongnition() self.infoGetter = ChessInformation() self.frame = Framework() self.mouse = Mouse() self.endFlag = True def setConfig(self, config): self.neededHero = [] for key, value in config.items(): if value["Cost"] == 1: self.neededHero.append(key) def getInfo(self): imgList = list() for i in range(5): imgList.append(self.infoGetter.getChessImg(i, self.frame)) return imgList def processInfo(self, info): return self.recongnition.get(info) def opration(self, info): if info == None: return for i in range(5): if info[i] in self.neededHero: self.mouse.buyChess(i) def end(self): return self.endFlag
def setPrice(self, price): # found = [self.self_window_coord[0],self.self_window_coord[1],self.self_window_coord[2],self.self_window_coord[3]] # found = [374,200,374,200] found = [ 356, 181, 356 + GC.offer_button_dimensions[0], 181 + GC.offer_button_dimensions[1] ] found_coord = [ self.self_window_coord[0] + found[0], self.self_window_coord[1] + found[1], self.self_window_coord[0] + found[2], self.self_window_coord[1] + found[3] ] # crop = Screenshot.crop(self.global_rs_image, found_coord) # cv2.imwrite(r'C:\Users\PPC\git\RS_BOT_2.0\aaaaacrop.png', crop) # found_coord = [found[0]+self.self_window_coord[0], found[1]+self.self_window_coord[1], found[0]+self.self_window_coord[0] + GC.offer_button_dimensions[0], # found[1]+self.self_window_coord[1] + GC.offer_button_dimensions[1]] Mouse.clickRadius( self._calculateGlobalCoord(self.global_rs_coord, found_coord)) # Mouse.win32ClickRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord)) # Mouse.win32ClickRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord)) RandTime.randTime(0, 0, 0, 2, 0, 0) Keyboard.type_this(price) Keyboard.press("enter")
def run(): print "--> mission Intercept the Pirate Smugglers" result = None begin = time.time() while not result and time.time() - begin < 5: time.sleep(0.2) result = findAtFull("close") if result: mouse.leftClickAtP(result) if not ship.enableDefense(): return False if not drones.launchSmall(): return False if not general.openMissionDetails(): return False ship.enableAfterburn() overview.seekAndDestory() if not general.missionObjectiveComplete(): return False if not drones.back(): return False print "<-- mission Intercept the Pirate Smugglers\n" return True
def __init__(self): ReactionBase.__init__(self) self.recongnition = Recongnition() self.infoGetter = ChessInformation() self.frame = Framework() self.mouse = Mouse() self.endFlag = True
def chooseColor(r, g, b): global lastColorKey bestKey = getColor(r, g, b) if bestKey != lastColorKey: Mouse.click(btns[bestKey]) lastColorKey = bestKey
def run(): print '--> mission What Comes Around Goes Around' if not ship.enableDefense(): return False if not drones.launchSmall(): return False result = None begin = time.time() while not result and time.time() - begin < 5: time.sleep(0.2) result = findAtFull('close') if result: mouse.leftClickAtP(result) if not general.openMissionDetails(): return False if not general.missionObjectiveComplete(): return False if not drones.back(): return False print '<-- mission What Comes Around Goes Around\n' return True
def find_mining_icon(offset=0,*args): """needs work, not fucntional, copy pasted from findBankIcon""" # bank hue range low = np.array([26,160,176]) high = np.array([27,244,228]) mask, mm_x, mm_y = get_mini_map_mask(low, high) #cv2.imshow('mask', mask) #cv2.waitKey(0) _, contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) for c in contours: (x, y, w, h) = cv2.boundingRect(c) if args[0] == "n": x += mm_x y += mm_y - offset x2 = x + w y2 = y + (h/2) Mouse.randMove(x,y,x2,y2,1) #Mouse.moveTo(x,y) RandTime.randTime(1,0,0,1,9,9) return x += mm_x y += mm_y x2 = x + w y2 = y + h Mouse.randMove(x,y,x2,y2,1) RandTime.randTime(1,0,0,1,9,9) return
def findBankIcon(offset=0, *args): # bank hue range low = np.array([21,157,173]) high = np.array([25,178,221]) mask, mm_x, mm_y = get_mini_map_mask(low, high) #cv2.imshow('mask', mask) #cv2.waitKey(0) _, contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) for c in contours: (x, y, w, h) = cv2.boundingRect(c) try: if args[0] == "n": x += mm_x y += mm_y - offset x2 = x + w y2 = y + (h/2) Mouse.randMove(x,y,x2,y2,1) #Mouse.moveTo(x,y) RandTime.randTime(1,0,0,1,9,9) return except: pass x += mm_x y += mm_y x2 = x + w y2 = y + h Mouse.randMove(x,y,x2,y2,1) RandTime.randTime(1,0,0,1,9,9) return
def clickItem(self): # Mouse.win32MoveToRadius(self.global_self_coord) # Mouse.clickRadius(self._calculateGlobalCoord(self.global_rs_coord,self.self_window_coord)) print self._calculateGlobalCoord(self.global_rs_coord, self.self_window_coord) Mouse.clickRadius( self._calculateGlobalCoord(self.global_rs_coord, self.self_window_coord))
def enterStarMap(): print '--> enter star map' key.pressEx(sc.Map) begin = time.time() while findAtProgressBar('initializing_map') or time.time() - begin < 3: time.sleep(0.5) mouse.moveToP(panel.center(panel.Full)) mouse.wheel(100) print '<-- enter star map\n'
def run(): print '--> mission Eliminate the Pirate Campers' if not ship.enableDefense(): return False if not drones.launchSentry(): return False if not overview.switchTo('battle'): return False begin = time.time() result = None while not result and time.time() - begin < 5: result = findAtFull('close') if result: mouse.leftClickAtP(result) # kill small count = 0 while count < 4: result = overview.lockTarget('s', 1) if result: count += 1 begin = time.time() while time.time() - begin < 120: overview.lockTarget('s', 1) ship.fireOnce() drones.engage() if not drones.back(): return False # seek and destory if not general.openMissionDetails(): return False ship.enableAfterburn() if not drones.launchSmall(): return False overview.seekAndDestory() if not general.missionObjectiveComplete(): return False if not drones.back(): return False print '<-- mission Eliminate the Pirate Campers\n' return True
def drawPreprocessed(pixels): Mouse.click(btns["delete"]) Mouse.click(btns["pen"]) Mouse.click(btns["size2"]) for color in pixels: Mouse.click(btns[color]) for pixel in pixels[color]: Mouse.click((topLeft[0]+pixel[0], topLeft[1]+pixel[1])) print("Finished drawing!")
def openInventory(): print '--> open inventory' key.pressEx(sc.Inventory) mouse.moveToP(panel.center(panel.Inventory)) while not findAtInventory('x'): time.sleep(0.2) print '<-- open inventory\n' return True
def clickOffer(self): crop_down = [ self.global_self_coord[0] + 3, self.global_self_coord[1] + 10, self.global_self_coord[2] - 7, self.global_self_coord[3] - 20, ] Mouse.clickRadius(crop_down)
def openMissionMenu(): print '--> open mission menu' result = findAtInfo('agent_mission') while not result: result = findAtInfo('agent_mission') time.sleep(1) mouse.leftClickAt(result[0] + 60, result[1] + 30) time.sleep(1) print '<-- open mission menu\n'
def clickBack(self): # found = [217,200,217,200] found = [19, 258, 44, 277] found_coord = [ self.self_window_coord[0] + found[0], self.self_window_coord[1] + found[1], self.self_window_coord[0] + found[2], self.self_window_coord[1] + found[3] ] Mouse.clickRadius( self._calculateGlobalCoord(self.global_rs_coord, found_coord))
def handleDangerousAction(): result = findAtFull('dangerous') if result: mouse.moveToP(result) result = None while not result: result = findAtFull('x') mouse.leftClickAtP(result) key.pressEx(sc.Unlock) return True else: return False
def clickFoundItemHard(self, img_rgb): crop = Screenshot.crop(img_rgb, self.self_window_coord) found = [12, 35, 100, 55] resize_radius = [0, 0, 0, 0] found_coord = [ found[0] + self.self_window_coord[0] + resize_radius[0], found[1] + self.self_window_coord[1] + resize_radius[1], found[2] + self.self_window_coord[0] + resize_radius[2], found[3] + self.self_window_coord[1] + resize_radius[3] ] # Screenshot.save("balh.png", self._calculateGlobalCoord(self.global_rs_coord, found_coord)) Mouse.clickRadius( self._calculateGlobalCoord(self.global_rs_coord, found_coord))
def update(self, *args): layers = GetGame().get_layers() def sort_sprites_cmp(x, y): # Sorts sprites by layer from top down return layers.index(y.layer) - layers.index(x.layer) self._sprites.sort(sort_sprites_cmp) # Let's handle mouse clicks first for event in Mouse.get_events(): if event.type == pygame.MOUSEMOTION: # We don't really care about these, we'll poll the # mouse directly later continue for sprite in self._sprites: if not isinstance(sprite, MouseClickSprite): continue if sprite.is_clicked(event): sprite.clicked(event) if sprite.click_overlay is not True: break # Now let's handle mouseover. mouse_pos = Mouse.get_pos() mouse_now_over = [] for sprite in self._sprites: if not isinstance(sprite, MouseOverSprite): continue if sprite.is_mouse_over(mouse_pos): mouse_now_over.append(sprite) # first, is this one that the mouse was previously over if sprite in self._mouse_previously_over: if sprite.hover_overlay: continue else: break # Now that we know it's not, we tell it the mouse is on it sprite.mouse_on() if sprite.hover_overlay: continue break for sprite in self._mouse_previously_over: if sprite in mouse_now_over: continue sprite.mouse_off() self._mouse_previously_over = mouse_now_over Group.update(self, *args)
def lockEnemy(wait = 5): print '--> lock enemy' result = findEnemy() if not result: return False mouse.leftClickAtP(result) key.pressEx(sc.Lock) print 'wait for ' + str(wait) + ' seconds' time.sleep(wait) print '<-- lock enemy' return True
def switchTo(name): print '--> switch overview setting to ' + name trycount = 0 success = False while not success and trycount < 3: success = True trycount += 1 result = findAtOverview('overview') if not result: success = False mouse.leftClickAtP(result) mouse.moveTo(result[0] - 400, result[1]) time.sleep(0.5) result = findAtOverview(name) if not result: success = False mouse.leftClickAtP(result) time.sleep(0.5) if not success: mouse.leftClickAtP(panel.center(panel.Full)) if not success: return False print '<-- switch overview setting to ' + name + '\n' return True
def confirmPrice(self): template = GC.offer_confirm found = Match.this(self.global_rs_image, template) # print found, "found" if found: found_coord = [ found[0], found[1], found[0] + GC.offer_button_dimensions[0], found[1] + GC.offer_button_dimensions[1] ] Mouse.clickRadius( self._calculateGlobalCoord(self.global_rs_coord, found_coord))
def declineMission(): print '--> decline mission' result = None while not result: time.sleep(0.2) result = findAtMissionRight('decline') mouse.leftClickAtP(result) begin = time.time() result = None while not result and time.time() - begin < 5: time.sleep(0.5) result = findAtFull('yes') if result: mouse.leftClickAtP(result) print 'wait until decline' while not findAtMission('request_mission'): time.sleep(0.5) mouse.moveToP(panel.center(panel.MissionLeft)) result = None while not result: time.sleep(0.5) result = findAtFull('x') mouse.leftClickAtP(result) time.sleep(1) print '<-- decline mission\n' return True
def __init__(self, players): initKeys(logic.expandPath("//conf.mol")) #bge.constraints.setDebugMode(bge.constraints.DBG_DRAWWIREFRAME) #Constants: self.players = players self.mouse = Mouse() self.prefix = "default" self.radialSpeedIncrease = 1 #The speed with the radial speed will increase self.maxVelocity = 10 self.maxDotValue = 0.5 self.maxTimer = 6.0 self.minTimer = 2.0 self.reticuleXY = overlayer1.objects["reticuleXY"] self.reticuleXZ = overlayer1.objects["reticuleXZ"] overlayer1.objects["curveXZ"].localScale.y *= self.maxDotValue self.flagXY = overlayer1.objects["flagXY"] self.flagXZ = overlayer1.objects["flagXZ"] self.molkky = scene.objects["Mölkky"] self.puppet = scene.objects["Mölkky_puppet"] self.origin = scene.objects["Origin"] self.reference = scene.objects["reference"].worldPosition self.pinList = [] for i in range(0, 12): self.pinList.append(scene.objects["pin." + str(i + 1)].groupMembers["pin"]) #Variables: self.test = 0 self.playerNumber = 0 #The ID of the actual player self.player = self.players[self.playerNumber] self.molkkyLaunched = 0 self.leftActivated = 0 self.rightActivated = 0 self.oldLeftClick = 0 self.leftClick = 0 self.timer = Utils.Timer() self.oldPinsPos = [Vector((0, 0, 0))] * 12 self.oldMollkyPos = Vector((0, 0, 0)) #Init oldPinsPos && oldMollkyPos for i in range(0, 12): self.oldPinsPos[i] = self.pinList[i].worldPosition self.oldMollkyPos = Vector( (self.molkky.worldPosition.x, self.molkky.worldPosition.y, self.molkky.worldPosition.z))
def lockTarget(target, wait = 5): result = findTarget(target) if not result: return False print '--> lock target "' + target + '"' mouse.leftClickAtP(result) key.pressEx(sc.Lock) print 'wait for ' + str(wait) + ' seconds' time.sleep(wait) print '<-- lock target "' + target + '"\n' return True
def startConversation(agent): print '--> start conversation' result = pic.findImgR(panel.StationServices, agent) while not result: time.sleep(0.5) result = pic.findImgR(panel.StationServices, agent) mouse.doubleClickAtP(result) print 'wait until conversation start' while not findAtMissionLeft('info'): time.sleep(0.2) print '<-- start conversation\n' return True
def missionObjectiveComplete(): print '--> judge if mission complete' print 'wait until mission complete' while not findAtMissionDetails('v'): time.sleep(1) mouse.moveToP(panel.center(panel.MissionDetails)) result = None while not result: time.sleep(0.5) result = findAtMissionDetails('x') mouse.leftClickAtP(result) print '<-- judge if mission complete\n' return True
def clickBuy(self): template = GC.status_buy_button found = Match.this(self.global_rs_image, template) if found: found_coord = [ found[0], found[1], found[0] + GC.status_buy_button_dimensions[0], found[1] + GC.status_buy_button_dimensions[1] ] # print found_coord # Mouse.win32MoveToRadius(self._calculateGlobalCoord(self.global_self_coord,found_coord)) # Mouse.win32ClickRadius(self._calculateGlobalCoord(self.global_self_coord, found_coord)) Mouse.clickRadius( self._calculateGlobalCoord(self.global_self_coord, found_coord))
def funcionando(self): self.updFondo() self.m = Mouse.Mouse(self.supIzq, self.infDer) #inicializo todos para que no haya errores for i in xrange(int(self.smooth / 2) + 1): centro = (0, 0) self.__agregarPunto(centro, self.puntosFoto) self.__agregarPunto(centro, self.puntosSuav) self.centroSuav = (0, 0) i = 0 print time.clock() while self.cont: i += 1 centro = self.analizar() self.__agregarPunto(centro, self.puntosFoto) #para el butter self.centroSuav = self.__getPuntoSuav1() self.__agregarPunto(self.centroSuav, self.puntosSuav) self.m.setPos(self.centroSuav) if i > 60: self.updGTK() i = 0 print time.clock()
def run(): print '--> mission New Frontiers - Raw Materials (5 of 7)' if not ship.enableDefense(): return False if not drones.launchSentry(): return False if not overview.switchTo('battle'): return False if not overview.lockTarget('drone_energy', 25): return False drones.engage() time.sleep(160) if not drones.back(): return False mouse.moveTo(100, 100) result = findAtDrones('sentry') if result: mouse.leftClickAtP(result) if not drones.launchSmall(): return False overview.seekAndDestory() ship.enableAfterburn() while not overview.pickCargo(): time.sleep(5) while overview.pickCargo(): pass if not drones.back(): return False print '<-- mission New Frontiers - Raw Materials (5 of 7)\n' return True
def __init__(self): super(MouseListener, self).__init__() #Initialize like a normal listener #Initialize a bunch of stuff specific to this implementation self.cursor = Mouse.relative_cursor( ) #The cursor object that lets us control mice cross-platform self.clicked = False self.velocity = 0.05
def enter(): global character, mouse, map, monsters global items character = Character.Character() mouse = Mouse.Mouse() map = Map.Map() monsters = [Monster.Monster() for i in range(60)] items = [Item.Item() for i in range(2)]
def findFishingIcon(): #fish color low = np.array([93,119,84]) high = np.array([121,255,255]) mask, mm_x, mm_y = get_mini_map_mask(low, high) _, contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) for c in contours: (x, y, w, h) = cv2.boundingRect(c) x += mm_x y += mm_y x2 = x + w y2 = y + h Mouse.randMove(x,y,x2,y2,1) run= 0 RandTime.randTime(1,0,0,1,9,9) return 0 return 1
def OnMouse(self, event): if wx.GetApp().toolpath == None: GraphicsCanvas.OnMouse(self, event) else: e = Mouse.MouseEventFromWx(event) sim.OnMouse(e) if sim.refresh_wanted() == True: self.Refresh() event.Skip()
def decreasePrice(self, num_clicks): template = GC.offer_decrease found = Match.this(self.global_rs_image, template) # print found, "found" if found: found_coord = [ found[0], found[1], found[0] + GC.offer_button_dimensions[0], found[1] + GC.offer_button_dimensions[1] ] for x in range(num_clicks): Mouse.clickRadius( self._calculateGlobalCoord(self.global_rs_coord, found_coord)) # Mouse.win32ClickRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord)) # Mouse.win32MoveToRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord)) RandTime.randTime(0, 0, 0, 0, 0, 1)
def __init__(self, color, title="StreetCode Academy", show_mouse_pos=False): pygame.init() pygame.font.init() self.screen = pygame.display.set_mode(SCREEN_SIZE) pygame.display.set_caption(title) self.clock = pygame.time.Clock() if pygame.font: self.font = pygame.font.Font(None, 30) else: self.font = None self.screen_color = color self.is_playing_game = True self.sprites = {} self.collision_flag = 0 self._keyboard = Keyboard() self._mouse = Mouse() self._show_mouse_pos = show_mouse_pos if self._show_mouse_pos: self.draw_rectangle(0, 100, 10, 1, WHITE) self.draw_rectangle(0, 200, 10, 1, WHITE) self.draw_rectangle(0, 300, 10, 1, WHITE) self.draw_rectangle(0, 400, 10, 1, WHITE) self.draw_rectangle(100, 0, 1, 10, WHITE) self.draw_rectangle(200, 0, 1, 10, WHITE) self.draw_rectangle(300, 0, 1, 10, WHITE) self.draw_rectangle(400, 0, 1, 10, WHITE) self.draw_rectangle(500, 0, 1, 10, WHITE) self.draw_rectangle(600, 0, 1, 10, WHITE) self.mouse_pos_text = self.draw_text(0, SCREEN_SIZE[1] - 17, '(0,0)', BLACK, size=12)
def find_furnance(offset=0,*args): """finds the inner orange in furnance icon on minimap""" # furnance hue range low = np.array([10,211,244]) high = np.array([23,229,255]) mask, mm_x, mm_y = get_mini_map_mask(low, high) kernel = np.ones((5,5),np.uint8) dilation = cv2.dilate(mask,kernel,iterations = 1) #cv2.imshow('mask', dilation) #cv2.waitKey(0) #return _, contours, _ = cv2.findContours(dilation.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) for c in contours: (x, y, w, h) = cv2.boundingRect(c) try: # clicks north of the icon if args[0] == "n": x += mm_x y += mm_y - offset x2 = x + w y2 = y + (h/2) Mouse.randMove(x,y,x2,y2,1) #Mouse.moveTo(x,y) RandTime.randTime(1,0,0,1,9,9) return except: pass x += mm_x y += mm_y x2 = x + w y2 = y + h Mouse.randMove(x,y,x2,y2,1) RandTime.randTime(1,0,0,1,9,9) return
def pickTarget(target): print '--> picking wreck' result = findTarget(target) if not result: return False mouse.doubleClickAtP(result) print 'wait until cargo open' result = None begin = time.time() while not result and time.time() - begin < 120: time.sleep(0.2) result = findAtFull('loot_all') if not result: return False mouse.leftClickAtP(result) time.sleep(2) result = findAtFull('x') if not result: return False mouse.leftClickAtP(result) print '<-- picking wreck\n' return True
def undock(): print '--> undock' result = findAtMenu('undock') if not result: return False mouse.leftClickAtP(result) mouse.moveTo(result[0] + 200, result[1]) print 'wait until undock' while findAtMenu('undock'): time.sleep(0.5) print 'wait until entering space' begin = time.time() while not findAtProgressBar('entering_space') and time.time() - begin < 10: time.sleep(0.1) time.sleep(3) print '<-- undock\n' return True
def seekAndDestory(): switchTo('battle') print '--> seek and destory' while not findAtMissionDetails('v'): # if findAtDrones('fighting'): # time.sleep(5) # elif lockEnemy(): if lockEnemy(): mouse.moveTo(200, 200) time.sleep(10) ship.approach() ship.fireOnce() time.sleep(5) else: break print '<-- seek and destory\n' return True
def initialize(self): ''' It's better to call this method after create all objects''' self.timeNow = now.time() if self.frame : print('Frame already created') else : self.frame = Frame.Frame(self) self.updateScreen() self.mouse = Mouse.Mouse(self) self.keyboard = Keyboard.Keyboard(self) self.running = True
def backToAgentStation(): print '--> back to agent station' if setMissionWaypoint(): pilot.autopilot() else: result = findAtInfo('dock') while not result: result = findAtInfo('dock') time.sleep(0.5) mouse.leftClickAtP(result) exitStarMap() print 'wait until reach station' time.sleep(10) while not findAtMenu('undock'): time.sleep(1) time.sleep(4) print '<-- back to agent station\n' return True
def setMissionWaypoint(retry = False): print '--> set mission waypoint' enterStarMap() openMissionMenu() while True: result = findAtInfo('set_destination') if not result and not retry: return False elif not result: time.sleep(1) mouse.leftClickAtP(panel.center(panel.Full)) else: break mouse.leftClickAtP(result) exitStarMap() print '<-- set mission waypoint\n' return True
def init(): print("Move cursor to top left corner of canvas!") countdown(1) canvasTopLeft = Mouse.getPosition() print("Top-Left corner:", canvasTopLeft) print("Move cursor to bottom right corner of canvas!") countdown(1) Skribbler.bottomRight = Skribbler.getPosition() print("Bottom-Right corner:", Sketch.bottomRight) Skribbler.width = Skribbler.bottomRight[0] - Skribbler.topLeft[0] Skribbler.height = Skribbler.bottomRight[1] - Skribbler.topLeft[1] print("Canvas-Dimensions:", Skribbler.width, Skribbler.height)
def main(): cursor = Mouse.cursor()#Create a cursor object, which controls the cursor position, clicking, etc listener = LeapFunctions.Listener(cursor)#Create a custom listener object which controls the cursor controller = Leap.Controller()#Get a Leap controller print "Adding Listener." controller.add_listener(listener)#Attach the listener # Keep this process running until Enter is pressed print "Press Enter to quit..." sys.stdin.readline() # Remove the sample listener when done controller.remove_listener(listener)
def setQuantity(self, quantity): # found = [217,200,217,200] found = [ 199, 181, 199 + GC.offer_button_dimensions[0], 181 + GC.offer_button_dimensions[1] ] found_coord = [ self.self_window_coord[0] + found[0], self.self_window_coord[1] + found[1], self.self_window_coord[0] + found[2], self.self_window_coord[1] + found[3] ] # crop = Screenshot.crop(self.global_rs_image, found_coord) # cv2.imwrite(r'C:\Users\PPC\git\RS_BOT_2.0\aaaaacrop.png', crop) Mouse.clickRadius( self._calculateGlobalCoord(self.global_rs_coord, found_coord)) # Mouse.win32ClickRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord)) # Mouse.win32MoveToRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord)) RandTime.randTime(0, 0, 0, 2, 0, 0) Keyboard.type_this(quantity) Keyboard.press("enter")
def checkBoxCheck(self, fromPage, toPage): buttonImg = str(fromPage) + 'To' + str(toPage) + 'CheckBox.png' min_val, max_val, min_loc, max_loc = util.getCvImagePosOfCvImage( self.imageSet[buttonImg]["img"], self.page.wShoot) if max_val < self.page.judgeValue: return None else: wLeft, wTop, wRight, wBottom = self.page.windowPos iX, iY = max_loc print((wLeft, wTop, wRight, wBottom)) mouseTask = Mouse.MouseTask( "click", "left", self.page.hW, { "pos": (wLeft + iX + self.page.windowOffest[0], wTop + iY + self.page.windowOffest[1] + int(self.imageSet[buttonImg]["size"][0] / 2)) }) self.mouse.addMouseTask(mouseTask)
def main(): input("Press ENTER to start...") start_time = time.clock() products = [ Laptop.Laptop(), Desktop.Desktop(), Monitor.Monitor(), Printer.Printer(), Mouse.Mouse(), Keyboard.Keyboard() ] for product in products: product.run() print("\n{0}s".format(time.clock() - start_time))
def OnMouse(self, event): self.SetCurrent(self.context) e = Mouse.MouseEventFromWx(event) if event.controlDown: wx.GetApp().select_mode.OnMouse(e) return if event.RightDown(): self.right_down_and_no_left_clicked = True if event.LeftIsDown(): self.right_down_and_no_left_clicked = False if event.RightUp() and self.right_down_and_no_left_clicked: wx.GetApp().DoDropDownMenu(self, event.GetX(), event.GetY(), event.ControlDown()) self.right_down_and_no_left_clicked = False else: wx.GetApp().input_mode_object.OnMouse(e) event.Skip()
def back(): print '--> drones return' key.pressEx(sc.DronesReturn) mouse.moveToP(panel.center(panel.Drones)) mouse.wheel(-100) mouse.moveToP(panel.center(panel.Full)) print 'wait until drones return' while findAtDrones('returning') or findAtDrones('fighting') or findAtDrones('idle'): key.pressEx(sc.DronesReturn) time.sleep(0.2) print '<-- drones return\n' return True
def main(): print("Start !") hWList = util.findWindowList("阴阳师") mouse = Mouse.Mouse() for hW in hWList: pageInstance = Page.Page(hW) autoYuHun = AutoYuHun.AutoYuHun(pageInstance, mouse) while (True): try: print( list(pageInstance.pageType.keys())[list( pageInstance.pageType.values()).index( pageInstance.nowPage)]) except Exception as e: print(pageInstance.nowPage) print(e) time.sleep(1) print("End !")
def acceptMission(): print '--> accept mission' result = findAtMissionRight('accept') if not result: return False mouse.leftClickAtP(result) mouse.moveTo(result[0], result[1] - 80) print 'wait until accepting mission' while not findAtMissionRight('complete_mission'): time.sleep(0.2) time.sleep(0.5) result = findAtMissionRight('x') if not result: return False mouse.leftClickAtP(result) print '<-- accept mission\n' return True
def openMissionDetails(): enterStarMap() print '--> open mission detail' openMissionMenu() result = findAtInfo('read_details') while not result: result = findAtInfo('read_details') time.sleep(0.5) mouse.leftClickAtP(result) print 'wait until find mission objective' while not findAtMissionDetails('o'): mouse.leftClickAt(panel.MissionDetails[0] + 20, panel.MissionDetails[1] + 20) mouse.wheel(-20) print '<-- open mission detail\n' exitStarMap() return True
def activateShip(ship): print '--> activate ship "' + ship + '"' key.pressEx(sc.ShipHangar) time.sleep(3) result = None while not result: time.sleep(0.5) result = findAtInventory(ship) mouse.rightClickAtP(result) mouse.moveTo(result[0] + 200, result[1]) result = findAtInventory('make_active') if result: mouse.leftClickAtP(result) key.pressEx(sc.ShipHangar) time.sleep(2) print '<-- activate ship "' + ship + '"\n' return True