Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to create an AutoHotKey script such that when a string item is copied to the clipboard, a search and replace is done on the string, and the resulting string be copied to the clipboard. Ideally I'd like to happen automatically upon the event of the clipboard getting populated.

Pseudo-code for this might look like:

Assume for this example that the string to be put on the clipboard is "h:\my folder"

  1. Event of clipboard getting populated (ideally) or if necessary, I can manually trigger the action numerous ways
  2. "h:\" is replaced with "\myserver\my share\"
  3. "\myserver\my share\my folder" is copied to the clipboard

How can I do this?

share|improve this question
up vote 3 down vote accepted

You can try this, it should work, or at least get you started, I didn't have a chance to test it out:

StringReplace, clipboard, clipboard, h:\, \myserver\my share\, All

Tested and this works for me

share|improve this answer
Perfect! What does the initial "return" do? The script behavior seems the same regardless of it's presence. – Howiecamp Jul 4 '12 at 23:44
@Howiecamp The behavior is not exactly the same. Without the first return before the label (OnClipboardChange:), the script will jump into that method immediately (when the script starts) as opposed to when it should be called (when the clipboard changes). The result is that StringReplace gets executed once when it shouldn't. – iglvzx Jul 5 '12 at 23:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .