OSDN Git Service

二語前からの単語取得に対応(MODI側)
authortnishi <sgm00353@nifty.ne.jp>
Mon, 28 Nov 2016 11:59:14 +0000 (20:59 +0900)
committertnishi <sgm00353@nifty.ne.jp>
Mon, 28 Nov 2016 11:59:14 +0000 (20:59 +0900)
DCHook/DCHook.cpp
DCHook/DCHook.h
DCHookTest/DCHookMain.cpp
amodi/amodi/MainForm.cs

index 2a5d759..193b89c 100644 (file)
@@ -409,6 +409,7 @@ bool ExtAMODI = false;
 int ScaleX = 0;        // 96\82ð1\82Æ\82µ\82½\89æ\96Ê\82Ì\8ag\91å\97¦
 int ScaleY = 0;
 int generation = 0;
+int NumPrevWords = 1;  // \89½\8cÂ\82Ü\82Å\91O\82Ì\92P\8cê\82ð\8fE\82¤\82©\81H
 
 TCHAR ImageTextPath[256+40];   // OCR\97pimage filename or text filename
 DWORD SaveImageTime;
@@ -880,13 +881,14 @@ int WINAPI Config( int clickonly, int keyaction, int keyflag )
 __declspec(dllexport)
 int WINAPI Config2( const struct TDCHConfig *cfg )
 {
-       DBW("Config2: %d %d %d %d", (int)cfg->ScaleX, (int)cfg->ScaleY, (int)cfg->UseAMODI, (int)ExtAMODI);
+       DBW("Config2: %d %d %d %d %d", (int)cfg->ScaleX, (int)cfg->ScaleY, (int)cfg->UseAMODI, (int)ExtAMODI, cfg->UseNumPrev ? cfg->NumPrevWords : 1);
 
        MoveSend = cfg->MoveSend ? true : false;
        MoveSent = false;
        OnlyImage = cfg->OnlyImage;
        ScaleX = cfg->ScaleX;
        ScaleY = cfg->ScaleY;
+       NumPrevWords = cfg->UseNumPrev ? cfg->NumPrevWords : 1;
 
        if (cfg->UseAMODI){
                if (!ExtAMODI){
@@ -2720,11 +2722,11 @@ bool CaptureImage(HWND hwnd, bool movesend, bool non_block)
                        SYSTEMTIME t;
                        GetLocalTime(&t);
                        if (ExtAMODI){
-                               wsprintf(path+len, /*path_size-len,*/ _T("\\%04d-%02d-%02d-%02d%02d%02d-(%d,%d).bmp"),
-                                       t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond, ptCursor.x, ptCursor.y);
+                               wsprintf(path+len, /*path_size-len,*/ _T("\\%04d-%02d-%02d-%02d%02d%02d-(%d,%d)-n%d.bmp"),
+                                       t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond, ptCursor.x, ptCursor.y, NumPrevWords );
                        } else {
-                               wsprintf(path+len, /*path_size-len,*/ _T("\\amodi\\%04d-%02d-%02d-%02d%02d%02d.bmp"),
-                                       t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond);
+                               wsprintf(path+len, /*path_size-len,*/ _T("\\amodi\\%04d-%02d-%02d-%02d%02d%02d-n%d.bmp"),
+                                       t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond, NumPrevWords );
                                SendAMODI(WMCD_SETPOINT, (char*)&ptCursor, sizeof(ptCursor));
                        }
                        HANDLE fh = CreateFile(path,  GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
index d19877b..27292c3 100644 (file)
@@ -6,9 +6,12 @@ struct TDCHConfig {
        int OnlyAMODI : 1;
        int MoveSend : 1;
        int OnlyImage : 1;
+       int UseNumPrev : 1;
        int ScaleX;
        int ScaleY;
        char AMODIPath[_MAX_PATH];
+       unsigned char NumPrevWords;     // UseNumPrev\82ª1\82Ì\82Æ\82«\82Ì\82Ý\97L\8cø
+       unsigned char reserved1[3];
 };
 
 extern "C" {
index e755b7d..0d40c3b 100644 (file)
@@ -1396,6 +1396,8 @@ void TDCHookMainForm::SetupConfig2()
                cfg.ScaleX = Ini->ReadInteger(PFS_CONFIG, PFS_SCALE, 0);
        }
        cfg.ScaleY = cfg.ScaleX;
+       cfg.UseNumPrev = 1;
+       cfg.NumPrevWords = 2;
        hDll->Config2(&cfg);
 }
 void TDCHookMainForm::SetupAMODI()
index 7103cc6..37233ab 100644 (file)
@@ -146,6 +146,7 @@ namespace amodi
                 MODI.Layout layout = image.Layout;
                                bool outok = capture_page;
                                string prevWord = "";
+                               string prevWord2 = "";
                                for (int j = 0; j < layout.Words.Count; j++)
                 {
                     MODI.Word word = (MODI.Word)layout.Words[j];
@@ -164,25 +165,23 @@ namespace amodi
                             //incursor = true;
                                                        if (!outok)
                                                        {
-                                if (CursorPoint.X < rc.Left) {
-                                    // cursorを飛び越えた
+                                if (CursorPoint.X < rc.Left    // cursorを飛び越えた
+                                       || (CursorPoint.X >= rc.Left && CursorPoint.X <= rc.Right)      // cursorが矩形内
+                                       ){
                                     outok = true;
                                                                        curLocSet = true;
-                                    if (prevWord.Length != 0) {
-                                        tbText.AppendText(prevWord + " ");
-                                        CurLoc = prevWord.Length + 1;
-                                    }
-                                } else
-                                                                       if (CursorPoint.X >= rc.Left && CursorPoint.X <= rc.Right){
-                                                                               outok = true;
-                                                                               curLocSet = true;
-                                        if (prevWord.Length != 0) {
-                                            tbText.AppendText(prevWord + " ");
-                                            CurLoc = prevWord.Length + 1;
-                                        }
-                                                                       } else {
-                                                                               prevWord = word.Text;
-                                                                       }
+                                       if (prevWord.Length != 0) {
+                                                                               if (NumPrevWords >= 2 && prevWord2.Length != 0){
+                                                                                       tbText.AppendText(prevWord2 + " " + prevWord + " ");
+                                                                               } else {
+                                                   tbText.AppendText(prevWord + " ");
+                                               }
+                                           CurLoc = prevWord.Length + 1;
+                                       }
+                                } else {
+                                                                       prevWord2 = prevWord;
+                                                                       prevWord = word.Text;
+                                                               }
                                                        }
                         } else {
                             //incursor = false;
@@ -225,6 +224,12 @@ namespace amodi
                                CursorPoint.X = int.Parse(m.Groups["x"].Value);
                                CursorPoint.Y = int.Parse(m.Groups["y"].Value);
                        }
+                       r = new Regex(@"-n(?<n>\d+)");
+                       m = r.Match(filename);
+                       if (m.Success)
+                       {
+                               NumPrevWords = int.Parse(m.Groups["n"].Value);
+                       }
                }
 
         //イベントハンドラ
@@ -307,6 +312,7 @@ namespace amodi
             p.Y = pt.y;
             return p;
         }
+        int NumPrevWords = 1;
         // interface for external app
         protected override void WndProc(ref Message m)
         {