1

I am working on a C# application which consists of some context menus that have an ability to communicate with my website via WebClient(). The options work when they are clicked.

Once my app is opened, it stays open in the tray and it doesn't show in the taskbar/toolbar (the bar in the bottom where open programs stay). It's basically a background application that runs continuously.

There is a section in the context menu named Upload which includes Upload from Computer and Window screenshot. These are the two items that I want to be accessed via keyboard shortcuts. It shouldn't matter where the user is, once he clicks the set keyboard keys, he will trigger the application's _Click event for a certain context menu.

Final question: How do I make global keyboard shortcuts to trigger some context menus item _Click event?

It would be good is someone could explain a bit more broadly how to achieve this. I'm into C# for a short time (1 month learning it, 2 weeks using it) and I am having trouble understanding code just pasted here.

This is one of the click events I want to associate with a keyboard shortcut:

private void menu_upload_file_Click(object sender, EventArgs e)
{
    DialogResult dialogOpened = openFileDialog1.ShowDialog();
    if (dialogOpened == DialogResult.OK)
    {
        string filename = openFileDialog1.FileName;
        this.sendToIMGit(filename);
    }
}

Thanks.

4

1 回答 1

1

You will need to use a 'keyboard hook' to create a global hotkey.

See this question.

于 2013-02-08T14:59:06.480 回答