2

我想从语言栏中获取当前的键盘语言:

我想实时执行此操作。如何?



编辑:表单加载:

Timer1.Start()


Public Sub MyCurrentInputLanguage()
    Dim myCurrentLanguage As InputLanguage = InputLanguage.CurrentInputLanguage
    Me.Text = "Current input language is: " & _
        myCurrentLanguage.Culture.EnglishName
End Sub

计时器:

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

 MyCurrentInputLanguage()

end sub

当用户按下“Alt+Shift”时如何更新我的文本框?

4

1 回答 1

1

使用InputLanguage.CurrentInputLanguage. MSDN 上的链接给出了这个例子:

CurrLang = InputLanguage.CurrentInputLanguage

以下是有关InputLanguage.

您可以使用事件在运行时检测更改(不使用计时器)Form.InputLanguageChanged。(来自引用的 MSDN 链接的示例。)

Private Sub Form1_InputLanguageChanged(sender as Object, e as InputLanguageChangedEventArgs) _ 
  Handles Form1.InputLanguageChanged

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "InputLanguage", e.InputLanguage)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Culture", e.Culture)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "CharSet", e.CharSet)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"InputLanguageChanged Event")

End Sub

(感谢 HansPassant 提供的信息。)

于 2012-09-05T18:20:15.067 回答