Welcome to MTurk Crowd

Work on Amazon Mechanical Turk, learn from the best, and have fun doing it. Join the crowd today!

Sign Up

Can I make a script to find/replace?

Discussion in 'Userscripts, Extensions, and Software' started by Type2Work, Mar 10, 2016.

  1. Type2Work

    Type2Work
    Expand Collapse
    Active Member

    • Contributor
    Joined:
    Jan 19, 2016
    Messages:
    747
    Likes:
    1,038
    Can I make a script to make changes to text that I am making over and over, just like macros in Word to find and replace all occurrences?
    Is this possible with AHK or user scripts?
     
  2. clickhappier

    clickhappier
    Expand Collapse
    ┬──┬ ノ( ゜-゜ノ)

    • Subforum Curator
    • Crowd Pleaser
    Joined:
    Jan 12, 2016
    Messages:
    727
    Likes:
    1,601
    Yes, it's possible, but more context would be needed to say how.
     
  3. TSolo315

    TSolo315
    Expand Collapse
    SnapNCrackle

    • Moderator
    Joined:
    Jan 12, 2016
    Messages:
    2,397
    Likes:
    8,056
    Sounds very doable with AHK.
     
    Collapse Signature Expand Signature
    Type2Work likes this.
  4. Type2Work

    Type2Work
    Expand Collapse
    Active Member

    • Contributor
    Joined:
    Jan 19, 2016
    Messages:
    747
    Likes:
    1,038
    I'm doing hits where I am editing in a text field. I tried looking up search and replace for AHK and found a lot of threads that seem to be about running a script that finds a file on your computer and makes the changes there. I'd like to do it in the browser. I'll try to keep looking around with AHK, maybe just not searching the right terms.
     
  5. DCI

    DCI
    Expand Collapse
    Active Member

    Joined:
    Jan 14, 2016
    Messages:
    802
    Likes:
    2,772
    If you're editing text in a text field, the easiest way to do it in ahk would probably be to make a hotkey that selects all, copies to clipboard, searches string on clipboard for text and replaces with other text, then pastes.

    https://autohotkey.com/docs/commands/StringReplace.htm

    Code:
    ~::
    send ^a
    send ^c
    ClipWait
    StringReplace, clipboard, clipboard, Kansas basketball, lol, All
    send ^v
    return
    
    ^will change all instances of the text "Kansas basketball" to "lol" when you press ~ inside of the text field. Not case sensitive.
     
    #5 DCI, Apr 2, 2016
    Last edited: Apr 2, 2016