Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
Cezi din Vaslui
Femeie
23 ani
Vaslui
cauta Barbat
23 - 80 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [AUTOHOTKEY] Replace a Character with Another, Interactively Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2228
All credits go to davebrny,

Comment on usage:

Change selected text from something like "one.two.three" to "one_two_three" or "one two three"

USAGE:

- select some text
- press alt + r
- first press the character you want to replace, then the character you want to add in its place
- press enter to paste the new text
- press esc at any time to close the interactive tooltip
- use alt + shift + r to repeat the last replace without showing the tooltip


#noEnv
#singleInstance, force
sendMode input

return ; end of auto-execute ---------------------------------------------------



!r:: goSub, txt_replace
!+r::goSub, use_last_replace


txt_replace:
selected := selected_text_r()
loop, % strLen(selected) / 1.6
    div .= "- "  ; make divider
mouseGetPos, mx, my
if inStr(a_thisLabel, "use_last")
     relpaced := replace_r(selected, with := last_replace, this, that)
else relpaced := selected
toolTip, % "replace: """ . this . """`nwith: """ . that . """`n" selected "`n" div "`n" selected, 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, with, with, 1
    with .= new_input

    relpaced := replace_r(selected, with, this, that)
    tooltip, % "replace: """ . this . """`nwith: """ . that . """`n" selected "`n" div "`n" relpaced, mx, my+50
    }

tooltip, ; clear
if (with != "") and (endkey = "enter")
    {
    last_replace := with
    clipboard := relpaced
    send ^{v}
    sleep 300
    }
clipboard := save_clipboard
this := ""
with := ""
div  := ""
return


use_last_replace:
if (last_replace)
    {
    clipboard := replace_r(selected_text_r(), last_replace)
    send ^{v}
    sleep 300
    clipboard := save_clipboard
    }
return


selected_text_r() {
    global save_clipboard
    save_clipboard := clipboardAll
    clipboard := ""
    send ^{c}
    clipWait, 0.3
    if clipboard is not space
        return clipboard
}


replace_r(string, with, byRef this="", byRef that="") {
    split := strSplit(with)
    this := split[1]
    that := split[2]
    string := strReplace(string, this, that)
    return string
}


/*
[script info]
version     = 1.0
description = replace a character with another, interactively
author      = davebrny
source      =
*/


_______________________________________


pus acum 3 ani
   
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      =
*/


_______________________________________


pus acum 1 an
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2228
The following macro must be saved as an .AHK file and ran after installing AutoHotkey,

In anything you copy (CTRL+C) it will replace .jpeg.html with .jpeg, ia-o with o and ib-o with o, then paste the result and then erase clipboard:


#persistent

return

OnClipboardChange:

StringReplace, Clipboard, Clipboard, jpeg.html, jpeg, All
StringReplace, Clipboard, Clipboard, ia-o, o, All
StringReplace, Clipboard, Clipboard, ib-o, o, All
Send, ^v ; paste
Send, {Enter}

Clipboard = ; empties clipboard
Sleep, 33 ; required for the clipboard emptying to work properly

return


_______________________________________


pus acum 1 an
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2228
To simply replace a character with a space, do the following:


OnClipboardChange:
StringReplace, Clipboard, Clipboard,   , % " ", All


_______________________________________


pus acum 1 an
   
Pagini: 1  

Mergi la