如何在C#中使用sendkeys发送键盘组合shift + win + left? [英] How to send keyboard combination shift+win+left using sendkeys in C#?

查看:717
本文介绍了如何在C#中使用sendkeys发送键盘组合shift + win + left?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用键盘组合键Shift + Win + LEFT使用c#中的sendkeys将焦点窗口发送到第二台显示器,但由于某种原因,窗口没有移动到第二台显示器。当我在键盘上按下这些键但不实用时,它可以正常工作。注意我已经知道如何将我想要的窗口带到前台并且它工作正常现在我想使用键盘组合使用c#Shift + Win + LEFT将所需窗口发送到第二台显示器我不想使用SetWindowPos(proceso。 MainWindowHandle,0,monitor.Left,monitor.Top,monitor.Width,monitor.Height,0);



这里是我试过的尝试谢谢提前期待你的帮助顺便说一下我还在寻找和尝试。



我尝试过的事情:



试用版1:

I've been trying to send a focused window to the second monitor using the keyboard combination keys Shift+Win+LEFT using sendkeys in c#, but for some reason the window isn't moving to the second monitor. It works when I physically press on these keys on the keyboard but not pragmatically. Note I already know how to bring my desired window to foreground and it's working fine now I wanna send that desired window to the second monitor using the keyboard combination using c# Shift+Win+LEFT I don't want to use the SetWindowPos(proceso.MainWindowHandle, 0, monitor.Left, monitor.Top, monitor.Width, monitor.Height, 0);

here are my attempts that I've tried Thank you in advance looking forward for your help btw I'm still searching and trying.

What I have tried:

trial 1:

private void btnSendToSecondDisplay_Click(object sender, EventArgs e)
{
  bringToFront("Task Manager");//This lets the "task manager" window to be in the foreground and has the focus set to it
  SendKeys.Send(Keys.ShiftKey.ToString());
  SendKeys.Send(Keys.LWin.ToString());
  SendKeys.Send("{LEFT}");
}





trail 2:



trail 2:

private void btnSendToSecondDisplay_Click(object sender, EventArgs e)
{
  bringToFront("Task Manager");//This lets the "task manager" window to be in the foreground and has the focus set to it
  SendKeys.Send("+"+Keys.LWin.ToString()+"{LEFT}");
}





试用版3:



trial 3:

private void btnSendToSecondDisplay_Click(object sender, EventArgs e)
{
  bringToFront("Task Manager");//This lets the "task manager" window to be in the foreground and has the focus set to it
  SendKeys.Send("{SHIFTDOWN}");
  SendKeys.Send("{APPSKEY}");
  SendKeys.Send("{LEFT}");
}





试用版4:



trial 4:

private void btnSendToSecondDisplay_Click(object sender, EventArgs e)
{
  bringToFront("Task Manager");//This lets the "task manager" window to be in the foreground and has the focus set to it
  SendKeys.Send("{SHIFTDOWN}{APPSKEY}{LEFT}");
}





试用版5:



trial 5:

private void btnSendToSecondDisplay_Click(object sender, EventArgs e)
{
  bringToFront("Task Manager");//This lets the "task manager" window to be in the foreground and has the focus set to it
  SendKeys.Send("+(^{ESC}){LEFT}");
}

推荐答案

这个SO帖子可能有所帮助:使用SendKeys发送Windows密钥 [ ^ ]

有人建议Windows键与Ctrl + Esc键组合相同。

所以也许这样会做的伎俩:

This SO post could be of help: Sending Windows key using SendKeys[^]
Someone suggested that the Windows key is the same as the Ctrl+Esc keys combination.
So maybe that would do the trick:
SendKeys.Send("+(^{ESC}{LEFT})");



这与您的第五次试验略有不同,但这是我从 SendKeys.Send Method(String) [ ^ ]关于键组合的语法ations。

如果这不起作用,那么你可以看看 InputSimulator(Codeplex) [<一个href =http://inputsimulator.codeplex.com/target =_ blank> ^ ]如SO帖子所示。

我无法在我的实际计算机上测试它,对不起希望它能引导你走向正确的方向。

亲切。


This is marginally distinct from your fifth trial, but that is what I understand from SendKeys.Send Method (String)[^] about the syntax for keys combinations.
If that does not work, then you could have a look to InputSimulator (Codeplex)[^] as suggested in SO post.
I cannot test it on my actual computer, sorry for that. Hope it will guide you towards right direction, though.
Kindly.


感谢您的回复,我实际上尝试了
Thank you for your reply, I've actually tried the
SendKeys.Send("+(^{ESC}{LEFT})");

但仍然没有运气,我认为操作系统没有翻译

but still no luck, I think the operating system isn't translating the

^{ESC}

与实际按下Windows启动时相同键盘上的键,因为当我物理按下物理键盘上的那些键时,前景聚焦窗口不会移动到辅助监视器。我将尝试 http://inputsimulator.codeplex.com/ 链接,看看模拟的密钥是否解决了这个问题。

to be the same as when actually pressing the windows start key on the keyboard because when I physically press on those key on the physical keyboard the foreground focused window doesn't move to the secondary monitor. I'm going to try the http://inputsimulator.codeplex.com/ link and see if the simulated keys fix this problem or not.


这篇关于如何在C#中使用sendkeys发送键盘组合shift + win + left?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆