Advertisement
Guest User

Untitled

a guest
Aug 5th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. ConvertText(Text, ByRef OppositeLayout)
  2. {
  3. Static Cyr := "ЁЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ/ёйцукенгшщзхъфывапролджэячсмитьбю,.""№;?:"
  4. , Lat := "~QWERTYUIOP{}ASDFGHJKL:""ZXCVBNM<>|``qwertyuiop[]asdfghjkl;'zxcvbnm,.?/@#$&^"
  5.  
  6. RegExReplace(Text, "i)[A-Z@#\$\^&\[\]'`\{}]", "", LatCount)
  7. RegExReplace(Text, "i)[А-ЯЁ№]", "", CyrCount)
  8.  
  9. if (LatCount != CyrCount)
  10. {
  11. CurrentLayout := LatCount > CyrCount ? "Lat" : "Cyr"
  12. OppositeLayout := LatCount > CyrCount ? "Cyr" : "Lat"
  13. }
  14. else
  15. {
  16. threadId := DllCall("GetWindowThreadProcessId", Ptr, WinExist("A"), UInt, 0, Ptr)
  17. landId := DllCall("GetKeyboardLayout", Ptr, threadId, Ptr) & 0xFFFF
  18. if (landId = 0x409)
  19. CurrentLayout := "Lat", OppositeLayout := "Cyr"
  20. else
  21. CurrentLayout := "Cyr", OppositeLayout := "Lat"
  22. }
  23. Loop, parse, Text
  24. NewText .= (found := InStr(%CurrentLayout%, A_LoopField, 1))
  25. ? SubStr(%OppositeLayout%, found, 1) : A_LoopField
  26. Return NewText
  27. }
  28.  
  29. :?:!шиф::
  30. Input, firs, V, {Enter}
  31. msgbox, ConvertText(%firs%, Layout)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement