Exemplo n.º 1
0
 void WatchHWNDs()
 {
     while (true)
     {
         IntPtr CurrentWindow = NativeWin32.GetForegroundWindow();
         if (CurrentWindow == m_MyHWND)
         {
             NativeWin32.SetForegroundWindow(LastWindow);
         }
         LastWindow = CurrentWindow;
         Thread.Sleep(10);
     }
 }
Exemplo n.º 2
0
        // Returns the name of the process owning the foreground window.
        public static Process GetForegroundProcess()
        {
            IntPtr hwnd = NativeWin32.GetForegroundWindow();

            // The foreground window can be NULL in certain circumstances,
            // such as when a window is losing activation.
            if (hwnd == null || hwnd == IntPtr.Zero)
            {
                return(null);
            }

            uint pid;

            NativeWin32.GetWindowThreadProcessId(hwnd, out pid);

            return(Process.GetProcesses().FirstOrDefault(p => p.Id == pid));
        }
Exemplo n.º 3
0
        void IMaster.Execute(string[] args, Action <string, DisplayData, List <string>, Action <string> > display)
        {
            var hwnd = (IntPtr)NativeWin32.GetForegroundWindow();


            var image  = Capture.GrabWindow(hwnd);
            var dialog = new SaveFileDialog {
                AddExtension = true,
                DefaultExt   = "*.png",
                Filter       = "Png files (*.png)|*.png",
                Title        = "Save the screenshot..."
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                image.Save(dialog.FileName, System.Drawing.Imaging.ImageFormat.Png);
            }
        }
Exemplo n.º 4
0
 void GO()
 {
     while (true)
     {
         if (NativeWin32.GetForegroundWindow() == myHandle)
         {
             while (true)
             {
                 if (NativeWin32.GetForegroundWindow() != myHandle)
                 {
                     for (int i = 0; i < TheDictionary.Count; i++)
                     {
                         if (TheDictionary[i].Length == length)
                         {
                             for (int j = 0; j < CurrentLetters.Length; j++)
                             {
                                 if (TheDictionary[i][0] == CurrentLetters[j])
                                 {
                                     SendKeys.SendWait(TheDictionary[i]);
                                     SendKeys.SendWait("{ENTER}");
                                 }
                             }
                         }
                     }
                     if (length >= 3)
                     {
                         length--;
                     }
                     else
                     {
                         return;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 && (wParam == (IntPtr)WM_KEYDOWN || wParam == (IntPtr)WM_SYSKEYDOWN))
            {
                Keys number = (Keys)Marshal.ReadInt32(lParam);

                string cucc = nCode.ToString() + " | " +
                              wParam.ToString() + " | " +
                              lParam.ToString() + " | " +
                              number.ToString() + " | " +
                              Control.ModifierKeys.ToString();

                if (number == Keys.PrintScreen)
                {
                    if ((wParam == (IntPtr)256 && number == Keys.PrintScreen && Keys.None == Control.ModifierKeys))
                    {
                        System.Threading.Thread fullps = new System.Threading.Thread(() => new ScreenMode.FullScreen());
                        fullps.SetApartmentState(System.Threading.ApartmentState.STA);
                        fullps.Start();
                    }
                    else if ((wParam == (IntPtr)260 && Keys.Alt == Control.ModifierKeys && number == Keys.PrintScreen))
                    {
                        IntPtr    hWnd = NativeWin32.GetForegroundWindow();
                        Rectangle rect;
                        NativeWin32.GetWindowRect(hWnd, out rect);
                        new Thread(() => new ScreenMode.ActiveWindow(rect)).Start();
                    }
                    else if ((wParam == (IntPtr)256 && Keys.Control == Control.ModifierKeys && number == Keys.PrintScreen))
                    {
                        DesignateArea secondForm = new DesignateArea();
                        secondForm.Show();
                    }
                }
            }
            return(NativeWin32.CallNextHookEx(_hookID, nCode, wParam, lParam));
        }