Ability to store multiple copied entries in an array and paste them whenever you like, as many times as needed.
Ability to split up a copied selection into individual parts to be pasted based on tabs/newlines/cells (from Excel).
Ability to look through every entry that was copied and select the one to be pasted.
Ability to run code directly after pasting from a selection, such as code to sleep a certain amount of time and then tab directly afterward.
Some functionality to alter what was copied, such as trimming spaces off the ends of copied entries.
This script is controlled using the F1-F5 keys.
F1 will take whatever is currently selected and copy it to an array that you can scroll backwards and forwards through using F2 and F4. F3 will paste the currently selected entry in the array and increment the array by 1 automatically. F5 will reopen the settings gui.
I've included a video I made to demonstrate its features and use-cases:
Code here (ClipArray V1.1):
Code: Select all
/*
Created by Epishade
Credit to AfterLemon for his In-Line Send Sleep Function
*/
#NoEnv
#SingleInstance Force
SendMode Input
Global Array := []
Global F1Count = 0
Global F3Count = 0
Global DelimitByCell = 1
Global InterpretAsCode = 1
Global TrimEnds = 1
Global RemoveBlanks = 0
Gui:
Gui, Font, s10
Gui, Add, CheckBox, vDelimitByCell Checked%DelimitByCell%, Delimit selection by tabs/newlines/cells?
Gui, Add, CheckBox, vInterpretAsCode Checked%InterpretAsCode%, Some lines such as abc{1000}{tab} etc will be interpretted as code. Allow?
Gui, Add, CheckBox, vTrimEnds Checked%TrimEnds%, Trim spaces from the ends?
Gui, Add, CheckBox, vRemoveBlanks Checked%RemoveBlanks%, Remove blanks between entries?
Gui, Add, Button, x12 y100 w100 vButtonSave Default, Save
Gui, Add, Button, x125 y100 w100 vButtonHelp, Help
Gui, Add, Button, x238 y100 w100 vButtonReset, Reset
Gui, Show, , New GUI Window
Return
ButtonSave:
Gui, submit
Return
ButtonHelp:
MsgBox,
(
This script is used to copy and store large amounts of information to be manipulated and sequentially pasted as needed. It works best with Excel, but can also be used to copy information from elsewhere.
F1 = Copies the current selection and stores in array.
F2 = Decreases the current location in the array to be pasted.
F3 = Sends or pastes the current entry in the array.
F4 = Increases the current location in the array to be pasted.
F5 = Opens the Gui to make any settings changes.
Delimit selection by tabs/newlines/cells allows the user to select multiple cells to be copied, each cell of which will be placed independently in the array from the others.
Interpretting lines as code allows the user to write code into the copied selection, which will be executed when that selection is sent using F3.
This is useful for sending code to tab a certain amount of times or sleep for a little bit upon sending the array entry. Sleep is denotated by a number within curly braces. Example: Copying a cell with abc{1000}{tab} will, when pasted, result in "abc" being sent followed by a sleep of 1 second, and then a tab keypress.
Note that certain symbols, if copied, will also attempt to run code or alter the keys immediately following them. Example: Copying a cell with ^c anywhere within the text will interpret that as ctrl + c (copy).
Trim spaces from the ends removes any spaces from the ends of copied entries.
Remove blanks between entries will mean that any empty line data will be excluded in the copy array.
This is useful for ignoring blank entries in between sets of data.
)
Return
ButtonReset:
Reload
Return
GuiClose:
ExitApp
Return
F1::
Clipboard := ""
Send ^c
ClipWait, 1
Gosub ClipboardFormat
Return
F2::
F3Count -= 1
F1Count := F3Count
Gosub WatchToolTip
Return
F3::
F3Count += 1
F1Count := F3Count
If (InterpretAsCode = 0) ; Uses SendRaw.
SendRaw % Array[F3Count]
If (InterpretAsCode = 1) ; Uses Send function.
Send(Array[F3Count])
Gosub WatchToolTip
Return
F4::
F3Count += 1
F1Count := F3Count
Gosub WatchToolTip
Return
F5::
GUI Destroy
Gosub GUI
Return
WatchTooltip:
NextItem := Array[F3Count+1]
PreviousItem := Array[F3Count]
EntryCount := F3Count
ToolTip, Entry: %EntryCount% `r`nNext Entry: %NextItem% `r`nPrevious Entry: %PreviousItem%
SetTimer, RemoveTooltip, -3000
Return
RemoveTooltip:
ToolTip
Return
ClipboardFormat:
If (DelimitByCell = 0)
{
F1Count += 1
Clipboard := StrReplace(Clipboard,"`r`n","`n") ; Fixes double-newline issue.
Array[F1Count] := ClipboardTrim(Clipboard)
If (RemoveBlanks = 1) && Trim(Clipboard = "`n") ;If Clipboard is only composed of a newline, then it can be ignored.
{
F1Count -= 1
}
}
If (DelimitByCell = 1)
{
Clipboard := StrReplace(Clipboard,"`r`n","¶") ; Replaces newlines (vertical cells) with ¶ symbol.
Clipboard := StrReplace(Clipboard,"`t","¶") ; Replaces tabs (horizontal cells) with ¶ symbol.
If (SubStr(Clipboard,0) = "¶") ; Removes the last ¶ symbol from the string, if it exists, meaning selection was copied from excel.
{
Clipboard := Substr(Clipboard, 1, StrLen(Clipboard) - 1)
}
Loop, Parse, Clipboard, "¶"
{
F1Count += 1
Array[F1Count] := ClipboardTrim(A_LoopField)
If (RemoveBlanks = 1) && (Array[F1Count] = "") ;If Clipboard is blank, then it can be ignored.
{
F1Count -= 1
}
}
}
Return
ClipboardTrim(StringToTrim)
{
If (TrimEnds = 1)
{
StringToTrim := Trim(StringToTrim)
}
Return StringToTrim
}
Send(String, Raw:="", RawKeys:="")
{
D:="{",E="}",S:=String D,i=0,T=1,R=(Raw?1:(SubStr(S,1,5)="{RAW}"?1:0)),M="+,!,#,^",K=RawKeys
While i:=InStr(S,D,V,i+1){
Send,% (R?"{RAW}":"") SubStr(S,T,InStr(S,D,V,i)-T)
B:=SubStr(S,InStr(S,D,V,i)+1,InStr(S,E,V,i)-StrLen(S)-1),A=SubStr(B,1,-1)
If InStr(S,D,V,i+1)
If(B&1=""){
If(A&1!="")
Sleep,% A*1000
else{
L:=(!R?(InStr(S,E,V,i)-StrLen(B)-2>4?4:InStr(S,E,V,i)-StrLen(B)-2):0)
Loop,%L%{
C:=SubStr(SubStr(S,InStr(S,D,V,i)-L,L),A_Index,1)
If C in %M%
{ C:=SubStr(S,InStr(S,D,V,i)-(L+1-A_Index),L+1-A_Index)
break
}else C:=""
}Send,% (K?"{RAW}":"") C "{" B "}"
}}else Sleep,%B%
T:=InStr(S,E,V,i+1)+1
}}
I wrote this primarily to be used with Excel. As such, when multiple cells in Excel are selected and copied to the copy-array using F1, each cell will be split from the others and placed as its own separate entry in the copy-array. This setting works based on tabs and newlines, so if you are copying from somewhere outside of excel and your data has either tabs or newlines, it will attempt to split those entries into their own spots in the copy-array. If you don't want that functionality to split apart copied entries based on tabs or newlines, that can be unchecked in the gui settings.
Any copied entries that include curly brackets will attempt to run whatever is within those curly brackets as if they were code. If you have entries with curly brackets that you want to be pasted literally instead of ran as code, you will want to uncheck that option in the gui settings.
If your copied selection has a literal ¶ symbol in it (not likely), there may be some issues in splitting that copied selection up, and turning off the delimiter option may work better.
I'd also like to extend some credit to AfterLemon for his in-line sleep script found here:
viewtopic.php?t=392
Hope this script comes in handy for some people!