コード例 #1
0
ファイル: bot.py プロジェクト: highkite/alphaBot
def run(handleOK=False, debug=False):
	"""
	Runs the bot
	"""

	print english.produce_fuel
	coordinate = mapExtractor.getFuelstation()

	if None == coordinate:
		raise ValueError("Map positions are not initialized")

	print english.move_mouse_to_browser
	print english.start_in 
	alphaBotUtility.countDownwards(5)

	infix = datetime.datetime.now().strftime("%d-%m-%y_%H-%M-%S")

	currentRun = 0

	while True:

		currentReport = report.Report()

		if handleOK:
			clickOK()

		backgroundLayerPath = captchaExtractor.extractBackgroundLayer(coordinate[0], coordinate[1], nameInfix=infix)
		currentReport.setBackgroundLayer(backgroundLayerPath)

		# move to factory
		autopy.mouse.smooth_move(coordinate[0], coordinate[1])

		# extract capture
		captchaPath = captchaExtractor.extractCaptcha(coordinate[0], coordinate[1], nameInfix=infix)
		currentReport.setCaptcha(captchaPath)
		
		delta_x = None
		delta_y = None 

		(delta_x, delta_y) = tetragonDetector.findTetragonLineBased(captchaPath, report=currentReport, backgroundLayerPath=backgroundLayerPath, _debug=False)

		if not None == delta_x and not None == delta_y:
			target_x = int(coordinate[0] - 50 + delta_x)
			target_y = int(coordinate[1] + delta_y)

		currentReport.setTargetCoordinates(delta_x, delta_y)

		# move the mouse to prevent the blackening of the screen
		autopy.mouse.smooth_move(coordinate[0]-random.randint(0,100), coordinate[1]-random.randint(0,100))

# move to detected tetragon and click
		if not None == delta_x and not None == delta_y:
			clickCoordinate(target_x, target_y)

		currentReport.save("report_" + str(currentRun) + ".txt")
		currentRun += 1

# wait 60 seconds
		alphaBotUtility.countDownwards(60)
コード例 #2
0
def run(handleOK=False, debug=False):
    """
	Runs the bot
	"""

    print english.produce_fuel
    coordinate = mapExtractor.getFuelstation()

    if None == coordinate:
        raise ValueError("Map positions are not initialized")

    print english.move_mouse_to_browser
    print english.start_in
    alphaBotUtility.countDownwards(5)

    infix = datetime.datetime.now().strftime("%d-%m-%y_%H-%M-%S")

    currentRun = 0

    while True:

        currentReport = report.Report()

        if handleOK:
            clickOK()

        backgroundLayerPath = captchaExtractor.extractBackgroundLayer(
            coordinate[0], coordinate[1], nameInfix=infix)
        currentReport.setBackgroundLayer(backgroundLayerPath)

        # move to factory
        autopy.mouse.smooth_move(coordinate[0], coordinate[1])

        # extract capture
        captchaPath = captchaExtractor.extractCaptcha(coordinate[0],
                                                      coordinate[1],
                                                      nameInfix=infix)
        currentReport.setCaptcha(captchaPath)

        delta_x = None
        delta_y = None

        (delta_x, delta_y) = tetragonDetector.findTetragonLineBased(
            captchaPath,
            report=currentReport,
            backgroundLayerPath=backgroundLayerPath,
            _debug=False)

        if not None == delta_x and not None == delta_y:
            target_x = int(coordinate[0] - 50 + delta_x)
            target_y = int(coordinate[1] + delta_y)

        currentReport.setTargetCoordinates(delta_x, delta_y)

        # move the mouse to prevent the blackening of the screen
        autopy.mouse.smooth_move(coordinate[0] - random.randint(0, 100),
                                 coordinate[1] - random.randint(0, 100))

        # move to detected tetragon and click
        if not None == delta_x and not None == delta_y:
            clickCoordinate(target_x, target_y)

        currentReport.save("report_" + str(currentRun) + ".txt")
        currentRun += 1

        # wait 60 seconds
        alphaBotUtility.countDownwards(60)
コード例 #3
0
def showImageProcessing():
	print "Executing:"
	print "print str(findTetragonLineBased(\"" + str(captcha) + "\", backgroundLayerPath=\"" + str(bgLayer) + "\", report=None, _debug=True))"
	tetragonDetector.findTetragonLineBased(captcha, report=None, backgroundLayerPath=bgLayer, _debug=True)