hi
i want which user in runtime, can be create shortcut key
"sorry my english is bad"
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
theLizardPosted Mar 5, 2010, 11:01 PM
This implies that you want a user to open a form or press a button or open a file or perform any other function / procedure you have made available to your users programatically.
Trapping keys pressed by the user is simple enough, allowing a user to set which keys will do ANY task in your application is not so simple and would require you to test for every possible combination of keys pressed by the user in every part of your application where a user is able to set which keys to press to perform that function.
On this occasion, I would go with Sam and say I am not sure of what you are trying to do.
Sam HobbsPosted Mar 5, 2010, 10:39 PM
See How to trap keystrokes in controls by using Visual C# for a documented way to do what I think your code that you posted is doing.
as dsddddssPosted Mar 5, 2010, 1:49 PM
andother Solution is :
public partial class Form1 : Form
{
Keys _firstKey = new Keys();
Keys _secondKey = new Keys();
public Form1()
{
InitializeComponent();
}
private void submitShortcut_Click(object sender, EventArgs e)
{
switch (comboBox1.SelectedItem.ToString())
{
case "ALT":
_firstKey = Keys.Alt;
break;
case "CTRL" :
_firstKey = Keys.ControlKey;
break;
case "SHIFT" :
_firstKey = Keys.Shift;
break;
default :
_firstKey = Keys.ControlKey;
break;
}
}
private void textBox_secondKey_KeyDown(object sender, KeyEventArgs e)
{
if (char.IsLetter(e.KeyCode.ToString (),0))
_secondKey = e.KeyCode;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers == _firstKey && e.KeyCode == _secondKey)
testButton_Click((object)testButton, (EventArgs)e);
}
private void testButton_Click(object sender, EventArgs e)
{
MessageBox.Show("testButton Clicked");
}
kiran kumarPosted Mar 5, 2010, 6:05 AM
check it out
MARK THE ANSWER IF IT HELPS YOU
as dsddddssPosted Mar 5, 2010, 3:50 AM
set shortcut key for any task by user(for example user can set SHIFT + S for any task in application);
Hirendra SisodiyaPosted Mar 5, 2010, 1:49 AM