4

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?

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

3 Answers 3

1

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

1
  • Yeah. Remove all the language-switch hotkeys and leave only the indicators in the task bar. That way you can't accidentally switch. Commented Oct 3, 2010 at 16:05
0

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.

1
  • 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). Commented May 27, 2010 at 8:45
0

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.

15
  • I did all the steps. All went fine. Except the language switch still happens. :( Commented May 28, 2010 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
    Commented May 28, 2010 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
    Commented May 29, 2010 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. Commented May 29, 2010 at 18:36
  • @Vasiliy Borovyak: "try the thread idea in two days"... but the bounty ends in 2 days :(
    – Hugh Allen
    Commented May 30, 2010 at 0:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .