Results 1 to 7 of 7

Thread: How to recognize writing language?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    61

    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.

  2. #2

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to recognize writing language?

    Where does the label's caption come from in the first place?

  4. #4
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    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]

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    61

    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.

  6. #6
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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

  7. #7
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    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
  •  



Click Here to Expand Forum to Full Width