Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Windows Application Always Detect Key Event's

$
0
0

I am developing a small application ,

Using C# 4.0 Visual Studio 2012

I am making my Windows Form Hidden on Form_Load but now I want even it is in hidden state it should always detect certain key event's

if i press [Alt +1] it should respond to my windows application

now the problem comes when i hide the windows and open Google chrome or do any other stuff ,i am losing it's focus and it is not detecting any of my key event's

Code Below

   private void CloseProcesses_Load(object sender, EventArgs e)
        {
            this.Hide();
            this.ShowInTaskbar = false;
            this.TopLevel = true;
            this.TopMost = true;
            this.BringToFront();

        }

        #endregion

        private void CloseProcesses_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Alt)
            {
                //MessageBox.Show("alt pressed");
                foreach (Process myProc in Process.GetProcesses())
                {
                    if (myProc.ProcessName == ProgramName)
                    {
                        myProc.Kill();
                    }
                }
            }
        }
    }


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>