forked from sandboxdream/AI-Vtuber
-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #701 from Ikaros-521/owner
新增 图像识别 板块,使用多模态模型(Gemini)的能力实现,暂时仅支持n秒后截图识别内容,未来会继续拓展
- Loading branch information
Showing
8 changed files
with
309 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import pygetwindow as gw | ||
import pyautogui | ||
|
||
def capture_window_by_title(window_title): | ||
try: | ||
# 使用窗口标题查找窗口 | ||
win = gw.getWindowsWithTitle(window_title)[0] # 获取第一个匹配的窗口 | ||
if win: | ||
# 获取窗口的位置和大小 | ||
left, top = win.left, win.top | ||
width, height = win.width, win.height | ||
|
||
# 使用pyautogui捕获指定区域的截图 | ||
screenshot = pyautogui.screenshot(region=(left, top, width, height)) | ||
screenshot.save(f'{window_title}.png') | ||
print(f"截图已保存为 {window_title}.png") | ||
else: | ||
print("未找到指定的窗口") | ||
except IndexError: | ||
print("未找到指定的窗口") | ||
|
||
|
||
# 获取所有有标题的窗口对象 | ||
def list_visible_windows(): | ||
"""获取所有有标题的窗口对象 | ||
Returns: | ||
list: 获取所有有标题的窗口名列表 | ||
""" | ||
windows = gw.getWindowsWithTitle('') | ||
|
||
window_titles = [] | ||
|
||
# 打印每个窗口的标题 | ||
for win in windows: | ||
if win.title: # 确保窗口有标题 | ||
window_titles.append(win.title) | ||
|
||
return window_titles | ||
|
||
# 调用函数,列出所有可见窗口的标题 | ||
list_visible_windows() | ||
|
||
# 调用函数,替换"Your Window Title Here"为你想要捕获的窗口的标题 | ||
capture_window_by_title("伊卡酱 fans群等3个会话") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters