DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: DONE: ahk Find and Replace  (Read 15,432 times)

DougleBug

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 4
DONE: ahk Find and Replace
« on: April 10, 2012, 11:42 AM »
Hello All,

I need some help with ahk, I'm at the 'Hello World' stage and a bit lost with this.

Hoping to press a short-cut and ahk will find @1 and replace it with what is in my clip board.

I think the command is StringReplace but not sure on how to code it.

Any help would be greatly appreciated.

Thank you, Doug.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: DONE: ahk Find and Replace
« Reply #1 on: April 10, 2012, 12:53 PM »
Hello, DougleBug, and welcome to the site.

ahk will find @1

Can you explain this in more detail?  Find "@1" where/how, exactly?

DougleBug

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 4
Re: DONE: ahk Find and Replace
« Reply #2 on: April 10, 2012, 01:03 PM »
Hi skwire,

Working in Chrome find @1 (or something unique) within a text field, and replacing it with what is in your clip-board.

Thanks,

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: DONE: ahk Find and Replace
« Reply #3 on: April 10, 2012, 01:10 PM »
Working in Chrome find @1 (or something unique) within a text field, and replacing it with what is in your clip-board.

Right, I understand that.  What I need to know is how are you determining the text to be searched through?  AHK doesn't just "know" which text you want searched through.  Do you have this text selected/highlighted or something like that?

DougleBug

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 4
Re: DONE: ahk Find and Replace
« Reply #4 on: April 10, 2012, 01:22 PM »
Just the web page really, but I could select the text.

A bit like this Quick Reply box, press one key to chance 'text' for example in to what you have copied.

Edit: before posting, while still editable.
« Last Edit: April 10, 2012, 01:27 PM by DougleBug »

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: DONE: ahk Find and Replace
« Reply #5 on: April 10, 2012, 02:04 PM »
Consider the following example:

Code: (autohotkey)
^1:: ; Ctrl+1
{
    mySavedClip := Clipboard
    Clipboard := "" ; Flush the clipboard
    SendInput, ^c
    ClipWait, 2
    StringReplace, Clipboard, Clipboard, @1, % mySavedClip, All
}
Return

Because programmatically getting text from a browser is an exercise in frustration, you must first highlight the text you want searched through and then press the Ctrl+1 hotkey.  After doing that, any occurrences of @1 will be replaced with what was originally on your clipboard and then the new text is put back on the clipboard.

DougleBug

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 4
Re: DONE: ahk Find and Replace
« Reply #6 on: April 10, 2012, 02:19 PM »
Wow that works bob on, thank you very much for you help in this.

This is just what I was after, Doug.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: DONE: ahk Find and Replace
« Reply #7 on: April 10, 2012, 02:21 PM »
You're welcome.  I'm glad to hear it works for you.  :Thmbsup:

Original address: https://www.donationcoder.com/forum/index.php?topic=30613.0