Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Send Ctrl+Shift+F1 to an application using send keys

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}");
like image 910
Mohd Zubair Avatar asked Nov 26 '12 02:11

Mohd Zubair


People also ask

How do I use SendKeys SendWait?

Use SendWait to send keystrokes or combinations of keystrokes to the active application and wait for the keystroke messages to be processed. You can use this method to send keystrokes to an application and wait for any processes that are started by the keystrokes to be completed.

What is SendKeys?

SendKeys in VBA language is a method to send keystrokes to the active window so we can work manually after that. Whenever we use alphabets as the keys, all the alphabets need to be in lowercase characters.


1 Answers

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}
like image 151
Mark Hall Avatar answered Sep 22 '22 16:09

Mark Hall