I`d like to learn how I can select text like with


until a specific character ("-" in this case) has been found.

Thank you for your help.

ClipSaved := ClipboardAll  ; save clipboard
    If GetKeyState("F2","P")  ; terminate the loop whenever you want by pressing F2
    clipboard =           ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
    ; Send, +^{Left}      ; select text by whole words to the left
    Send, +{Left}         ; select text by single characters to the left
    Send, ^c              ; copy selected text
    ClipWait              ; wait until the clipboard contains data
    StringLeft, OutputVar, clipboard, 1  ; save the first character from the left side of the clipboard in the variable OutputVar
    If OutputVar = -      ; if the specific character "-" has been found
        break             ; terminate the loop
clipboard := ClipSaved    ;restore original clipboard


  • 4
    Can you explain what this code does? – bwDraco Feb 20 '15 at 23:58
  • Thanks, that basically does what I wanted. It works the following way. Place and left click with your mouse to the rightmost position from which you want to select your text leftward until the "-" character has been found and press F1. One caveat however is that it seems to be working in textfiles but not on websites. It simply doesn`t stop selecting text and passes by any characters you want it to stop at. – colonel_claypoo Feb 27 '15 at 10:29
  • I've replaced "+^{Left}" by "+{Left}". Now it works also on websites. – user3419297 Feb 27 '15 at 21:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.