Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 04, 2015, 01:53:22 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: DONE: ahk Find and Replace  (Read 5260 times)

DougleBug

  • Supporting Member
  • Joined in 2012
  • **
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
DONE: ahk Find and Replace
« on: April 10, 2012, 06:42:45 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

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,393
    • View Profile
    • Donate to Member
Re: DONE: ahk Find and Replace
« Reply #1 on: April 10, 2012, 07:53:02 AM »
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
  • **
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: DONE: ahk Find and Replace
« Reply #2 on: April 10, 2012, 08:03:32 AM »
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

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,393
    • View Profile
    • Donate to Member
Re: DONE: ahk Find and Replace
« Reply #3 on: April 10, 2012, 08:10:41 AM »
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
  • **
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: DONE: ahk Find and Replace
« Reply #4 on: April 10, 2012, 08:22:05 AM »
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, 08:27:21 AM by DougleBug »

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,393
    • View Profile
    • Donate to Member
Re: DONE: ahk Find and Replace
« Reply #5 on: April 10, 2012, 09:04:52 AM »
Consider the following example:

Code: Autohotkey
  1. ^1:: ; Ctrl+1
  2. {
  3.     mySavedClip := Clipboard
  4.     Clipboard := "" ; Flush the clipboard
  5.     SendInput, ^c
  6.     ClipWait, 2
  7.     StringReplace, Clipboard, Clipboard, @1, % mySavedClip, All
  8. }
  9. Return
  10.  

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
  • **
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: DONE: ahk Find and Replace
« Reply #6 on: April 10, 2012, 09:19:07 AM »
Wow that works bob on, thank you very much for you help in this.

This is just what I was after, Doug.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,393
    • View Profile
    • Donate to Member
Re: DONE: ahk Find and Replace
« Reply #7 on: April 10, 2012, 09:21:26 AM »
You're welcome.  I'm glad to hear it works for you.   :Thmbsup: