topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Tuesday March 19, 2024, 5:18 am
  • Proudly celebrating 15+ 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 11516 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 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: 5,286
    • View Profile
    • Donate to Member
Re: DONE: ahk Find and Replace
« Reply #1 on: April 10, 2012, 07:53 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 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: 5,286
    • View Profile
    • Donate to Member
Re: DONE: ahk Find and Replace
« Reply #3 on: April 10, 2012, 08:10 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 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 AM by DougleBug »

skwire

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

Code: Autohotkey [Select]
  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

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 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: 5,286
    • View Profile
    • Donate to Member
Re: DONE: ahk Find and Replace
« Reply #7 on: April 10, 2012, 09:21 AM »
You're welcome.  I'm glad to hear it works for you.   :Thmbsup: