|
-
Jun 16th, 2008, 10:11 AM
#1
Thread Starter
Member
How to recognize writing language?
Hello,
I have a hiden form. If I press a keyboard shortcut, it shows me the form.
In the form there is a label.
The problem:
When change the typing language to English, the label caption will be "English". If I change to, lets say Spanish, the caption will be "Spanish".
Is it possible? If yes then can you gimme a code for that?
Thank you.
-
Jun 16th, 2008, 10:37 AM
#2
-
Jun 16th, 2008, 11:14 AM
#3
Re: How to recognize writing language?
Where does the label's caption come from in the first place?
-
Jun 16th, 2008, 12:32 PM
#4
PowerPoster
Re: How to recognize writing language?
I don't think you can program the computer to discern whether the user is typing in English, or Spanish, etc unless you can find a way to look for specific words or phrases.
Are you wanting the computer to figure out that you are typing in Spanish and change everything to Spanish?
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Jun 16th, 2008, 01:03 PM
#5
Thread Starter
Member
Re: How to recognize writing language?
I was thinking and I found a half way to do this:
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Dim Spanish, English As Boolean
Private Sub Form_Load()
Timer1.Interval = 150
English = True
Spanish = False
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(18) And GetAsyncKeyState(16) Then'if pressed alt+shift
If English Then
English = False
Spanish = True
Label1.Caption = "Spanish"
ElseIf Spanish Then
English = True
Spanish = False
Label1.Caption = "English"
End If
End If
End Sub
All I need is when I type anything and anywhere in English, it will say "English", for example: to enter google I type in english google.com, so in the label caption it will be "English".
In this program if you press Alt+Shift (to change language), it will swich to the other language in the caption, as you can see. But it is still not good because the writing language in the computer changes automaticly when I close a window.
Understand what I mean?
if there is a way to find out if a character is in English or other language, then tell me. But the character writing must not be in vb, only the caption will change in vb to show if its in English.
Last edited by kiaraire; Jun 16th, 2008 at 01:16 PM.
-
Jun 16th, 2008, 05:51 PM
#6
Re: How to recognize writing language?
Instead of doing that, you might want to determine the user's locale...using the GetLocaleInfo API function.
http://allapi.mentalis.org/apilist/GetLocaleInfo.shtml
-
Jun 16th, 2008, 07:06 PM
#7
Re: How to recognize writing language?
Rather than use a Timer, Subclass and look for message WM_INPUTLANGCHANGE.
Const WM_INPUTLANGCHANGE As Long = &H51
http://www.tech-archive.net/Archive/.../msg00003.html
My keyboard is ABNT-2 Brazilian Portuguese and I can type either Portuguese or English without having to Alt-Shift to English keyboard. Thus there is no guarantee that I'm typing English or not just by looking at the Keyboard Layout.
Looking at Locale is also no guarantee as to what the user is typing since you can install any number of Keyboard Layouts or IMEs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|