在 C# 中模拟 Winkey 行为

发布于 2024-12-28 11:27:41 字数 300 浏览 3 评论 0原文

我想模拟按 WinKey + 数字在任务栏中的应用程序之间切换。

有没有办法用托管代码来做到这一点,或者我必须使用 win32 API? 我尝试使用 SendKeys.SendWait 进行某些操作类似于“^{TAB}2”,但这会在中写入 1 开始菜单字段。 “(^{TAB})1”也不起作用。

如何将 WinKey 传递给 SendKeys?

I want to simulate pressing WinKey + digit to switch between to application in taskbar.

Is there a way to do this with managed code or I have to use win32 API?
I tried to use SendKeys.SendWait with something like "^{TAB}2" but this writes 1 in the
field of Start Menu. Nor does "(^{TAB})1" works.

How can I pass WinKey to SendKeys?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水晶透心 2025-01-04 11:27:41

我的研究表明,如果不使用像 AutoHotKey 这样的第三方工具,您就无法在不使用 win32 API 的情况下真正模拟 Windows 组合键快捷键。

不过这篇文章展示了 win32 API 的一个非常简单的实现。只需创建一个类并在需要时调用它即可。最好的部分是,它可以通过传入 Keys 枚举值

My research showed that without the use of third party tools like AutoHotKey you can't really simulate the windows key combination shortcuts without the use of the win32 API.

This post showed a very easy implementation of the win32 API though. Just create a class and call on it when you need to. Best part is that it works using any key you want by passing in a Keys enum value

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文