فهرست منبع

check focused process name against group name, if they match open to that group, needs to match exactly (ex, notepad.exe), case does not matter

ScottBrogden 8 سال پیش
والد
کامیت
4340bfbaa6
3فایلهای تغییر یافته به همراه32 افزوده شده و 0 حذف شده
  1. 19 0
      MainFrm.cpp
  2. 10 0
      Options.cpp
  3. 3 0
      Options.h

+ 19 - 0
MainFrm.cpp

@@ -280,6 +280,25 @@ LRESULT CMainFrame::OnHotKey(WPARAM wParam, LPARAM lParam)
 			//Before we show our window find the current focused window for paste into
 			theApp.m_activeWnd.TrackActiveWnd(true);
 
+			if (CGetSetOptions::GetOpenToGroupByActiveExe() &&
+				theApp.m_activeWnd.ActiveWnd() != NULL)
+			{
+				CString exeName = GetProcessName(theApp.m_activeWnd.ActiveWnd());
+				if (exeName != _T(""))
+				{
+					CString query = StrF(_T("SELECT lID FROM Main WHERE bIsGroup = 1 AND mText = '%s' COLLATE NOCASE"), exeName);
+					CppSQLite3Query q = theApp.m_db.execQueryEx(query);
+					if (q.eof() == false)
+					{
+						int groupId = q.getIntField(_T("lID"));
+						//this will revert back to the old group on hide of ditto
+						theApp.EnterGroupID(groupId, TRUE, TRUE);
+
+						Log(StrF(_T("Opening Ditto to Group based on found group name, name: %s, GroupId: %d"), exeName, groupId));
+					}
+				}
+			}
+
             m_quickPaste.ShowQPasteWnd(this, false, true, FALSE);
         }
 

+ 10 - 0
Options.cpp

@@ -2476,4 +2476,14 @@ CString	CGetSetOptions::GetRegexFilterByProcessName(int pos)
 	CString cs;
 	cs.Format(_T("RegexFilterByProcessName_%d"), pos);
 	return GetProfileString(cs, "");
+}
+
+BOOL CGetSetOptions::GetOpenToGroupByActiveExe()
+{
+	return GetProfileLong(_T("OpenToGroupByActiveExe"), TRUE);
+}
+
+void CGetSetOptions::SetOpenToGroupByActiveExe(int val)
+{
+	SetProfileLong(_T("OpenToGroupByActiveExe"), val);
 }

+ 3 - 0
Options.h

@@ -563,6 +563,9 @@ public:
 
 	static void SetRegexFilterByProcessName(CString val, int pos);
 	static CString GetRegexFilterByProcessName(int pos);
+
+	static BOOL GetOpenToGroupByActiveExe();
+	static void SetOpenToGroupByActiveExe(int val);
 };
 
 // global for easy access and for initialization of fast access variables