Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance force
- #InstallKeybdHook
- #InstallMouseHook
- SetWorkingDir %A_ScriptDir%
- ; MyScript 0.1
- /*
- клавиши:
- ДВОЙНОЕ нажатие win — запуск диспетчера задач
- alt + - — вставка длинного тире
- */
- ;===================================================================
- ;CONST
- global iniFileName := "MyKeysScript.ini"
- global mode := "standart"
- ;замена двух слешей рядом с шифт и ввод на их дубли.
- ;sc56h::LShift
- return
- ;sc2Bh::Enterf
- return
- ; а если нужно их вставить, используем альт \
- ;~LWin & sc2Bh:: SendInput {ASC 092}
- Return
- ;а если нужно их вставить, используем альт |
- ;~RWin & sc2Bh:: SendInput {ASC 124}
- Return
- ;~Alt & sc56h:: SendInput {ASC 124}
- Return
- ; вставка кавычек ==========================================================================
- ;1 , - вставка елочек «»
- ~Alt & vkBC:: SendInput, {ASC 0171}{ASC 0187}{Left}
- Return
- ; . - вставка елочек «»
- ~Alt & vkBE:: SendInput {ASC 0171}{ASC 0187}{Left}
- Return
- ; ' - вставка двойных кавычек ""
- ~Alt & vkDE:: SendInput {ASC 34}{ASC 34}{Left}
- Return
- ;==========================================================================
- ; вставка длинного тире (альт + минус)
- ~Alt & vkBD:: SendInput, {ASC 0151}
- Return
- ;==========================================================================
- ; ДВОЙНОЕ нажатие windows — запуск диспетчера задач
- ~LWin::
- {
- if (A_PriorHotkey <> "~LWin" or A_TimeSincePriorHotkey > 230)
- {
- ;ожидать, пока клавиша не будет отпущена (чтобы исключить срабатывание от простого удержания нажатой клавиши)
- KeyWait, LWin
- Return
- }
- KeyWait, LWin
- Run taskmgr.exe
- Return
- }
- ~RWin::
- {
- if (A_PriorHotkey <> "~RWin" or A_TimeSincePriorHotkey > 230)
- {
- ;ожидать, пока клавиша не будет отпущена (чтобы исключить срабатывание от простого удержания нажатой клавиши)
- KeyWait, RWin
- Return
- }
- KeyWait, RWin
- Run taskmgr.exe
- Return
- }
- ;==========================================================================
- ; переключение режима капслук по win + capslock
- ;сочетания капслук + ...
- #NoEnv
- #If GetKeyState("CapsLock", "P")
- ; мультимедиа клавиши капс+f5-f8
- ; регулировка громкости капс и стрелки вверх, вниз.
- UP:: ; /? keycode insert /
- send, {Volume_Up}
- return
- Down:: ; /? keycode insert /
- send, {Volume_Down}
- return
- Numpad0:: ; /? keycode insert /
- send, {Volume_Mute}
- return
- vk30:: ; /? keycode insert /
- send, ->
- return
- vkBF:: ; /? keycode insert /
- send, {ASC 47}
- return
- ; insert |
- ;sc2Bh::
- SendInput {ASC 124}
- return
- vk4E:: ; n keycode
- SendInput, {ctrl down}
- SendInput, {left}
- SendInput, {Ctrl up}
- return
- vkBE:: ; >. keycode
- SendInput, {ctrl down}
- SendInput, {Right}
- SendInput, {Ctrl up}
- return
- ;vim-подобная навигация h - left, j - down, k - up, l - right
- vk48:: ; h keycode
- send {left}
- return
- vk4C:: ; l keycode
- send {right}
- return
- vk4B:: ; k keycode
- send {up}
- return
- vk4a:: ;j keycode
- Send {Down}
- Return
- ; sending escape
- vk50:: ; P keycode
- SendInput {Ctrl down}
- SendInput, {Shift down}
- SendInput {Right}
- SendInput, {shift up}
- SendInput, {ctrl up}
- return
- ;раскрывание списка (аналог альт+стрелка вниз)
- vk20:: ; space keycode
- send {Lalt down}
- sleep, 64
- send, {down}
- sleep, 64
- send {Lalt up}
- return
- ;раскрывание списка (аналог альт+стрелка вниз)
- vk55:: ; u keycode
- SendInput {Ctrl down}
- SendInput, {Shift down}
- SendInput {Left}
- SendInput, {shift up}
- SendInput, {ctrl up}
- return
- vk49:: ; I keycode
- SendInput, {shift down}
- SendInput, {up}
- SendInput {shift up}
- return
- vk4F:: ; O keycode
- SendInput, {shift down}
- SendInput, {down}
- SendInput {shift up}
- return
- ;вставка даты и времени 19.06.2015_22:30
- vk54:: ; t keycode
- if (mode = "standart")
- {
- FormatTime, DateString,, ShortDate
- FormatTime, TimeString,, Time
- send %DateString%_%TimeString%{Space}
- }
- if (mode = "apprun")
- {
- Run, "c:\!my_files\apps\sys\sys_filemanagers\TC_8.51a_x86\totalcmd.exe"
- }
- return
- ; wasd - навигация home end pageup pagedown
- ;w
- vk57:: SendInput {PgUp}
- Return
- ;s
- vk53:: SendInput {PgDn}
- Return
- ;a
- vk41:: SendInput {Home}
- Return
- ;d
- vk44:: SendInput {End}
- Return
- ; c
- vk43:: run, calc.exe
- return
- ; переключение режимов клавиш
- ;numpad0
- vk60::
- TrayTip, Current keys mode is %mode%, , 5, 33
- return
- Numpad1::
- mode := "standart"
- TrayTip, Keys mode is %mode%, Mode keys is changed. , 5, 33
- return
- Numpad2::
- mode := "apprun"
- TrayTip, Keys mode is %mode%, Mode keys is changed. , 5, 33
- return
- /*
- */
- ;-------------------------------------------------------------
- ; капс + таб - неразрывный абзац.
- tab:: SendInput {ASC 255}{ASC 255}{ASC 255}{ASC 255}
- #if
- ~Lwin & CapsLock:: SetCapsLockState, % GetKeyState("Capslock", "T") ? "Off" : "On"
- ;------------------------------------------------------
- ;Переключение языка по капслук
- $CapsLock::
- {
- LangSwitch(1)
- return
- }
- $CapsLock up::
- {
- LangSwitch(2)
- Return
- }
- ; реверс ВЫДЕKЕННОГО текста
- ~LAlt & CapsLock::
- {
- LangSwitch(2)
- sleep, 50
- RecodeTextENRU()
- Return
- }
- ; реверс последнего слова
- ; удаление последнего слова. Иногда контрл+бэкспейс вместо удаления слова вставляет нечитаемый символ.
- ~Ctrl & backspace::
- {
- SendInput, {Ctrl down}+{Shift down}+{left}
- SendInput, {Ctrl up}
- SendInput, {Shift up}
- sendInput, {delete}
- return
- }
- ; реверс раскладки последнего слова
- ~RAlt & CapsLock::
- {
- SendInput, {Ctrl down}+{Shift down}+{left}
- SendInput, {Ctrl up}
- SendInput, {Shift up}
- LangSwitch(2)
- sleep, 50
- RecodeTextENRU()
- Return
- }
- ;----------------------------------------------------
- ;Реверс всего текста неверной раскладки по левый контрол+ капслук
- LControl & CapsLock::
- {
- SendInput, ^{sc01E}
- LangSwitch(1)
- sleep, 50
- RecodeTextENRU()
- Return
- }
- ;переключение языка
- LangSwitch( iKeyDownUp=0 )
- {
- ; если капслук зажат больше 180 милисекунд то не переключаем язык
- static tickLast
- IfEqual, iKeyDownUp, 1
- {
- tickLast=%A_TickCount%
- return
- }
- IfEqual,iKeyDownUp,2
- If(A_TickCount-tickLast>180)
- return
- ; читаем настройки секции изменения языка, параметр «method»
- ; MsgBox, langchangemeghod "%langChangeMethod%"
- ; MsgBox, workDir "%A_WorkingDir%"
- ; MsgBox, inifilename "%iniFileName%"
- IfExist %A_WorkingDir%\%iniFileName%
- {
- IniRead, langChangeMethod, %A_WorkingDir%\%iniFileName%, CHANGE LANG, method
- ; MsgBox, %A_WorkingDir%\%iniFileName%
- }
- If (langChangeMethod == "alt+shift")
- {
- ;MsgBox, "altshift"
- SendInput, {LAlt down}
- SendInput, {LShift}
- sendInput, {LAlt up}
- }
- else
- {
- If (langChangeMethod == "control+shift")
- {
- ;MsgBox, "controlshift"
- SendInput, {LControl down}
- SendInput, {LShift}
- sendInput, {LControl up}
- }
- else
- {
- If (langChangeMethod == "win+space")
- {
- ;MsgBox, "winspace"
- SendInput, {LWin down}
- SendInput, {Space}
- sendInput, {LWin up}
- }
- else
- {
- TrayTip, Error reading parameter file %iniFileName%, Switching layout alt+shift, 5, 35
- SendInput, {LAlt down}
- SendInput, {LShift}
- sendInput, {LAlt up}
- }
- }
- }
- }
- ;реверс текста
- 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%
- }
- /*
- rec()
- {
- StringCaseSense On
- AutoTrim,Off
- clipSave:=clipAnsi()
- send ^{Insert}
- sleep,50
- /*text:=clipAnsi()
- StringCaseSense,On
- ;Result := DllCall("HelperForAHK.dll\DecodeTextENRU_RUEN", "Str", text)
- ;msgbox, %Result%
- arrEN = qwerty
- arrRU = huisob
- EN = 0
- RU = 0
- ;
- loop,parse,text
- {
- currSymb=%A_LoopField%
- ; check EN
- loop, parse, arrEN
- {
- chSymb = %A_LoopField%
- if(chSymb= currSymb)
- EN := 1
- }
- if (EN = 0)
- RU:=1
- ;msgbox, %text%
- ; to rus
- if (EN = 1)
- {
- loop, parse, text
- {
- cs = %A_LoopField%
- if (cs = currSymb)
- {
- StringGetPos, i, arrEN, %cs%
- StringMid, newstr, arrRU, i, i+1
- dest=%dest%%newstr%
- break
- }
- }
- break_outer:
- }
- }
- ; 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()
- }
- RecodeTextENRU()
- {
- StringCaseSense On
- AutoTrim,Off
- clipSave:=clipAnsi()
- send ^{Insert}
- sleep,50
- text:=clipAnsi()
- runwait, HelperForAHK_c.exe "%text%" ,PIDD
- sleep, 1
- FileRead, dest, buf
- /* 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%
- ;msgbox, %destChar%
- ; 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
- ;msgbox, %dest%
- 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
- }
- 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