当前位置: 首页>>代码示例>>Python>>正文


Python pyautogui.click方法代码示例

本文整理汇总了Python中pyautogui.click方法的典型用法代码示例。如果您正苦于以下问题:Python pyautogui.click方法的具体用法?Python pyautogui.click怎么用?Python pyautogui.click使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyautogui的用法示例。


在下文中一共展示了pyautogui.click方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handleCommand

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def handleCommand(command, keyPosition):
                global freePongActive
                if command == 'FIRE':
                    print("fire, clicking mouse")
                    # Line below change to what control you want to assign to the premium button.
                    pyautogui.click(button='right')
                if command == 'FREE_FIRE':
                    print("processing fire")
                    if not freePongActive:
                        freePongActive = True
                        print("free pong fire was enabled")
                        # Line below change to what control you want to assign to free button.
                        pyautogui.click(button='right')
                        print("free ping pong", freePongActive)
                        # Time delay you want in seconds between when they can free fire.
                        time.sleep(10)
                        freePongActive = False
                    else:
                        print("ping pong not enabled") 
开发者ID:robotstreamer,项目名称:robotstreamer,代码行数:21,代码来源:mac_interface.py

示例2: open_firefox

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def open_firefox():

    # Printing basic message
    msg(1,'Opening Firefox...')

    # Location the start button
    _start_button_=pyautogui.locateOnScreen('images/start_button.png')
    _location_=pyautogui.center(_start_button_)

    # Clicking the start button
    if not  pyautogui.click(_location_):
        msg(1,'Opened start menu successfully!')
    else:
        msg(3,'Failed to open start menu!')
        ext()

    time.sleep(2)

    # Search for Firefox in the menu search
    pyautogui.typewrite('firefox')
    pyautogui.typewrite('\n')
    
    # Print message
    msg(1,'Firefox is now open and running.')


# Function used to locate GMail 
开发者ID:unix121,项目名称:gmail-generator,代码行数:29,代码来源:gmail_generator.py

示例3: _click_to_the_direction_of

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def _click_to_the_direction_of(self, direction, location, offset,
                                   clicks, button, interval):
        x, y = self._get_location(direction, location, offset)
        try:
            clicks = int(clicks)
        except ValueError:
            raise MouseException('Invalid argument "%s" for `clicks`')
        if button not in ['left', 'middle', 'right']:
            raise MouseException('Invalid button "%s" for `button`')
        try:
            interval = float(interval)
        except ValueError:
            raise MouseException('Invalid argument "%s" for `interval`')

        LOGGER.info('Clicking %d time(s) at (%d, %d) with '
                    '%s mouse button at interval %f' % (clicks, x, y,
                                                        button, interval))
        ag.click(x, y, clicks=clicks, button=button, interval=interval) 
开发者ID:eficode,项目名称:robotframework-imagehorizonlibrary,代码行数:20,代码来源:__init__.py

示例4: adjust_click_position

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def adjust_click_position(click_x, click_y, window_width, window_height, dest_x, dest_y, dest_width, dest_height):
	# get screen size
	screen_width, screen_height = pyautogui.size()
	if screen_width > window_width and screen_height > window_height:
		# fit position to destination size
		new_x, new_y = fit_position_to_destination(click_x, click_y, window_width, window_height, dest_width, dest_height)
		#print('new_x: %d, new_y: %d, dest_x: %d, dest_y: %d' % (new_x, new_y, dest_x, dest_y))
		# scale to screen
		x = new_x + dest_x
		y = new_y + dest_y
	else:
		x = click_x
		y = click_y
	return (x, y)

# Perform a simple click or double click on x, y position 
开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:18,代码来源:tools.py

示例5: _Input

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def _Input(mousex=0, mousey=0, click=0, keys=None, delay='0.2'):
    import pyautogui
    '''Control the user's mouse and/or keyboard.
       Arguments:
         mousex, mousey - x, y co-ordinates from top left of screen
         keys - list of keys to press or single key
    '''
    g = Globals()
    screenWidth, screenHeight = pyautogui.size()
    mousex = int(screenWidth / 2) if mousex == -1 else mousex
    mousey = int(screenHeight / 2) if mousey == -1 else mousey
    exit_cmd = [('alt', 'f4'), ('ctrl', 'shift', 'q'), ('command', 'q')][(g.platform & -g.platform).bit_length() - 1]

    if keys:
        if '{EX}' in keys:
            pyautogui.hotkey(*exit_cmd)
        else:
            pyautogui.press(keys, interval=delay)
    else:
        pyautogui.moveTo(mousex, mousey)
        if click:
            pyautogui.click(clicks=click)

    Log('Input command: Mouse(x={}, y={}, click={}), Keyboard({})'.format(mousex, mousey, click, keys)) 
开发者ID:Sandmann79,项目名称:xbmc,代码行数:26,代码来源:playback.py

示例6: locate_gmail

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def locate_gmail():
    
    #Sleep for a while and wait for Firefox to open
    time.sleep(3)

    # Printing message
    msg(1,'Opening Gmail...')

    # Typing the website on the browser
    pyautogui.keyDown('ctrlleft');  pyautogui.typewrite('a'); pyautogui.keyUp('ctrlleft')
    pyautogui.typewrite('https://accounts.google.com/SignUp?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ltmpl=default')
    pyautogui.typewrite('\n')
    
    # Wait for a while until the website responds
    time.sleep(6)

    # Print a simple message
    msg(1,'Locating the form...')

    # Locate the form
    pyautogui.press('tab')
 
    time.sleep(2)

    _gmail_ = pyautogui.locateOnScreen('images/gmail_form.png')
    formx, formy = pyautogui.center(_gmail_)
    pyautogui.click(formx, formy)
    
    # Check and print message
    if not pyautogui.click(formx, formy):
        msg(1,'Located the form.')
    else:
        msg(3,'Failed to locate the form.')
        ext()


# Function used to randomize credentials 
开发者ID:unix121,项目名称:gmail-generator,代码行数:39,代码来源:gmail_generator.py

示例7: click

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def click(self):
        click(self.x, self.y) 
开发者ID:Qirky,项目名称:PyKinectTk,代码行数:4,代码来源:AutoClick.py

示例8: fromPosition

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def fromPosition():
        raw_input("Hover over the location you want to click and press enter")
        return position() 
开发者ID:Qirky,项目名称:PyKinectTk,代码行数:5,代码来源:AutoClick.py

示例9: run

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def run(self):
        while self.running:
            self.click()
            sleep(self.time_step)
            if (self.x, self.y) != position():
                self.running=False 
开发者ID:Qirky,项目名称:PyKinectTk,代码行数:8,代码来源:AutoClick.py

示例10: get_game_landscape_and_set_focus_or_die

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def get_game_landscape_and_set_focus_or_die(self, threshold=0.7) -> Dict:
        tries = 0
        landscape = None
        while not landscape:
            landscape = self.find_game_position(threshold)
            if landscape or tries == 10:
                break
            else:
                tries += 1
            time.sleep(1)
        if not landscape:
            print("Can't find the game!")
            exit(1)
        pyautogui.click(landscape['left'], landscape['top'] + landscape['height'])
        return landscape 
开发者ID:pauloalves86,项目名称:go_dino,代码行数:17,代码来源:dino_api.py

示例11: click_image

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def click_image(image, pos, action, timestamp, offset=5):
    img = cv2.imread(image)
    height, width, channels = img.shape
    pyautogui.moveTo(pos[0] + r(width / 2, offset), pos[1] + r(height / 2, offset),
                     timestamp)
    pyautogui.click(button=action) 
开发者ID:drov0,项目名称:python-imagesearch,代码行数:8,代码来源:imagesearch.py

示例12: repeat_click

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def repeat_click(cls,say, adjust_x=0, adjust_y=0, interval=0.10):
        rect =cls.find_window_movetop()
        posx = rect[0]
        posy = rect[1]

        x, y = pyautogui.position()
        x = x+adjust_x
        y = y+adjust_y
        print(x, y)
        pyautogui.click(m.ceil(x+posx), m.ceil(y+posy), clicks=say-1, interval=interval) 
开发者ID:Sunuba,项目名称:roc,代码行数:12,代码来源:Clicker.py

示例13: click

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def click(cls,coords, clicks=1, interval=1, button='left', yat=1):
        rect =cls.find_window_movetop()
        posx = rect[0]
        posy = rect[1]

        base = 0.3+random.random()*random.random()*0.9
        print(base)
        sleep(base)
        print(m.ceil(coords[0]+posx), m.ceil(coords[1]+posy))
        # print('Clicking on: (' + str(coords[0]) + ', ' + str(coords[1]) + ')')
        pyautogui.click(m.ceil(coords[0]+posx), m.ceil(coords[1]+posy), clicks, interval, button) 
开发者ID:Sunuba,项目名称:roc,代码行数:13,代码来源:Clicker.py

示例14: centerclick

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def centerclick(cls, clicks=1, interval=1, button='left', yat=1):
        rect =cls.find_window_movetop()
        posx = rect[0]
        posy = rect[1]
        w = rect[2] - posx
        h = rect[3] - posy

        # print('Clicking on: (' + str(coords[0]) + ', ' + str(coords[1]) + ')')
        pyautogui.click(m.ceil(w/2+posx), m.ceil(h/2+posy), clicks, interval, button) 
开发者ID:Sunuba,项目名称:roc,代码行数:11,代码来源:Clicker.py

示例15: click_image

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import click [as 别名]
def click_image(self, reference_image):
        '''Finds the reference image on screen and clicks it once.

        ``reference_image`` is automatically normalized as described in the
        `Reference image names`.
        '''
        center_location = self.locate(reference_image)
        LOGGER.info('Clicking image "%s" in position %s' % (reference_image,
                                                            center_location))
        ag.click(center_location)
        return center_location 
开发者ID:eficode,项目名称:robotframework-imagehorizonlibrary,代码行数:13,代码来源:_recognize_images.py


注:本文中的pyautogui.click方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。