Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8522051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:00:04+00:00 2026-06-11T07:00:04+00:00

I have tried GetKeyboardLayoutName() and GetKeyboardLayout() for getting the current keyboard layout, but they

  • 0

I have tried GetKeyboardLayoutName() and GetKeyboardLayout() for getting the current keyboard layout, but they both give me the default layout and changing the layout doesn’t affect the output!

while(1)
{
    Sleep(5);
    for(int i = 8; i < 191; i++)
    {
        if(GetAsyncKeyState(i)&1 ==1)
        {
            TCHAR szKeyboard[KL_NAMELENGTH];
            GetKeyboardLayoutName(szKeyboard);

            if(GetAsyncKeyState(i)&1 ==1)
            {
                TCHAR szKeyboard[KL_NAMELENGTH];
                GetKeyboardLayoutName(szKeyboard);
                cout << szKeyboard << endl ;
            }
        }
    }
}

It always gives me “00000409” when the default layout is set to English, while I expect it to be “00000429” when I change the layout to Farsi.

My first question here, I used to find all my answers by just searching. But right now I’m driving crazy after hours of searching around and getting nothing…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:00:06+00:00Added an answer on June 11, 2026 at 7:00 am

    one thing that you need to notice is that ::GetKeyboardLayout (..) gets the lang for the passed thread identifer as a param.

    each input thread can have different input locale lang.
    for instance if you put lets IE in the foreground and press Alt+Shift the lang changes to UK. ( you can see it in the taskbar )

    now if you will Alt+Tab to another window ( which will be in foregorund ) you will see that lang dont have to stay UK.

    so what you need to check is what is the thread id you are passing.

    look at this code it will get you the lang for the current active window:

    GUITHREADINFO Gti;
    ::ZeroMemory ( &Gti,sizeof(GUITHREADINFO));
    Gti.cbSize = sizeof( GUITHREADINFO );
    ::GetGUIThreadInfo(0,&Gti);
    DWORD dwThread = ::GetWindowThreadProcessId(Gti.hwndActive,0);
    HKL lang = ::GetKeyboardLayout(dwThread);
    

    to use GUITHREADINFO you need to define WINVER 0x500.
    put this in the stdafx.h before all the include.

    #ifdef WINVER
    #undef WINVER
    #endif 
    #define WINVER 0x500
    

    source: GetKeyboardLayout not returning correct language ID (WINXP)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried many permutations but they all don't seems to work well. Am
I have tried SQLiteConnection(:memory:) and SQLiteConnection(sqlite::memory:) but both of these fail with 'Invalid ConnectionString
have tried to change the timezon in android-emulator but it doesn't work. I write
I have tried all the normal methods of faking keyboard actions (SendInput/SendKeys/etc) but none
I have tried to use records in Clojure 1.2 but they seem very messy
I have tried setting the background image this way, but it doesn't work. Any
I have tried searching over the internet about this problem but not able to
I have tried gaussian blur and checked out all the questions on stackoverflow but
I have tried this but Contacts were not added! ContentResolver cr = this.getContentResolver(); ContentValues
Have tried to compile and run this program, but have received this error message

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.