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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Hirendra SisodiyaRank #258 · 9.8K reputationPosted Mar 4, 2010, 8:49 PM EST
as dsddddss5 reputationPosted Mar 4, 2010, 10:50 PM EST
set shortcut key for any task by user(for example user can set SHIFT + S for any task in application);
kiran kumarRank #3,110 · 461 reputationPosted Mar 5, 2010, 1:05 AM EST
check it out
MARK THE ANSWER IF IT HELPS YOU
as dsddddss5 reputationPosted Mar 5, 2010, 8:49 AM EST
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");
}
Sam HobbsRank #107 · 20.5K reputationPosted Mar 5, 2010, 5:39 PM EST
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.
theLizardRank #1,079 · 1.8K reputationPosted Mar 5, 2010, 6:01 PM EST
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.