Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Or, how about this, sending the key's code (ASCII) instead the key itself?


Hallo Everybody,

How can I press both the function key (fn) and f11 at the same time using the sendkeys method?

I tried like this:
C#
var WshShell = new ActiveXObject("WScript.Shell");
                WshShell.AppActivate(this);
                WshShell.SendKeys("FN{F11}");


but this is not working.

Help me,

Thanks
Posted
Updated 8-Aug-16 6:30am
v2
Comments
Manfred Rudolf Bihy 19-Apr-11 5:58am    
What are you trying to achieve? Why not just WshShell.SendKeys("{F11}");
Toniyo Jackson 19-Apr-11 6:01am    
Actually there is Fn key in some laptops. I think he is talking about that.

Sendkeys can only deal with keys known to and processed by windows. In
most cases, the FN key deals directly with the hardware, and not through the
o/s.

I suspect that Fn keys are hardwired and need special methods to pick them
up.

Check this link[^].
 
Share this answer
 
Comments
OriginalGriff 19-Apr-11 6:06am    
Sounds about right! Beat me to it :)
Sergey Alexandrovich Kryukov 19-Apr-11 12:06pm    
No, there is absolutely nothing special about them.
I just tested my Fn. If produces strange key combination (Left|OemClear) but it is a "normal" key handled as WM_KEYUP, WM_KEYDOWN.
--SA
Please see my answer.
--SA
You don't need to send "Fn"; that is merely a hardware feature on the laptop keyboard. All you need is the correct string for the key in question as described here[^].
 
Share this answer
 
Comments
Manfred Rudolf Bihy 19-Apr-11 8:48am    
Exactly 5+!
Sergey Alexandrovich Kryukov 19-Apr-11 12:12pm    
No! I just tested my Fn. If produces strange key combination (Left|OemClear) but it is a "normal" key handled as WM_KEYUP, WM_KEYDOWN.
Please see my answer.
--SA
The functionality of SendKey is very limited. For completely authentic simulation of input you need to use P/Invoke for Windows API SendInput.

There is nothing special about Fn, but it can be non-standard (maybe depending on hardware, I'm not sure). Is is handled as WM_KEYUP, WM_KEYDOWN as any other key.

Please understand that using keyboard simulation as a dirty work-around to get desired UI behavior is unacceptable. It can be uses only for special "system" purposes, such as creation of keyboard macro tools, virtual keyboards, etc.

—SA
 
Share this answer
 
v2
Comments
Richard MacCutchan 19-Apr-11 12:31pm    
Very interesting, but the questioner wants to use the Sendkeys() function to send a key message. The hardware operation is irrelevant in this instance, as evidenced in the MSDN page I linked to.
Sergey Alexandrovich Kryukov 19-Apr-11 13:41pm    
I agree with your answer in part where you say OP does not need to use SendKeys.
And I agree hardware operation is irrelevant, so what?
I think we don't know the OP's purpose, but the idea is certainly wrong.
You see, on my keyboard Fn + F11 does not mean anything, but on other notebook it could be significant. Just wrong approach.
Richard MacCutchan 19-Apr-11 14:24pm    
Yes, you're right. I suspect that the key combinations he is talking about are actually not sent beyond the BIOS or driver level.
Sergey Alexandrovich Kryukov 19-Apr-11 15:24pm    
Well, they can be sent via SendInput, for sure (it is a very close simulation of hardware keyboard), but what's the use?

Thank you for the discussion.
--SA
Hi,

The soluction is:

Firt) Chande de propriety of form (windowsforms) "Start Position" to manual;
Second) Use this code:

C#
this.Location = Screen.AllScreens[1].WorkingArea.Location;



This index is a number of screen. For example, "0" is a principal screen of the windows. Remember: Windows 10 implement any screens.
 
Share this answer
 
Comments
Richard Deeming 8-Aug-16 12:58pm    
This question was asked, answered, and solved over FIVE YEARS AGO.

Also, your "solution" has absolutely nothing to do with the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900