Mrrrr
AdMiN
Inregistrat: acum 17 ani
Postari: 2228
|
|
Same as above, but improved (version 1.2)
All credits go to davebrny,
Comment on usage:
This doesn't work if there are any linefeeds / multiple lines in the selected text
- select some text - press alt + s - type the character or word that you want to swap the text at - press enter to replace the selected text with the new text - press esc at any time to close the interactive tooltip - use alt shift + s to repeat the last swap without showing the tooltip
Examples:
original text ----------------------------- swap at --------------------- swapped text us and them ---------------------------- and ------------------------- them and us daddy or chips -------------------------- or --------------------------- chips or daddy this place to that place ----------------- to --------------------------- that place to this place miles in kilometers --------------------- in --------------------------- kilometers in miles some word, another word -------------- , ---------------------------- another word, some word 54 - 46 ---------------------------------- - ---------------------------- 46 - 54 a + b = c -------------------------------- = ---------------------------- c = a + b
#noEnv #singleInstance, force sendMode input return ; end of auto-execute ---------------------------------------------------
!s:: goSub, text_swap !+s::goSub, repeat_last_swap ; !+s::goSub, repeat_last_swap_interactive
text_swap: repeat_last_swap_interactive: selected := selected_text() loop, % strLen(selected) / 1.6 div .= "- " ; make divider mouseGetPos, mx, my if inStr(a_thisLabel, "repeat_last") swapped := swap(selected, this := last_swap) else swapped := selected toolTip, % "swap at: """ . this . """`n`n" selected "`n" div "`n" swapped, mx, my+50
loop, { input, new_input, L1, {enter}{esc}{backspace} endkey := strReplace(errorLevel, "EndKey:", "") if endkey contains enter,escape break if (endkey = "backspace") stringTrimRight, this, this, 1 if inStr(selected, new_input) this .= new_input
swapped := swap(selected, this) tooltip, % "swap at: """ . this . """`n`n" selected "`n" div "`n" swapped, mx, my+50 }
tooltip, ; clear if (this != "") and (endkey = "enter") { last_swap := this clipboard := swapped send ^{v} sleep 300 } clipboard := save_clipboard this := "" div := "" return
repeat_last_swap: if (last_swap) { clipboard := swap(selected_text(), last_swap) send ^{v} sleep 300 clipboard := save_clipboard } return
selected_text() { global save_clipboard save_clipboard := clipboardAll clipboard := "" send ^{c} clipWait, 0.3 if clipboard is space return if !inStr(clipboard, "`n") return clipboard }
swap(string, at_this) { stringGetPos, pos, string, % at_this stringMid, left, string, pos, , L stringGetPos, pos, string, % at_this stringMid, right, string, pos + strLen(at_this) + 1
stringRight, left_space, left, % strLen(left) - strLen(rTrim(left)) stringLeft, right_space, right, % strLen(right) - strLen(lTrim(right))
return lTrim(right) . left_space . at_this . right_space . rTrim(left) }
/* [script info] version = 1.2 description = swap text at a certain character or word, interactively author = davebrny source = */ |
_______________________________________
|
|