Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Реверс всего текста неверной раскладки по левый контрол+ капслук
- LControl & CapsLock::
- {
- ;hModule := DllCall("LoadLibrary", "str", "AHKHelper.dll")
- ;clipSave:=clipAnsi()
- ;send ^{Insert}
- ;sleep,50
- ;text:="qwerty"
- ;clipAnsi()
- ;Result := DllCall("AHKHelper.dll\SetDllString1", "Str", "qwert")
- ;msgbox, %Result%
- ;Result := DllCall("AHKHelper.dll\GetDllString1", "Str", "qwert")
- ;msgbox, %Result%
- ; StrPut(strA, %Result%, 2)
- ; msgbox, %strA%
- ; SendInput, ^{sc01E}
- ;runwait, HelperForAHK_c.exe " /recodepls" ,PIDD
- ;FileRead, fBuff, buf
- ;msgbox, %fBuff%
- SendInput, ^{sc01E}
- LangSwitch(1)
- sleep, 50
- RecodeTextENRU()
- Return
- ;LangSwitch()
- ;sleep, 50
- ;RecodeTextENRU()
- ;rec()
- ;RecodeTextENRU()
- }
- ;реверс текста
- RecodeTextENRU()
- {
- StringCaseSense On
- AutoTrim,Off
- clipSave:=clipAnsi()
- send ^{Insert}
- sleep,50
- dest=
- text:=clipAnsi()
- StringCaseSense,On
- prevCharToEN=0
- ; АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ
- RUtoEN=F<DULT:PBQRKVYJGHCNEA{WXIO}SM">Zf,dult;pbqrkvyjghcnea[wxio]sm'.z
- RUtoSP1=хъжэбюХЪЖЭБЮ.,/"№;:?
- RUtoSP2=[];',.{}:"<>/?|@#$^&
- ;" ABCDEFGHIJKLMNOPQRSTUVWXYZ
- ENtoRU=ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯфисвуапршолдьтщзйкыегмцчня
- loop,parse,text
- {
- destChar=%A_LoopField%
- ; check explicit (non punctuations) ranges
- ifGreaterOrEqual,A_LoopField,А
- prevCharToEN=1
- else if A_LoopField between A and Z
- prevCharToEN=0
- else if A_LoopField between a and z
- prevCharToEN=0
- ; to Russian
- ifEqual,prevCharToEN,0
- { StringGetPos,i,RUtoEN,%A_LoopField%
- ifEqual,ErrorLevel,0
- Transform,destChar,chr,% i + 0xC0
- else
- { StringGetPos,i,RUtoSP2,%A_LoopField%
- ifEqual,ErrorLevel,0
- StringMid,destChar,RUtoSP1,% i+1, 1
- }
- }
- ; to English because nothing changed
- ifEqual,destChar,%A_LoopField%
- {
- StringGetPos,i,ENtoRU,%A_LoopField%
- ifEqual,ErrorLevel,0
- Transform,destChar,chr,% i + (i>=26 ? 71 : 65)
- else ; check .,;':"[]{}
- { StringGetPos,i,RUtoSP1,%A_LoopField%
- ifEqual,ErrorLevel,0,StringMid,destChar,RUtoSP2,% i+1, 1
- }
- ifNotEqual,destChar,%A_LoopField%
- prevCharToEN=1
- }
- dest=%dest%%destChar%
- }
- ; decide compatibility of unicode clipboard
- WinGetClass,cls,A
- if cls in TMsgEditor,wndclass_desked_gsk
- {
- ControlGetFocus,cls,A
- ifInString,cls,TXTRichEdit
- clipSetUnicode(dest)
- else
- Clipboard=%dest%
- }
- else
- clipSetUnicode(dest)
- sleep,50
- send +{Insert}
- sleep 50
- clipSetUnicode(clipSave)
- LangSwitch()
- }
- ; read unicode clipboard into ansi string
- clipAnsi()
- {
- StringLen,L,Clipboard
- L:=(L+1)*4
- transform,ca_Clip,unicode
- varSetCapacity(ca_WideText,L,0)
- varSetCapacity(ca_AnsiText,L,0)
- ; Convert UTF-8 to UTF-16. CP_UTF8=65001
- if dllCall("MultiByteToWideChar",uint,65001, uint,0, str,ca_Clip
- , uint,-1, str,ca_WideText, uint,L/2)
- dllCall("WideCharToMultiByte",uint,0, uint,0, str,ca_WideText
- , uint,-1, str,ca_AnsiText, uint,L/2, uint,0, uint,0)
- ; Convert UTF-16 to ANSI. CP_ACP=0
- return ca_AnsiText
- }
- ;--------------------------------------------------------------
- ; copy ansi string to clipboard in unicode mode
- clipSetUnicode(cu_AnsiText)
- {
- StringLen,L,cu_AnsiText
- L:=(L+1)*4
- varSetCapacity(cu_WideText,L,0)
- varSetCapacity(cu_UTFtext,L,0)
- ; ANSI to UTF-16. CP_ACP=0
- if dllCall("MultiByteToWideChar",uint,0, uint,0, str,cu_AnsiText
- , uint,-1, str,cu_WideText, uint,L/2)
- dllCall("WideCharToMultiByte",uint,65001, uint,0, str,cu_WideText
- , uint,-1, str,cu_UTFtext, uint,L/2, uint,0, uint,0)
- ; Convert UTF-16 to UTF-8. CP_UTF8=65001
- transform,clipboard,unicode,%cu_UTFtext%
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement