In Visual Studio and Other Editors/IDE, the automatic input method is automatically switched. Do you need to manually do this ?, Studioide

Source: Internet
Author: User

In Visual Studio and Other Editors/IDE, the automatic input method is automatically switched. Do you need to manually do this ?, Studioide

When using Visual Studio to write code, it is often difficult to switch the Chinese input method. After Entering the annotation //, you must switch to the Chinese language, enter the quotation marks, and enter the Chinese language, then you need to switch back, do you have?

Is the Chinese Input Method suddenly invalid? Clearly in the Chinese input mode, Chinese cannot be entered. Is there any?

 

Here we share an AHK script to solve the above problems and implement the following functions:

1. Based on different programs, after startup, the system automatically switches to the Chinese and English input methods.

For example, qq uses sogou Pinyin and vs automatically switches to the English input method after startup.

2. in Visual Studio and other IDE/Editors (configurable), the input method is automatically switched.
  • Easy to add comments: enter comments // Add spaces to automatically switch to the Chinese input method. Ignore the current input method status. If it is a Chinese character, "," is automatically corrected //
  • Easy to enter Chinese strings: Enter quotation marks and spaces to automatically switch to the Chinese input method.
  • Easy to switch back to the English input method: enter a semicolon and switch to the English input method automatically. Similarly, if you ignore the current input method status, the full-width Semicolon is automatically corrected to a half-width semicolon. If you enter a semicolon and a space, the system automatically switches back to the English input method and automatically changes the full-width semicolon to a half-width semicolon.
3. In Visual Studio and other IDE/Editors (configurable), you can manually switch the input method more efficiently.

During manual switching, the operation is simple and easy to remember. spaces represent Chinese input methods (smart ABC users indicate that all input characters are on the screen with spaces), and semicolons represent English input methods. This c # code is understandable.

  • Enter two semicolons consecutively and switch to the English input method.
  • Enter two consecutive spaces and switch to the Chinese input method.

Two-click Key switching is much better than pressing windows, contrl, and other key combinations. Don't tell me about the shirt key switch, so it is easy to confuse the current input method status.

Code testing environment: win10 64-bit, vs2012/vs2013/vs2015/Notepad ++/Notepad, ahkv1.1.23.01

 

Highlights:

 

The AHK code is as follows:

1 ;===== group configuration 2; group 3 GroupAdd, cn, ahk_exe QQ.exe; group QQ 4 GroupAdd, cn, ahk_exe WINWORD. EXE; word 5 GroupAdd, cn, ahk_exe MindManager.exe 6 7; Group 8 GroupAdd, en, ahk_exe devenv.exe; Visual Studio 9 GroupAdd, en, ahk_exe dopus.exe 10 GroupAdd, en, ahk_class Notepad ++ 11 12; editor Group 13 GroupAdd, editor, ahk_exe devenv.exe; Visual Studio 14 GroupAdd, editor, ahk_exe notepad.exe; Notepad 15 GroupAdd, editor, ahk_cia Ss Notepad ++ 16 17 18 19 20; function 21; input from clipboard to interface 22 sendbyclip (var_string) 23 {24 ClipboardOld = % ClipboardAll % 25 Clipboard = % var_string % 26 ClipWait 27 send ^ v 28 sleep 100 29 Clipboard = % ClipboardOld %; Restore previous contents of clipboard. 30} 31 32 33 setChineseLayout () {34; send the shortcut key for switching the Chinese Input Method. Set it according to the actual situation. 35 send {Ctrl Down} {Shift} 36 send {Ctrl Down}, 37 send {Ctrl Down} {Shift} 38 send {Ctrl Down }, 39 send {Ctrl Up} 40} 41 setEnglishLayout () {42; send the shortcut key for switching the English input method. Set it according to the actual situation. 43 send {Ctrl Down} {Shift} 44 send {Ctrl Down}, 45 send {Ctrl Down} {Shift} 46 send {Ctrl Down }, 47 48 send {Ctrl Down} {Space} 49 send {Ctrl Up} 50} 51 52; monitor message callback ShellMessage, and automatically set the input method 53 Gui + LastFound 54 hWnd: = WinExist () 55 DllCall ("RegisterShellHookWindow", UInt, hWnd) 56 MsgNum: = DllCall ("RegisterWindowMessage", Str, "SHELLHOOK") 57 OnMessage (MsgNum, "ShellMessage ") 58 59 ShellMessage (wP Aram, lParam) {60 If (wParam = 1) 61 {62 WinGetclass, WinClass, ahk_id % lParam % 63; MsgBox, % Winclass % 64 Sleep, 1000 65 WinActivate, ahk_class % Winclass % 66; WinGetActiveTitle, Title 67; MsgBox, The active window is "% Title % ". 68 IfWinActive, ahk_group cn 69 {70 setChineseLayout () 71 TrayTip, AHK, has automatically switched to 72 return 73} 74 IfWinActive, ahk_group en 75 {76 setEnglishLayout () 77 TrayTip, AHK, already Automatic switch to English Input Method 78 return 79} 80} 81} 82 83; In all editors, automatic switch between English and Chinese Input Methods 84 # IfWinActive, ahk_group editor 85: *: //: 86; // switch to the Chinese Input Method 87 setEnglishLayout () 88 sendbyclip ("/") 89 setChineseLayout () 90 return 91: Z *: //: 92; /// switch to the Chinese Input Method (or enter a space) when commenting 93 setengishlayout () 94 sendbyclip ("//") 95 SendInput/96 setChineseLayout () 97 return 98: *: ": 99; switch to the Chinese Input Method 100 setEnglishLayout () 101 sendindium when the quotation marks and spaces are added Ut "102 setChineseLayout () 103 return104: *: '; 'N': 105; English input method 106 setEnglishLayout () 107 sendbyclip (";") 108 SendInput 'n109 return110: Z? *: ';: 111; the English input method 112 setEnglishLayout () 113 return114: Z? *: 115; enter two spaces to switch the Chinese Input Method 116 setEnglishLayout () 117 setChineseLayout () 118 return119 120 # IfWinActive

 

Github address:

Https://github.com/lspcieee/lspcieee_ahk

Seek powder and follow

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.