MyTetra Share
Делитесь знаниями!
мой вариант скрипта автоматического создания hotstrings
Время создания: 22.04.2017 12:43
Раздел: AutoHotkey - Programs
Запись: xintrea/mytetra_db_mcold/master/base/1492854193wxgxxw7bnj/text.html на

!h:: ; Win+H hotkey

; Get the text currently selected. The clipboard is used instead of

; "ControlGet Selected" because it works in a greater variety of editors

; (namely word processors). Save the current clipboard contents to be

; restored later. Although this handles only plain text, it seems better

; than nothing:

AutoTrim Off ; Retain any leading and trailing whitespace on the clipboard.

ClipboardOld = %ClipboardAll%

Clipboard = ; Must start off blank for detection to work.

Send ^c

ClipWait 1

if ErrorLevel ; ClipWait timed out.


; Replace CRLF and/or LF with `n for use in a "send-raw" hotstring:

; The same is done for any other characters that might otherwise

; be a problem in raw mode:

StringReplace, Hotstring, Clipboard, ``, ````, All ; Do this replacement first to avoid interfering with the others below.

StringReplace, Hotstring, Hotstring, `r`n, ``r, All ; Using `r works better than `n in MS Word, etc.

StringReplace, Hotstring, Hotstring, `n, ``r, All

StringReplace, Hotstring, Hotstring, %A_Tab%, ``t, All

StringReplace, Hotstring, Hotstring, `;, ```;, All

Clipboard = %ClipboardOld% ; Restore previous contents of clipboard.

; This will move the InputBox's caret to a more friendly position:

SetTimer, MoveCaret, 10

; Show the InputBox, providing the default hotstring:

InputBox, Hotstring, New Hotstring, Type your abreviation at the indicated insertion point. You can also edit the replacement text if you wish.`n`nExample entry: ::btw`::by the way,,,,,,,, :*:`::%Hotstring%

if ErrorLevel ; The user pressed Cancel.


IfInString, Hotstring, :R`:::


MsgBox You didn't provide an abbreviation. The hotstring has not been added.



; Otherwise, add the hotstring and reload the script:

FileAppend, `n%Hotstring%, %A_ScriptFullPath% ; Put a `n at the beginning in case file lacks a blank line at its end.


Sleep 200 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.

MsgBox, 4,, The hotstring just added appears to be improperly formatted. Would you like to open the script for editing? Note that the bad hotstring is at the bottom of the script.

IfMsgBox, Yes, Edit



IfWinNotActive, New Hotstring


; Otherwise, move the InputBox's insertion point to where the user will type the abbreviation.

Send {Home}{Right 3}

SetTimer, MoveCaret, Off


MyTetra Share v.0.60
Яндекс индекс цитирования