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),
"_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']:
if name not in self.bindfunctions:

View File

@ -44,6 +44,7 @@ class QUnFrameWindow(resizableframeless):
hidesignal=pyqtSignal()
muteprocessignal=pyqtSignal()
entersignal=pyqtSignal()
ocr_once_signal=pyqtSignal()
def hookfollowsignalsolve(self,code,other):
if self._move_drag:
return
@ -228,6 +229,15 @@ class QUnFrameWindow(resizableframeless):
self.textAreaChanged()
self.setMinimumHeight(int(globalconfig['buttonsize']*1.5+10))
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 simulate_key_enter():
windows.SetForegroundWindow(gobject.baseobject.textsource.hwnd)
@ -243,13 +253,7 @@ class QUnFrameWindow(resizableframeless):
while windows.GetForegroundWindow()==gobject.baseobject.textsource.hwnd:
time.sleep(0.001)
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=(
("move",None),
("retrans",self.startTranslater),
@ -283,7 +287,7 @@ class QUnFrameWindow(resizableframeless):
("copy_once",lambda:gobject.baseobject.textgetmethod(winsharedutils.clipboard_get(),False) ),
("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),
("quit",self.close)
)
@ -387,6 +391,7 @@ class QUnFrameWindow(resizableframeless):
self.hideshownotauto=True
self.ocr_once_signal.connect(self.ocr_once_function)
self.entersignal.connect(self.enterfunction)
self.displaystatus.connect(self.showstatus)
self.showhideuisignal.connect(self.showhideui)

View File

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