From ac0608e849b2da738d2b7878226559bf1c544768 Mon Sep 17 00:00:00 2001 From: Hanmin Qi <512240272@qq.com> Date: Tue, 26 May 2020 17:09:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E9=80=89=E5=8F=96hook=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E7=9A=84=E5=89=AA=E8=B4=B4=E6=9D=BF=E7=9B=91=E8=A7=86?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=A4=96=E7=BD=AE=E5=88=B0=E4=B8=BB=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=85=B6=E4=B8=BA=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E5=AE=9A=E5=90=91=E5=88=B0=E5=AD=90=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9Hook=E6=A8=A1=E5=9D=97=E6=95=B4?= =?UTF-8?q?=E4=BD=93=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MisakaTranslator-WPF/GameGuideWindow.xaml.cs | 31 ++++++++++++++++--- .../GuidePages/Hook/ChooseHookFuncPage.xaml | 6 +++- .../Hook/ChooseHookFuncPage.xaml.cs | 4 +-- MisakaTranslator-WPF/MainWindow.xaml | 3 +- MisakaTranslator-WPF/MainWindow.xaml.cs | 15 +++++++++ MisakaTranslator-WPF/lang/en-US.xaml | 6 ++-- MisakaTranslator-WPF/lang/zh-CN.xaml | 6 +++- TextHookLibrary/TextHookHandle.cs | 19 +++++++++++- 8 files changed, 77 insertions(+), 13 deletions(-) diff --git a/MisakaTranslator-WPF/GameGuideWindow.xaml.cs b/MisakaTranslator-WPF/GameGuideWindow.xaml.cs index 5649864e..cab810ac 100644 --- a/MisakaTranslator-WPF/GameGuideWindow.xaml.cs +++ b/MisakaTranslator-WPF/GameGuideWindow.xaml.cs @@ -58,10 +58,10 @@ public GameGuideWindow(int Mode) FuncHint.Text = Application.Current.Resources["GameGuideWin_FuncHint_OCR"].ToString(); GuidePageFrame.Navigate(new Uri("GuidePages/OCR/ChooseOCRAreaPage.xaml", UriKind.Relative)); } - else if(Mode == 3) + else if (Mode == 3) { //重新选择Hook方法 - List lstStep = new List() { + List lstStep = new List() { Application.Current.Resources["GameGuideWin_ReHook_Step_1"].ToString(), Application.Current.Resources["GameGuideWin_Step_5"].ToString() }; @@ -70,6 +70,18 @@ public GameGuideWindow(int Mode) FuncHint.Text = Application.Current.Resources["GameGuideWin_FuncHint_ReHook"].ToString(); GuidePageFrame.Navigate(new Uri("GuidePages/Hook/ReChooseHookFuncPage.xaml", UriKind.Relative)); } + else if (Mode == 4) { + //剪贴板监控 + List lstStep = new List() { + Application.Current.Resources["GameGuideWin_Hook_Step_3"].ToString(), + Application.Current.Resources["GameGuideWin_Step_4"].ToString(), + Application.Current.Resources["GameGuideWin_Step_5"].ToString() + }; + + GuideStepBar.ItemsSource = lstStep; + FuncHint.Text = Application.Current.Resources["GameGuideWin_FuncHint_ClipBoard"].ToString(); + GuidePageFrame.Navigate(new Uri("GuidePages/Hook/ChooseTextRepairFuncPage.xaml", UriKind.Relative)); + } } /// @@ -87,8 +99,8 @@ private void Next_Click(object sender, RoutedEventArgs e) { //Hook方式设置 完成 Common.transMode = 1; TranslateWindow translateWindow = new TranslateWindow(); - translateWindow.Show(); - + translateWindow.Show(); + this.Close(); } else if (GuideMode == 2) @@ -100,7 +112,7 @@ private void Next_Click(object sender, RoutedEventArgs e) { this.Close(); } - else if(GuideMode == 3) + else if (GuideMode == 3) { //Hook方式设置 完成 Common.transMode = 1; @@ -109,6 +121,15 @@ private void Next_Click(object sender, RoutedEventArgs e) { this.Close(); } + else if (GuideMode == 4) + { + //剪贴板监控方式设置 完成 + Common.transMode = 1; + TranslateWindow translateWindow = new TranslateWindow(); + translateWindow.Show(); + + this.Close(); + } } else { //其他情况就跳转指定页面 diff --git a/MisakaTranslator-WPF/GuidePages/Hook/ChooseHookFuncPage.xaml b/MisakaTranslator-WPF/GuidePages/Hook/ChooseHookFuncPage.xaml index 459b7e54..a93cb017 100644 --- a/MisakaTranslator-WPF/GuidePages/Hook/ChooseHookFuncPage.xaml +++ b/MisakaTranslator-WPF/GuidePages/Hook/ChooseHookFuncPage.xaml @@ -34,7 +34,11 @@ - + + diff --git a/MisakaTranslator-WPF/MainWindow.xaml.cs b/MisakaTranslator-WPF/MainWindow.xaml.cs index b5c8aba1..82101376 100644 --- a/MisakaTranslator-WPF/MainWindow.xaml.cs +++ b/MisakaTranslator-WPF/MainWindow.xaml.cs @@ -460,5 +460,20 @@ private int GetGameListHasProcessGame_PID_ID() } return -1; } + + private void ClipboardGuideBtn_Click(object sender, RoutedEventArgs e) + { + Common.textHooker = new TextHookHandle(); + Common.transMode = 1; + Common.textHooker.Init(); + Common.textHooker.AddClipBoardThread(new System.Windows.Interop.WindowInteropHelper(Common.mainWin).Handle); + + //剪贴板方式读取的特殊码和misakacode + Common.textHooker.HookCodeList.Add("HB0@0"); + Common.textHooker.MisakaCodeList.Add("【0:-1:-1】"); + + var ggw = new GameGuideWindow(4); + ggw.Show(); + } } } diff --git a/MisakaTranslator-WPF/lang/en-US.xaml b/MisakaTranslator-WPF/lang/en-US.xaml index f0f5cadf..b8ebfc15 100644 --- a/MisakaTranslator-WPF/lang/en-US.xaml +++ b/MisakaTranslator-WPF/lang/en-US.xaml @@ -16,6 +16,7 @@ Start translation Translate through hook Wizard Translate through OCR Wizard + Translate through ClipBoard New game @@ -145,6 +146,7 @@ Extract Texts with TextHook Re-select the hook method to match the previous settings Extract Texts with OCR + Extract Texts with ClipBoard Note: Run the game first, then come back and select the game process from the drop-down list. If the game has multiple processes, choose "Enable smart hook" in the Hook Settings. Select a window @@ -264,8 +266,8 @@ MisakaTranslator has detected that you have input custom H-code behavior. The last H-code recorded is If you confirm that this H-code can get text, please select "Yes"; if it can't, select "No" to re-inject a custom H-code; if you do not need a custom H-code, please select "Cancel" to enter the next interface. - Add clipboard monitoring method - + Can not find correct Hook? + MisakaTranslator encountered an exception that cannot be resolved. It is about to exit. Details about this exception have been stored in the " " file in the "logs" Directory. To better the Translator, sending these files to the developer on GitHub to troubleshoot is appreciated. diff --git a/MisakaTranslator-WPF/lang/zh-CN.xaml b/MisakaTranslator-WPF/lang/zh-CN.xaml index e534c281..365bf4e3 100644 --- a/MisakaTranslator-WPF/lang/zh-CN.xaml +++ b/MisakaTranslator-WPF/lang/zh-CN.xaml @@ -18,6 +18,7 @@ 开始翻译 Hook方式游戏向导 OCR方式游戏向导 + 剪贴板监控向导 添加游戏 @@ -143,6 +144,7 @@ 使用TextHook方式提取文本 重新选择Hook方法以适配上次的设置 使用OCR方式提取文本 + 使用剪贴板监控方式提取文本 说明:请先运行游戏,之后通过下拉列表选择游戏进程名。部分游戏可能存在多进程,请根据需要开启"智能注入"功能。 选择窗口 @@ -263,7 +265,9 @@ MisakaTranslator检测到您有自定义特殊码行为,记录最后一个特殊码为 如果您确认这个特殊码可以得到文本,请选择是;如果此特殊码不是您想要的结果,您可以选择否来重新注入一个自定义特殊码;如果您不需要自定义特殊码,请选择取消来进入下一个界面。 - 添加剪贴板监视方法 + 找不到正确的Hook方法? + + MisakaTranslator发现了全局无法解决的异常,即将强制退出。关于本次异常的详细信息已经存储在logs目录下的 文件中,为了更好地维护本软件,我们希望您能将此文件发送给作者以修复这个问题。 diff --git a/TextHookLibrary/TextHookHandle.cs b/TextHookLibrary/TextHookHandle.cs index f4f07261..144cda4f 100644 --- a/TextHookLibrary/TextHookHandle.cs +++ b/TextHookLibrary/TextHookHandle.cs @@ -81,7 +81,7 @@ public class TextHookHandle private Dictionary PossibleGameProcessList;//与gamePID进程同名的进程列表 - private int HandleMode;//处理的方式 1=已确定的单个进程 2=多个进程寻找能搜到文本的进程 + private int HandleMode;//处理的方式 1=已确定的单个进程 2=多个进程寻找能搜到文本的进程 3=剪贴板监控 private Process MaxMemoryProcess;//最大内存进程,用于智能处理时单独注入这个进程而不是PossibleGameProcessList中的每个进程都注入 private int listIndex;//用于Hook功能选择界面的方法序号 @@ -137,6 +137,23 @@ public TextHookHandle(List GameProcessList) ThreadID_RenewNum_List = new Dictionary(); } + public TextHookHandle() { + //剪贴板方式读取专用 + MisakaCodeList = new List(); + HookCodeList = new List(); + MaxMemoryProcess = null; + GamePID = -1; + PossibleGameProcessList = null; + TextractorOutPutHistory = new Queue(2000); + HandleMode = 3; + listIndex = 0; + listIndex_Re = 0; + TextractorFun_Index_List = new Dictionary(); + TextractorFun_Re_Index_List = new Dictionary(); + ThreadID_HookDataInfo_List = new Dictionary(); + ThreadID_RenewNum_List = new Dictionary(); + } + /// /// 结束时自动卸载所有Hook,调用方法即令此对象为null然后立即GC回收 ///