Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to drag a box on your screen python

import win32gui
import win32ui
import win32con
import win32api

def saveScreenShot(x,y,width,height,path):
    # grab a handle to the main desktop window
    hdesktop = win32gui.GetDesktopWindow()

    # create a device context
    desktop_dc = win32gui.GetWindowDC(hdesktop)
    img_dc = win32ui.CreateDCFromHandle(desktop_dc)

    # create a memory based device context
    mem_dc = img_dc.CreateCompatibleDC()

    # create a bitmap object
    screenshot = win32ui.CreateBitmap()
    screenshot.CreateCompatibleBitmap(img_dc, width, height)
    mem_dc.SelectObject(screenshot)


    # copy the screen into our memory device context
    mem_dc.BitBlt((0, 0), (width, height), img_dc, (x, y),win32con.SRCCOPY)

    # save the bitmap to a file
    screenshot.SaveBitmapFile(mem_dc, path)
    # free our objects
    mem_dc.DeleteDC()
    win32gui.DeleteObject(screenshot.GetHandle())
Comment

PREVIOUS NEXT
Code Example
Python :: expecting property name enclosed in double quotes json 
Python :: cv2 pink color range 
Python :: python copy file create intermediate directories 
Python :: poisson disc python 
Python :: odoo 12 compute documentation 
Python :: what is sklearn.base 
Python :: how to add previous and next in tkinter in python 
Python :: give utton a number python 
Python :: how to add a separator in a menubar pyqt5 
Python :: addDataToExp() psychopy 
Python :: schedule a function python inside tkinter loop 
Python :: loaves 
Python :: why am i not able to import wtf flask 
Python :: java sript 
Python :: how to mine bitcoin in python 
Python :: how to save an object in python to disk 
Python :: monoamine oxidase inhibitor 
Python :: tuto date and time python 
Python :: Add up the elements in this RDD 
Python :: reference other libraries in library 
Python :: pandas drop a list of rows 
Python :: using list comprehension to filter out age group pandas 
Python :: r value on poly fit python 
Python :: Recursively find the factorial of a natural number. 
Python :: keepalive_requests 
Python :: select option from dropdown in selenium python 
Python :: pip django graphql 
Python :: tkinter set widht 
Python :: response.url SSL warning python 
Python :: numpy rolling 2d 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =