2

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

+^{Left} 

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

Thank you for your help.

0
2
F1::
ClipSaved := ClipboardAll  ; save clipboard
Loop
{
    If GetKeyState("F2","P")  ; terminate the loop whenever you want by pressing F2
        break    
    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
return

http://ahkscript.org/docs/misc/Clipboard.htm

3
  • 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.