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


Python pyautogui.screenshot函数代码示例

本文整理汇总了Python中pyautogui.screenshot函数的典型用法代码示例。如果您正苦于以下问题:Python screenshot函数的具体用法?Python screenshot怎么用?Python screenshot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: screen_shot

def screen_shot(left_corner=None, right_corner=None):
    if (left_corner is not None) and (right_corner is not None):
        region=(left_corner[0],left_corner[1],right_corner[0]-left_corner[0],right_corner[1]-left_corner[1])
        pil_image = pyautogui.screenshot(region=region)
    else:
        pil_image = pyautogui.screenshot()
    opencv_image = cv2.cvtColor(np.array(pil_image), cv2.COLOR_RGB2BGR)
    return opencv_image
开发者ID:sedlamat,项目名称:Game_BM,代码行数:8,代码来源:game_bm.py

示例2: screenshot

	def screenshot(self):
		self.fmaximizeUO()
		if self.os == "Linux":
			command("import -window $(xdotool getwindowfocus -f) /tmp/screen.png & xdotool click 1")
			return "/tmp/screen.png"
		elif self.os == "Windows":
			pyautogui.screenshot("C:\\Windows\\Temp\\screen.png")
			return "C:/Windows/Temp/screen.png"
开发者ID:ZDDM,项目名称:Voyageur-chan,代码行数:8,代码来源:bot.py

示例3: func

        def func():
            self.screenshot_button.config(state='disabled')

            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Deselect the game window %s' % second)
                if second != 0:
                    time.sleep(1)

            region = []
            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place the mouse at the top left\nof the game\'s title bar %s' % second)
                if second != 0:
                    time.sleep(1)
            constant_top_left = pyautogui.position()
            region.extend(constant_top_left)
            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place the mouse at the bottom right\nof the game\'s title bar %s' % second)
                if second != 0:
                    time.sleep(1)
            constant_bottom_right = pyautogui.position()
            region.extend(
                (constant_bottom_right[0] - constant_top_left[0],
                 constant_bottom_right[1] - constant_top_left[1])
            )
            self.deselected_screenshot = pyautogui.screenshot(region=region)
            pyautogui.click()
            self.selected_screenshot = pyautogui.screenshot(region=region)

            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place mouse at the top left\nof the entire game window %s' % second)
                if second != 0:
                    time.sleep(1)
            top_left = pyautogui.position()
            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place mouse at the bottom right\nof the entire game window %s' % second)
                if second != 0:
                    time.sleep(1)
            bottom_right = pyautogui.position()

            self.screen_size = [
                constant_top_left[0] - top_left[0],
                constant_top_left[1] - top_left[1],
                bottom_right[0] - constant_bottom_right[0],
                bottom_right[1] - constant_bottom_right[1]
            ]

            self.screenshot_taken = True
            self.screenshot_label.config(text='Screenshot Taken')
            self.screenshot_button.config(
                state='normal', text='Retake Screenshot')
开发者ID:jaronoff97,项目名称:play_as_one,代码行数:55,代码来源:PlayAsOne.py

示例4: checkItem

 def checkItem(self, x, y, img=None):
     pyautogui.moveTo(x, y, duration=0.1)
     pyautogui.moveTo(x+1, y, duration=0.1)
     pyautogui.moveTo(x, y, duration=0.1)
     im = pyautogui.screenshot(region=(0, 0, 800, 600))
     if img is not None:
         # TODO check they are not the same
         pass
     time.sleep(0.1)
     return im
开发者ID:artofboom,项目名称:fmbot,代码行数:10,代码来源:char.py

示例5: click

 def click(self, x, y, button, press):
     if button == 1:
         if press:
             self.a.append(self.m.position())
             if(len(self.a) == 2):
                 #print(self.a)
                 x1,y1,x2,y2 = self.a[0][0],self.a[0][1],self.a[1][0],self.a[1][1]
                 pyautogui.screenshot('C:/Python27/output.png',(x1,y1,x2-60,y2-150))
                 self.a = []
                 self.stop()
     else:  # Exit if any other mouse button used
         self.stop()
开发者ID:sahil865gupta,项目名称:Tuts-Robo,代码行数:12,代码来源:click.py

示例6: screenCapture

def screenCapture(savePath):
    global SAVE_SCREEN_MAP_PATH
    # hwnd = 0
    # hwndDC = win32gui.GetWindowDC(hwnd)
    # mfcDC=win32ui.CreateDCFromHandle(hwndDC)
    # saveDC=mfcDC.CreateCompatibleDC()
    # saveBitMap = win32ui.CreateBitmap()
    # saveBitMap.CreateCompatibleBitmap(mfcDC, size[0], size[1])
    # saveDC.SelectObject(saveBitMap)
    # saveDC.BitBlt((0,0),SCREEN_SIZE, mfcDC, SCREEN_POS, win32con.SRCCOPY)
    # saveBitMap.SaveBitmapFile(saveDC,SAVE_SCREEN_MAP_PATH)
    # Image.open(SAVE_SCREEN_MAP_PATH).save(SAVE_SCREEN_MAP_PATH[:-4]+".png")
    pyautogui.screenshot(SAVE_SCREEN_MAP_PATH)
开发者ID:fengxxx,项目名称:ImagePin,代码行数:13,代码来源:_imagePinUtil.py

示例7: shoot

def shoot(x1,y1,x2,y2, *args, **kwargs):
    """Takes screenshot at given coordinates as PIL image format, the converts to cv2 grayscale image format and returns it"""
    # creates widht & height for screenshot region
    w = x2 - x1
    h = y2 - y1
    # PIL format as RGB
    img = pyautogui.screenshot(region=(x1,y1,w,h)) #X1,Y1,X2,Y2
    #im.save('screenshot.png')

    # Converts to an array used for OpenCV
    img = np.array(img)

    try:
        for arg in args:
            if arg == 'hsv':
                # Converts to BGR format for OpenCV
                img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
                hsv_img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
                return hsv_img

            if arg == 'rgb':
                rgb_img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
                return rgb_img
    except:
        pass

    cv_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    return cv_gray
开发者ID:jjvilm,项目名称:osrmacro,代码行数:28,代码来源:Screenshot.py

示例8: screenshotThread

def screenshotThread():
    OOO="                                           "
    global req
    global alive
    printer.p(OOO+"screenshotThread === checking in...")
    n=0
    while alive:
        #if time.time()-start>20: alive=False #autorestart
        if myID==IDcheck and req==1:
            #pyautogui.screenshot("screenshot.png")
            img=pyautogui.screenshot()
            try:
                img.save(abspath+"screenshot.jpg", "JPEG", quality=0, optimize=True, progressive=False)
                n+=1
            except:
                printer.p(OOO+"screenshotThread === couldn't save it?")
                pass
                
            try:
                files = {'media': open(abspath+'screenshot.jpg', 'rb')}
                r=requests.post('http://'+ip+'/zerog/upload.php', files=files)
                printer.p(OOO+"screenshotThread === screenshot#"+str(n))
            except:
                printer.p(OOO+"screenshotThread === couldn't upload it?")
                pass
        else: time.sleep(5)
        
    printer.p(OOO+"screenshotThread === ...checking out")
开发者ID:jayagopaldaz,项目名称:zerog,代码行数:28,代码来源:cooperate.py

示例9: locateAllOnScreen

def locateAllOnScreen(needleImg):
    # Take a screenshot image of the desktop and save it
    img = pyautogui.screenshot( "desktop.png")

    # Allow image to be saved prior to continuing
    time.sleep(5)
    
    # Allow opencv2 to read both images
    haystackImg = cv2.imread( "desktop.png")
    grayImg = cv2.cvtColor( haystackImg, cv2.COLOR_BGR2GRAY)
    needleImg = cv2.imread( needleImg ,0)
    width , height = needleImg.shape[::-1]
    
    # Use thresholding to find multiple matches
    res = cv2.matchTemplate( grayImg, needleImg, cv2.TM_CCOEFF_NORMED)
    threshold = 0.8
    matchCoords = np.where( res >= threshold)
    
    #Uncomment to view the rectangular match regions
    #for pt in zip(*matchCoords[::-1]):
    #    cv2.rectangle( haystackImg, pt, (pt[0] + width, pt[1] + height), (0,0,255), 2)
    
    # Save the resulting image as a png image
    #cv2.imwrite('result.png', haystackImg )

    return matchCoords
开发者ID:Astroua,项目名称:CARTAvis,代码行数:26,代码来源:ImageUtil.py

示例10: color_height

def color_height(measure_start):
    screenshot = pyautogui.screenshot()
    height = 0
    start_color = screenshot.getpixel((measure_start))
    while screenshot.getpixel((measure_start[0] + height, measure_start[1])) == start_color:
        height += 1
    return height
开发者ID:JacobTheEldest,项目名称:galaxies-solver,代码行数:7,代码来源:gui_recognition.py

示例11: cv2_match

def cv2_match(tmp, threshold=0.8, grayscale="auto"):
    if grayscale == "auto":
        if len(tmp.shape) == 2:
            grayscale = True
        else:
            grayscale = False
    q = p.screenshot()
    w = cv2.cvtColor(np.array(q), cv2.COLOR_RGB2BGR)
    if grayscale:
        w = cv2.cvtColor(w, cv2.COLOR_BGR2GRAY)
        if len(tmp.shape) >= 3:
            tmp = cv2.cvtColor(tmp, cv2.COLOR_BGR2GRAY)
    else:
        if len(tmp.shape) < 3:
            tmp = cv2.cvtColor(tmp, cv2.COLOR_GRAY2BGR)
    res = cv2.matchTemplate(w, tmp, cv2.TM_CCOEFF_NORMED)
    res = np.where(res > threshold)
    dis = min(tmp.shape[:2]) / 2
    l = int(tmp.shape[1] / 2)
    h = int(tmp.shape[0] / 2)
    result = []
    for i in range(len(res[0])):
        pos = (res[1][i] + l, res[0][i] + h)
        flag = True
        for j in result:
            if get_dis(pos, j) < dis:
                flag = False
                break
        if flag:
            result.append(pos)
    return result
开发者ID:qzane,项目名称:wanga.me,代码行数:31,代码来源:main.py

示例12: color_width

def color_width(measure_start):
    screenshot = pyautogui.screenshot()
    width = 0
    start_color = screenshot.getpixel((measure_start))
    while screenshot.getpixel((measure_start[0] + width, measure_start[1])) == start_color:
        width += 1
    return width
开发者ID:JacobTheEldest,项目名称:galaxies-solver,代码行数:7,代码来源:gui_recognition.py

示例13: Start

def Start(pos):
    pyautogui.FAILSAFE = False
    global root, running
    im=pyautogui.screenshot()
    pos['text']=str(pyautogui.position())
    rgb['text']=str(im.getpixel(pyautogui.position()))
    root.update_idletasks()
    root.after(10, lambda:Start(pos))
开发者ID:tushutripathi,项目名称:posRGB,代码行数:8,代码来源:posRGB.py

示例14: read

 def read(self):
     img = pyautogui.screenshot()
     if self.bbox:
         img = img.crop(self.bbox)
     img = np.asarray(img)
     img = cv2.resize(img, (self.width, self.height))
     img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
     return (self._is_opened, img)
开发者ID:ExceptionError,项目名称:resultoon,代码行数:8,代码来源:capture.py

示例15: screenShot

def screenShot():
	"""function for the taking the screen shot of current window"""
	BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
	img_path = os.path.join(BASE_DIR,r'raw_data\screenshot')
	#print img_path
	img_name = '{0}_{1}.{2}'.format('screnshot',time.strftime('%d%m%y_%I%M%S'),'jpg')
	im1 =pyautogui.screenshot(os.path.join(img_path,img_name))
	voiceOut.Speak("your screen is successfully captured")
	return
开发者ID:ShivaGuntuku,项目名称:Jarvis,代码行数:9,代码来源:simpleScript.py


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