run exe from button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i was wondering if there is someone that can tell me how i can use the
numbers from 0-9 on the right side of the keyboard to run any exe file.

thx in advance for the help
 
You may need to set the form's PreviewKey to true and hook its KeyDown
event. Check for Keys.Numpad0 - Keys.Numpad9. If you want to determine
the state of the Numlock key, call the API GetKeyState or
GetKeyboardState,

Thi
 
Click the form then click events and keydown. The source should
explain it:
Curtis
http://www.ghostclip.com
Premier Popup Notepad & Help System For Developers

private void Form1_KeyDown(object sender, KeyEventArgs e)
{

if (e.KeyData == Keys.NumPad0)
{
System.Diagnostics.Process.Start("firefox.exe");
}
else if (e.KeyData == Keys.NumPad1)
{
System.Diagnostics.Process.Start("iexplore.exe");
}

}
 
The first thing is determine which keypad lauch which application. I
assume you read it from a config file and store in a hashtable:
I assume you choose System.Windows.Form.Keys enum to be keys and
strings to be value.
On the form, set PreviewKey to true.
In the form KeyDown event:
if (e.KeyData >= Keys.NumPad0 && e.KeyData <= Keys.NumPad9)
{
if (table[e.KeyData] != null)
{
Process.Start((string) table[e.KeyData]);
}
}

This only works it numlock is on.
 
Back
Top