Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. msgbox,% ConvertText("ghbdtn", Layout)
  2.  
  3. ConvertText(Text, ByRef OppositeLayout)
  4. {
  5. Static Cyr := "ЁЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ/ёйцукенгшщзхъфывапролджэячсмитьбю,.""№;?:"
  6. , Lat := "~QWERTYUIOP{}ASDFGHJKL:""ZXCVBNM<>|``qwertyuiop[]asdfghjkl;'zxcvbnm,.?/@#$&^"
  7.  
  8. RegExReplace(Text, "i)[A-Z@#\$\^&\[\]'`\{}]", "", LatCount)
  9. RegExReplace(Text, "i)[А-ЯЁ№]", "", CyrCount)
  10.  
  11. if (LatCount != CyrCount)
  12. {
  13. CurrentLayout := LatCount > CyrCount ? "Lat" : "Cyr"
  14. OppositeLayout := LatCount > CyrCount ? "Cyr" : "Lat"
  15. }
  16. else
  17. {
  18. threadId := DllCall("GetWindowThreadProcessId", Ptr, WinExist("A"), UInt, 0, Ptr)
  19. landId := DllCall("GetKeyboardLayout", Ptr, threadId, Ptr) & 0xFFFF
  20. if (landId = 0x409)
  21. CurrentLayout := "Lat", OppositeLayout := "Cyr"
  22. else
  23. CurrentLayout := "Cyr", OppositeLayout := "Lat"
  24. }
  25. Loop, parse, Text
  26. NewText .= (found := InStr(%CurrentLayout%, A_LoopField, 1))
  27. ? SubStr(%OppositeLayout%, found, 1) : A_LoopField
  28. Return NewText
  29. }
  30.  
  31. Gui, Add, Edit, x42 y39 w260 h60 , Edit
  32. Gui, Add, Button, x102 y139 w110 h30 , Button
  33. Gui, Add, Edit, x42 y179 w260 h70 , Edit
  34. ; Generated using SmartGUI Creator 4.0
  35. Gui, Show, x137 y122 h349 w402, New GUI Window
  36. Return
  37.  
  38. GuiClose:
  39. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement