xbot.win32.Screenshot

概述

Screenshot是截图接口,主要功能是对窗口或屏幕进行截图,并将结果保存到指定路径下或将结果添加到剪切板中

详情

save_screen_to_clipboard

对屏幕进行截图,并将截图结果添加到剪切板中

save_screen_to_clipboard()

参数

返回值

实列1

将屏幕截图添加到剪切板中

from xbot import win32

def main(args):
    win32.screenshot.save_screen_to_clipboard()

save_screen_to_file

对屏幕进行截图,并将结果以指定格式保存到指定路径下

save_screen_to_file(image_path, image_format)

参数

  • image_path:截图保存完整路径, 如 c:\123.jpg

  • image_format:截图保存的文件格式, 如png、jpg等

返回值

实列1

对屏幕截图,并将结果命名为 123.png 保存在D盘根目录下

from xbot import win32

def main(args):
    win32.screenshot.save_screen_to_file('D:\\123.png', 'png')

save_window_to_clipboard

对窗口截图并将图片添加到剪切板, 句柄为0则选择当前激活的窗口

save_window_to_clipboard(hwnd)

参数

  • hwnd, 目标窗口的句柄,如果不传则默认对当前选中的窗口进行截图

返回值

示例1

对句柄为 0x040C08 的窗口进行截图,并将结果添加到剪切板中

from xbot import win32

def main(args):
    win32.screenshot.save_window_to_clipboard(0x040C08)

save_window_to_file

对窗口截图并将图片保存到本地

save_window_to_file(hwnd, image_path, image_format)

参数

  • hwnd:目标窗口的句柄, 句柄为0则选择当前激活的窗口

  • image_path:截图保存完整路径, 如 c:\123.jpg

  • image_format:截图保存的文件格式, 如png、jpg等

返回值

实列1

对句柄为 0x040C08 的窗口进行截图,并将结果命名为 123.png 保存到D盘根目录下

from xbot import win32

def main(args):
    win32.screenshot.save_window_to_file(0x040C08, 'D:\\123.png', 'png')
问题没有解决?去社区提问 all right reserved,powered by Gitbook

results matching ""

    No results matching ""