471,318 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,318 software developers and data experts.

run exe from button

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
Jan 11 '06 #1
4 3793
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

Jan 11 '06 #2
can you be a bit more specific plz
"Truong Hong Thi" wrote:
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

Jan 11 '06 #3
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");
}

}

Jan 11 '06 #4
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.

Jan 11 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Skip Hollowell | last post: by
5 posts views Thread by TrvlOrm | last post: by
25 posts views Thread by KK | last post: by
3 posts views Thread by Zürcher See | last post: by
18 posts views Thread by Colin McGuire | last post: by
7 posts views Thread by =?Utf-8?B?bWFydGluMQ==?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.