issues/552

This commit is contained in:
恍兮惚兮 2024-03-04 13:50:33 +08:00
parent 0a3a4ac0b4
commit ce6e69d61f
3 changed files with 20 additions and 62 deletions

View File

@ -45,6 +45,8 @@ def setTab_quick_direct(self):
"_23":lambda: gobject.baseobject.translation_ui.clickRange_signal.emit(True), "_23":lambda: gobject.baseobject.translation_ui.clickRange_signal.emit(True),
"_25":lambda: windows.SendMessage(windows.FindWindow('Magpie_Core_CLI_Message',None),windows.RegisterWindowMessage('Magpie_Core_CLI_Message_ToggleOverlay')), "_25":lambda: windows.SendMessage(windows.FindWindow('Magpie_Core_CLI_Message',None),windows.RegisterWindowMessage('Magpie_Core_CLI_Message_ToggleOverlay')),
"_26":gobject.baseobject.translation_ui.ocr_once_signal.emit,
} }
for name in globalconfig['quick_setting']['all']: for name in globalconfig['quick_setting']['all']:
if name not in self.bindfunctions: if name not in self.bindfunctions:

View File

@ -44,6 +44,7 @@ class QUnFrameWindow(resizableframeless):
hidesignal=pyqtSignal() hidesignal=pyqtSignal()
muteprocessignal=pyqtSignal() muteprocessignal=pyqtSignal()
entersignal=pyqtSignal() entersignal=pyqtSignal()
ocr_once_signal=pyqtSignal()
def hookfollowsignalsolve(self,code,other): def hookfollowsignalsolve(self,code,other):
if self._move_drag: if self._move_drag:
return return
@ -228,6 +229,15 @@ class QUnFrameWindow(resizableframeless):
self.textAreaChanged() self.textAreaChanged()
self.setMinimumHeight(int(globalconfig['buttonsize']*1.5+10)) self.setMinimumHeight(int(globalconfig['buttonsize']*1.5+10))
self.setMinimumWidth(globalconfig['buttonsize']*2) self.setMinimumWidth(globalconfig['buttonsize']*2)
def ocr_once_function(self):
@threader
def ocroncefunction(rect):
img=imageCut(0,rect[0][0],rect[0][1],rect[1][0],rect[1][1])
fname='./cache/ocr/once.png'
img.save(fname)
text=ocr_run(fname)
gobject.baseobject.textgetmethod(text,False)
rangeselct_function(self,ocroncefunction,False,False)
def addbuttons(self): def addbuttons(self):
def simulate_key_enter(): def simulate_key_enter():
windows.SetForegroundWindow(gobject.baseobject.textsource.hwnd) windows.SetForegroundWindow(gobject.baseobject.textsource.hwnd)
@ -243,13 +253,7 @@ class QUnFrameWindow(resizableframeless):
while windows.GetForegroundWindow()==gobject.baseobject.textsource.hwnd: while windows.GetForegroundWindow()==gobject.baseobject.textsource.hwnd:
time.sleep(0.001) time.sleep(0.001)
windows.keybd_event(17,0,windows.KEYEVENTF_KEYUP,0) windows.keybd_event(17,0,windows.KEYEVENTF_KEYUP,0)
@threader
def ocroncefunction(rect):
img=imageCut(0,rect[0][0],rect[0][1],rect[1][0],rect[1][1])
fname='./cache/ocr/once.png'
img.save(fname)
text=ocr_run(fname)
gobject.baseobject.textgetmethod(text,False)
functions=( functions=(
("move",None), ("move",None),
("retrans",self.startTranslater), ("retrans",self.startTranslater),
@ -283,7 +287,7 @@ class QUnFrameWindow(resizableframeless):
("copy_once",lambda:gobject.baseobject.textgetmethod(winsharedutils.clipboard_get(),False) ), ("copy_once",lambda:gobject.baseobject.textgetmethod(winsharedutils.clipboard_get(),False) ),
("open_relative_link",lambda:browserdialog(gobject.baseobject.settin_ui,gobject.baseobject.textsource) ), ("open_relative_link",lambda:browserdialog(gobject.baseobject.settin_ui,gobject.baseobject.textsource) ),
("ocr_once",lambda:rangeselct_function(self,ocroncefunction,False,False) ), ("ocr_once",self.ocr_once_signal.emit ),
("minmize",self.hide_and_disableautohide), ("minmize",self.hide_and_disableautohide),
("quit",self.close) ("quit",self.close)
) )
@ -387,6 +391,7 @@ class QUnFrameWindow(resizableframeless):
self.hideshownotauto=True self.hideshownotauto=True
self.ocr_once_signal.connect(self.ocr_once_function)
self.entersignal.connect(self.enterfunction) self.entersignal.connect(self.enterfunction)
self.displaystatus.connect(self.showstatus) self.displaystatus.connect(self.showstatus)
self.showhideuisignal.connect(self.showhideui) self.showhideuisignal.connect(self.showhideui)

View File

@ -421,190 +421,141 @@
"_A": { "_A": {
"use": false, "use": false,
"name": "选择翻译源_剪贴板", "name": "选择翻译源_剪贴板",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_B": { "_B": {
"use": false, "use": false,
"name": "选择翻译源_OCR", "name": "选择翻译源_OCR",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_C": { "_C": {
"use": false, "use": false,
"name": "选择翻译源_HOOK", "name": "选择翻译源_HOOK",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_1": { "_1": {
"use": false, "use": false,
"name": "重新翻译", "name": "重新翻译",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_2": { "_2": {
"use": false, "use": false,
"name": "自动翻译", "name": "自动翻译",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_3": { "_3": {
"use": false, "use": false,
"name": "打开设置", "name": "打开设置",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_4": { "_4": {
"use": false, "use": false,
"name": "复制到剪贴板", "name": "复制到剪贴板",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_5": { "_5": {
"use": false, "use": false,
"name": "显示/隐藏原文", "name": "显示/隐藏原文",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_6": { "_6": {
"use": false, "use": false,
"name": "显示/隐藏历史翻译和调试输出", "name": "显示/隐藏历史翻译和调试输出",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_7": { "_7": {
"use": false, "use": false,
"name": "朗读", "name": "朗读",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_8": { "_8": {
"use": false, "use": false,
"name": "鼠标穿透窗口", "name": "鼠标穿透窗口",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_9": { "_9": {
"use": false, "use": false,
"name": "锁定工具栏", "name": "锁定工具栏",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_10": { "_10": {
"use": false, "use": false,
"name": "打开保存的游戏", "name": "打开保存的游戏",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_11": { "_11": {
"use": false, "use": false,
"name": "选择游戏", "name": "选择游戏",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_12": { "_12": {
"use": false, "use": false,
"name": "选择文本", "name": "选择文本",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_13": { "_13": {
"use": false, "use": false,
"name": "选取OCR范围", "name": "选取OCR范围",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_14": { "_14": {
"use": false, "use": false,
"name": "显示/隐藏范围框", "name": "显示/隐藏范围框",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_15": { "_15": {
"use": false, "use": false,
"name": "绑定截图窗口", "name": "绑定截图窗口",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_16": { "_16": {
"use": false, "use": false,
"name": "显示/隐藏翻译窗口", "name": "显示/隐藏翻译窗口",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_17": { "_17": {
"use": false, "use": false,
"name": "退出", "name": "退出",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_18": { "_18": {
"use": false, "use": false,
"name": "字体增大(可长按)", "name": "字体增大(可长按)",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_19": { "_19": {
"use": false, "use": false,
"name": "字体缩小(可长按)", "name": "字体缩小(可长按)",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_20": { "_20": {
"use": false, "use": false,
"name": "缩放/恢复游戏窗口", "name": "缩放/恢复游戏窗口",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_21": { "_21": {
"use": false, "use": false,
"name": "前景窗口截屏", "name": "前景窗口截屏",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_22": { "_22": {
"use": false, "use": false,
"name": "游戏静音", "name": "游戏静音",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_23": { "_23": {
"use": false, "use": false,
"name": "选取OCR范围——立即", "name": "选取OCR范围——立即",
"key1": -1,
"key2": -1,
"keystring": "" "keystring": ""
}, },
"_25": { "_25": {
"use": false, "use": false,
"name": "Magpie_游戏内叠加层", "name": "Magpie_游戏内叠加层",
"key1": -1, "keystring": ""
"key2": -1, },
"_26": {
"use": false,
"name": "进行一次OCR",
"keystring": "" "keystring": ""
} }
} }