选择文本直到找到字符

选择文本直到找到字符

我想了解如何选择文本

+^{Left} 

直到找到特定字符(在本例中为“-”)。

感谢您的帮助。

答案1

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

相关内容