想通了。我会评论它以帮助遇到此问题的任何人。我喜欢你通常可以获得功能的紧凑程度,但这件作品确实需要比我想要的多几行。如果有人能把它降低到更少,并且仍然可以工作,请告诉我!
^L::
ClipBoard := ClipString(ClipBoard, "Canceled: ", "`n",2) ;This is the function call here.
;The first parameter is the string to do stuff to, the second is what to cut out of the
;string, and the third parameter is how far after that piece to cut, so if you wrote
;Canceled: thenawholebunchofstuffthena newline, it'd remove all of it except for the
;newline. The third parameter is which mode to put ClipString to.
Return
ClipString(lString, aMarker, bMarker, Mode := 0) ;already explained above.
;Mode defaults to zero because I call the zero mode a lot.
{
If (Mode = 0) ;Mode Zero returns the ONLY the section from the original string
;between aMarker and bMarker.
Return SubStr(lString, 1, InStr(lString, aMarker)-StrLen(aMarker)) . SubStr(lString, InStr(lString, bMarker)+StrLen(bMarker))
Else If (Mode = 1) ;Mode One returns the original string with the section between aMarker
;and bMarker removed.
Return SubStr(SubStr(lString, 1, InStr(lString, bMarker)+StrLen(bMarker)-1), InStr(lString, aMarker))
Else If (Mode = 2) ;Mode Two returns the original string with all instances of aMarker
;to bMarker removed. I.E. Every occurrence of aMarker will be removed to bMarker.
{
aString := lString
StringReplace, aString, aString, %aMarker%, %aMarker%, UseErrorLevel ;Count how many
;instances of aMarker are in the original string.
CanCnt := Errorlevel ;actual count of # of aMarkers
Loop, %CanCnt% ;loop as many times as there are aMarkers
{
aString := SubStr(aString, 1, InStr(aString, aMarker)-1) . SubStr(SubStr(aString, InStr(aString, aMarker)), InStr(SubStr(aString, InStr(aString, aMarker)), bMarker)-1)
;this is a tad complicated. The first part before the concatenate takes the string, and
;keeps from the start point to the first aMarker. The concatenate adds the substring of the
;substring between aMarker and the end of the string, and the location of the substring in
;aString from the occurrence of aMarker to one position before the start of bMarker.
;An easier way to read this would be to replace "SubStr(aString, InStr(aString, aMarker))
;with a variable like bString. It shortens it up quite a bit.
}
Return aString
}
}