Determine the input language that is used by the current application


There is a problem with entering combinations (for example, ctrl + v) in a local language, for example RU. Therefore, you need to determine the input language that is used by the current application.

What are the ideas?

language.xaml (7.2 KB)

this does not work.

InputLanguage.CurrentInputLanguage Gets or sets the input language for the current thread.

I assume that the current thread is a robot, and not the application in which it works.

But isn’t input goes from Robot “type into” or “select item” to application unless I’m missing something.



Or you want to check what language the application accepts and change to that at Runtime?



yes, I need to check what input language the application is currently using

so I found an example on VB, but I do not understand how it can be applied to invoke code

Option Explicit
Private Declare Function GetKeyboardLayout Lib “User32” (ByVal dwLayout As Long) As Long
Private Declare Function GetWindowThreadProcessId& Lib “User32” (ByVal hWnd As Long, lpdwProcessId As Long)
'Private Declare Function GetActiveWindow Lib “user32” () As Long ’ ← активное окно очереди сообщений вызывающего_потока
Private Declare Function GetForegroundWindow& Lib “User32” () ’ ← “самое верхнее” окно рабочего_стола. Вернет 0, если рабочий стол заблокирован
Private Declare Sub SetWindowPos Lib “User32” (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
'Делаем форму поверх всех окон
Private Sub Form_Load()
SetWindowPos hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
End Sub

Private Sub Timer1_Timer()
Dim hAppWnd As Long
Dim ThreadID As Long
Dim ThreadLayout As Long
Dim vbNullString, lng As String
'hAppWnd = GetActiveWindow()
hAppWnd = GetForegroundWindow()
ThreadID = GetWindowThreadProcessId(hAppWnd, ByVal 0&)
ThreadLayout = GetKeyboardLayout(ThreadID)
lng = Left(Trim(Str(Hex(ThreadLayout))), 3)
Select Case lng
Case 409: Me.Caption = “Английский” 'Выводим в заголовок информацию о языке
Case 419: Me.Caption = “Русский”
Case Else: Me.Caption = “Другой”
End Select
End Sub


Not sure if the problem is fixed.
But you can change the input language of your machine with Powershell.
This may be helpful you have the language of the application.

Here is a tutorial that I have made how you can use Powershell to read machine setting and change them.