15

I want to send Ctrl+Shift+F1 combination of keys to an application.

But when I try to send the keys i am getting an error,the error is, ^+F1 is not a valid key.

The code I am using is:

System.Windows.Forms.SendKeys.Send("{^+F1}");
Victor Zakharov
  • 25,801
  • 18
  • 85
  • 151
Mohd Zubair
  • 237
  • 1
  • 3
  • 7

1 Answers1

21

Looking at the documentation you need to have your braces around just the F1. Try this to see if it works

System.Windows.Forms.SendKeys.Send("^+{F1}");

From above link by enclosing the ^ and + in the braces you are sending the literal character.

The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses () have special meanings to SendKeys. To specify one of these characters, enclose it within braces ({})

added by barlop - explanatory note-

(from the documentation link above)

SHIFT +
CTRL ^
ALT %

and

F1 {F1}
F2 {F2}
barlop
  • 12,887
  • 8
  • 80
  • 109
Mark Hall
  • 53,938
  • 9
  • 94
  • 111