Skip to content

Instantly share code, notes, and snippets.

@JoeGlines
Created May 12, 2023 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoeGlines/36d570a8714a457d244448c2e734febc to your computer and use it in GitHub Desktop.
Save JoeGlines/36d570a8714a457d244448c2e734febc to your computer and use it in GitHub Desktop.
Clipboard_Backup_Copy_Selected_Text()
StringUpper, Clipboard,Clipboard ;uppercase all
Sort, Clipboard, U CL ;sort, case insensitive, remove duplicates
Clipboard:=Remove_Blank_Lines(clipboard)
Clipboard := RegExReplace(Clipboard,"m)^[_\s]*|[_\s]*$") ;removes spaces at beginning and end
Clipboard_Paste_and_Restore_Clipboard(Clipboard_Backup)
return
;***********Remove Blank lines*******************
Remove_Blank_Lines(text){
Loop,parse,text,`n`r ;loops through lines
{
New:=RegExReplace(A_LoopField,"^\s?$","") ;if line only has white space
If (new!="")
NewText.=new "`r`n"
}
return :=NewText
}
;******for clipboard manipulation and restoring original clipboard*********************************
Clipboard_Backup_Copy_Selected_Text(){
ClipBack := Clipboard ;Store full version of Clipboard
clipboard = ; Empty the clipboard
SendInput, ^c
ClipWait, 1
If ErrorLevel { ;Added errorLevel checking
Clipboard:=ClipBack ;Restore Clipboard
MsgBox, No text was sent to clipboard
Return
}
Return ClipBack
}
;**********************Paste and Restore clipboard*********************************
Clipboard_Paste_and_Restore_Clipboard(Clipboard_Backup,SleepTime="600"){
Send ,^v
sleep, %SleepTime%
Clipboard:=Clipboard_Backup
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment