Exemplo n.º 1
0
 /*
  * Callback for window opening and closing event
  * raises event for things such as start menu (ALL WINDOWS), etc.
  */
 public void OpenCloseEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     if (ProgramManager.ProcessDict.Keys.Contains(hwnd.ToInt32()))
     {
         updateText(ProgramManager.ProcessDict[hwnd.ToInt32()].WindowTitle + " is now in focus");
         //tObj.updateTextbox(ProgramManager.ProcessDict[hwnd.ToInt32()].WindowTitle + " is now in focus");
         ProgramManager.updateWindowCap(currentApp.ToInt32(), getWindowCap(currentApp));
         currentApp = hwnd;
         //tObj.updateGridView();
         updateTable();
     }
 }
Exemplo n.º 2
0
 /*
  * Callback for title changing event
  */
 private void TitleChangeEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     if (ProgramManager.ProcessDict.ContainsKey(hwnd.ToInt32()))
     {
         StringBuilder sb_title = new StringBuilder(256);
         int           length   = GetWindowText(hwnd, sb_title, sb_title.Capacity);
         updateText("Program " + hwnd.ToString() + " changed name from " + ProgramManager.ProcessDict[hwnd.ToInt32()].WindowTitle + " to " + sb_title.ToString());
         //tObj.updateTextbox("Program " + hwnd.ToString() + " changed name from " + ProgramManager.ProcessDict[hwnd.ToInt32()].WindowTitle + " to " + sb_title.ToString());
         ProgramManager.changeProgramTitle(hwnd.ToInt32(), sb_title.ToString());
         updateTable();
         //tObj.updateGridView();
     }
 }
Exemplo n.º 3
0
        // We use this function to filter windows.
        // This version selects visible windows that have titles.
        private bool FilterCallback(IntPtr hWnd, int lParam)
        {
            StringBuilder sb_title     = new StringBuilder(256);
            int           length       = GetWindowText(hWnd, sb_title, sb_title.Capacity);
            string        title        = sb_title.ToString();
            var           lShellWindow = GetShellWindow();
            Process       pObj;
            uint          processId;

            if (!isTopLevel(hWnd, lShellWindow, title))
            {
                return(true);
            }

            wPtrList.Add(hWnd.ToInt32());
            if (ProgramManager.ProcessDict.Keys.Contains(hWnd.ToInt32()))
            {
                return(true);
            }

            //If the window is visible and has a title, save it(and it's not Program Manager).
            //tObj.updateTextbox(GetParent(hWnd).ToString());
            GetWindowThreadProcessId(hWnd, out processId);
            pObj = Process.GetProcessById(checked ((int)processId));
            //ApplicationFrameHost allows stock windows app to be interacted with through GUI
            //but causes additional problems such as creating hidden top-level windows to Mail, Photos, and Groove Music open
            //while checking for updates to those software in WinStoreApp

            if (pObj.ProcessName == "WINWORD")
            {
                ProgramManager.addProgram(hWnd.ToInt32(), new WordApp(ref pObj, hWnd, title));
            }
            else
            {
                ProgramManager.addProgram(hWnd.ToInt32(), new ProgramBase(ref pObj, hWnd, title));
            }
            ProgramManager.updateWindowCap(hWnd.ToInt32(), getWindowCap(hWnd));
            updateTable();
            //tObj.updateGridView();



            // Return true to indicate that we
            // should continue enumerating windows.
            return(true);
        }
Exemplo n.º 4
0
 private void button2_Click(object sender, EventArgs e)
 {
     ProgramManager.removeProgram((int)dataGridView1.SelectedRows[0].Cells[2].Value);
     updateGridView();
 }