Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a problem of accidental input language switch. I tried many different settings in order to not do it - change hotkey, install some software (Key Switcher, Keyboard Ninja, Punto Switcher)... But nothing helped.

I used to certain hotkey (Ctrl+Shift). Any other hotkey make me even more suffer. The software I found has no feature to avoid accidental switches.

What I want is to find a piece of software which can stick "English US" input language to my "Visual Studio". And any Ctrl+Shift pushes inside VS should not lead to language switch. Have any ideas?

share|improve this question
    
What version of Windows and what version of Visual Studio? Also, 32 or 64-bit? –  Hugh Allen May 28 '10 at 6:54
    
I'm working with Windows 7 and VS2008 (soon will switch to VS2010). All 64bit. –  Vasiliy Borovyak May 28 '10 at 7:31
    
Have you solved this issue? I'm having same problem... –  alexeit Aug 2 '11 at 3:58
    
Nope, I didn't. –  Vasiliy Borovyak Aug 2 '11 at 12:17
    
it's 2014, there are flying robots outside, but we still can't solve it. still no solution? –  vorou May 27 at 3:03

3 Answers 3

The following works in Visual Studio .NET 2003 on WinXP 32-bit. YMMV.

  • File -> New Project
  • select Project Type: Other Projects \ Extensibility Projects
  • select template: Visual Studio .NET Add-in. Click OK.
  • click Next, select Create an Add-in using Visual C++ / ATL, click Next.
  • select all possible appication hosts, click Next.
  • (optionally) enter a name and description, click Next.
  • choose Options. Don't check "yes, create a Tools menu item". Click Next.
  • don't choose to create an About box. Click Next.
  • click Finish.
  • switch to the tab with the source file Connect.cpp
  • at the top, after the #includes add the line

    HHOOK myhook;
    
  • to method CConnect::OnConnection add the line

    myhook=SetWindowsHookEx(WH_GETMESSAGE, &myGetMsgProc, _AtlModule.GetResourceInstance(), GetCurrentThreadId());
    
  • to method CConnect::OnDisconnection add the line

    UnhookWindowsHookEx(myhook);
    
  • above OnConnection() add the function

    LRESULT CALLBACK myGetMsgProc(int code, WPARAM wParam, LPARAM lParam)
    {
        MSG *msg = (MSG*)lParam;
        if (code>=0 && msg->message==WM_INPUTLANGCHANGEREQUEST)
            msg->message = WM_NULL;
        return CallNextHookEx(myhook, code, wParam, lParam);
    }
    
  • build the solution.
  • select menu Tools -> Add-in Manager...
  • check the box for your new add-in. Don't check "Startup" for now in case anything went wrong - you don't want Visual Studio crashing every time it starts!
  • click OK.

It is now impossible to change language or keyboard layout in Visual Studio. The language bar gets a little confused if you try, but doesn't break.

share|improve this answer
    
I did all the steps. All went fine. Except the language switch still happens. :( –  Vasiliy Borovyak May 28 '10 at 15:14
    
Damn. My code assumes that the thread which loads the addin is the thread which hosts the GUI, which may not be true in your version of VS. Could you find out if that is the problem? One way is to put a MessageBox() call in OnConnection to show the current thread id, and use Spy++ on the code editor window to find its thread id. –  Hugh Allen May 28 '10 at 22:31
    
I just had another thought - did you actually try typing after switching languages, or did you just believe what the language bar told you? –  Hugh Allen May 29 '10 at 2:57
    
I was typing of course. :) And restarted the VS just in case. I'll try the thread idea in two days. Thanks. –  Vasiliy Borovyak May 29 '10 at 18:36
    
@Vasiliy Borovyak: "try the thread idea in two days"... but the bounty ends in 2 days :( –  Hugh Allen May 30 '10 at 0:07

As long as your default language is already set and you only need to change the language for one program I would suggest changing the language for that program (VS) and then going into the Language Options and changing the hotkey to none, and then go to the key sequence and uncheck that box (Regional and language options -> Languages tab -> details -> Key Settings -> Change Key Sequence). Now the shortcuts will be off, and since Windows remembers inputs on a per application basis the input will automatically switch for VS but remain Spanish for everything else.

share|improve this answer
    
Nope. This is not the solution. The matter is I have to use both languages in all other applications (like browser, or mail client, or skype). –  Vasiliy Borovyak May 27 '10 at 8:45

If you go to
Control Panel / Regional and Language Options / Languages / Details / Key Settings
you'll find that you can define hotkeys for language changes.

You may couple this with a macro language like AutoHotkey, to define a macro that changes the language/keyboard-layout and then launches Visual Studio. This however won't block future language-changes.

If you're looking for something much stricter than that, as far as I know no such program exists. As VS is extensible, you can program yourself an add-in that will limit the number of languages allowed for VS. This small add-in will load with VS and set the preferred languages to just one (english).

If you wish to launch yourself in this direction, the following links might be helpful for a start:

Supporting Application-Specific Language Settings
Tutorial : Creating Visual Studio Add-Ins
Creating Visual Studio Add-Ins

share|improve this answer
    
Thanks for the try... –  Vasiliy Borovyak May 26 '10 at 8:30
    
Yeah. Remove all the language-switch hotkeys and leave only the indicators in the task bar. That way you can't accidentally switch. –  Loren Pechtel Oct 3 '10 at 16:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.