I'm currently making a basic clipboard manager, I've got the basics working, copy, display, save and delete. However, has the text file is CSV delimited:
SHORT TITLE, DATE AND TIME, FULL CLIPBOARD TEXT
I'm struggling to be able to allow commas and line breaks in my clipboard content, otherwise the loop sees it has more delimited text. So say i copy "hi, im mike" the listview only shows "hi"
I've tried using an if on the a_index to break the loop after 3 so it doesnt look for anymore delimiters.
Code: Select all
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
^m::
Gui -MinimizeBox -MaximizeBox
Gui Add, ListView, x8 y8 w297 h170 gClipboardData, Clipboard|Date Added|D
Gui Add, Button, x232 y384 w50 h25 gDeleteEntry, Delete
Gui Add, Button, x32 y384 w50 h25 gCopyContent, Copy
Gui Add, Edit, x8 y207 w297 h170 vContent
Gui Add, Text, x8 y180 w95 h23 +0x200, Clipboard Content:
Gui Show, w481 h460 AutoSize, Clipboard Manager
LV_ModifyCol("3","0")
Loop, Read, clipboard.txt
{
Loop, parse, A_LoopReadLine, CSV
{
Row%A_Index% := A_LoopField
if A_Index >= 3
{
break
}
}
LV_Add("",Row1,Row2,Row3)
LV_ModifyCol("1","AutoHdr")
}
return
ClipboardData:
if A_GuiEvent = DoubleClick
{
LV_GetText(clipdata, A_EventInfo, 3)
GuiControl, Text, Content, %clipdata%
return
}
CopyContent:
Gui, Submit, NoHide
clipboard := Content
MsgBox Content saved to Clipboard!
return
DeleteEntry:
Loop
{
row := LV_GetNext(row -1)
if not row
return
LV_Delete(row)
GuiControl, Text, Content,
}
return
^b::
Send, ^c
copied := Clipboard
;~ replace := StrReplace(copied, ",", " ", All)
FormatTime, DateAdded, A_Now, dd/MM/yyyy
FileAppend, Entry..`,%DateAdded%`,%copied%, clipboard.txt
return
GuiClose:
FileDelete, clipboard.txt
Loop % LV_GetCount()
{
RowNum := A_Index
Loop, 3
{
LV_GetText(save, RowNum, A_Index)
FileAppend, %save%`,, clipboard.txt
}
LV_GetText(save, RowNum, 4)
FileAppend, %save%`n, clipboard.txt
}
Gui, Destroy