如何使用发送键更改快捷键? [英] how to change short cut keys using send keys?

查看:138
本文介绍了如何使用发送键更改快捷键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在开发一个c#.net应用程序,
在那我想使用多种语言的语言工具栏.
我为印地语(左alt + shift + 2)和英语(左alt + shift + 1)设置了快捷键.我可以使用sendkeys SendKeys.Send("+%(2)" );但是我无法通过使用SendKeys.Send("+%(1)"))将其更改为英文;
不知道为什么吗?

任何人都知道这一点.
在此先感谢您.

Hi All,

I am developing a c#.net application,
In that i want to use the language toolbar for multiple languages.
I set a short cut key for hindi(left alt + shift + 2) and english(left alt + shift + 1) I am able to change to hindi language by using sendkeys SendKeys.Send("+%(2)"); but im unable to change it back to english by using SendKeys.Send("+%(1)");
dont know why?

Anyone aware of this.
Thanks in advance.

推荐答案

首先,如果您仅将System.Windows.Forms.SendKeys(或任何其他模拟输入方式)用于UI开发,则为的错误.这也是不可接受的编码风格和无法维护的代码的开发.

仅在输入本身是关注主题的特殊情况下(例如,播放键盘宏(或键盘/鼠标宏),虚拟键盘

其次,您正在触摸输入语言的切换,这是您永远都不应做的.用户知道该怎么做.此外,Alt + Shift + 2只是您的幻想.一些用户可能会使用此组合键,但大多数用户会使用其他组合键.如果您在文档中要求用户严格使用此组合,则您正在破坏用户系统并滥用用户的工作习惯.在这种情况下,不管它有多有用,谁会使用您的软件? 不要这样做!

话虽如此,让我解释一下SendKeys是非常有限的.可以使用P/Invoked Windows APU SendInput完成全面的输入模拟,请参见 http://msdn.microsoft.com/en-us/library/ms646310(v = vs.85).aspx [
First of all, if you''re using System.Windows.Forms.SendKeys (or any other way of simulating input) just for UI development, it''s wrong. This would be also unacceptable coding style and development of not-maintainable code.

Input simulation should only be used only in special cases where the input itself is the subject of interest, such as for playing keyboard macro (or keyboard/mouse macro), virtual keyboards, etc.

Secondly, you''re touching the switch of input languages, which you never should do. The user knows how to do it. Moreover, Alt+Shift+2 is only your fantasy. Some users may use this key combination, but most will use something else. If you force the user to use exact this combination by demanding it in your documentation, you''re disrupting user system and abuse the user''s working habits. Who would use your software in this case, no matter how useful it may be? Do not do it!

Having say that, let me explain that SendKeys is very limited. The comprehensive input simulation can be done using P/Invoked Windows APU SendInput, see http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx[^].

—SA


这篇关于如何使用发送键更改快捷键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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