Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增了是否开启多显示器上截屏的设置开关 #392

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/setting_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,12 @@ def __initCard(self):
self.tr("游戏刷新时间"),
self.tr("用于循环运行及判断任务状态,默认凌晨四点"),
)
self.allScreensCard = SwitchSettingCard1(
FIF.ZOOM,
self.tr('在多显示器上进行截屏'),
"默认开启,如果正在使用多显示器且无法正常截屏请开关闭这个",
"all_screens"
)

self.NotifyGroup = SettingCardGroup(self.tr("消息推送"), self.scrollWidget)
self.testNotifyCard = PrimaryPushSettingCard(
Expand Down Expand Up @@ -701,6 +707,7 @@ def __initLayout(self):
self.ProgramGroup.addSettingCard(self.playAudioCard)
self.ProgramGroup.addSettingCard(self.powerLimitCard)
self.ProgramGroup.addSettingCard(self.refreshHourEnableCard)
self.ProgramGroup.addSettingCard(self.allScreensCard)

self.NotifyGroup.addSettingCard(self.testNotifyCard)
self.NotifyGroup.addSettingCard(self.notifyTemplateCard)
Expand Down
3 changes: 3 additions & 0 deletions assets/config/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ refresh_hour: 4 # 设置游戏每日刷新的时间(24小时制)。
# 游戏内秘技按键设置
hotkey_technique: e # 设置游戏内使用秘技的按键。

# 是否在多显示器上进行截屏(若开启无法正确运行请关闭)
all_screens: true

# 更新配置
redemption_code: [] # 兑换码列表
update_prerelease_enable: false # 是否加入预览版更新渠道。true 加入,false 不加入。
Expand Down
12 changes: 8 additions & 4 deletions module/automation/screenshot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pyautogui
import win32gui
from desktopmagic.screengrab_win32 import getDisplayRects

from module.config import cfg

class Screenshot:
@staticmethod
Expand Down Expand Up @@ -44,15 +44,19 @@ def take_screenshot(title, crop=(0, 0, 1, 1)):
window = Screenshot.get_window(title)
if window:
left, top, width, height = Screenshot.get_window_region(window)

offset_x, offset_y = Screenshot.get_main_screen_location()

all_screens = cfg.all_screens
if all_screens:
offset_x, offset_y = Screenshot.get_main_screen_location()
else:
offset_x, offset_y = 0,0

screenshot = pyautogui.screenshot(region=(
int(left + width * crop[0] + offset_x),
int(top + height * crop[1] + offset_y),
int(width * crop[2]),
int(height * crop[3])
), allScreens=True)
), allScreens=all_screens)

real_width, _ = Screenshot.get_window_real_resolution(window)
if real_width > 1920:
Expand Down