Skip to content

Instantly share code, notes, and snippets.

@0x4a
Created January 16, 2014 03:11
Show Gist options
  • Save 0x4a/8449214 to your computer and use it in GitHub Desktop.
Save 0x4a/8449214 to your computer and use it in GitHub Desktop.
saves #clipboard to #csv #work
#SingleInstance, force
#NoEnv
#persistent
FileEncoding UTF-8
SetWorkingDir %A_ScriptDir%
WaitClose := 1
saveFileName := A_ScriptDir "\" SubStr( A_ScriptName, 1, -4 )
saveFileExt := "csv"
saveFile := saveFileName . "." . saveFileExt
timestamp = %A_YYYY%-%A_MM%-%A_DD%_-_%A_Hour%-%A_Min%-%A_SEC%
Gosub INIT
#y::appendClipboard(saveFile)
while 1
{
sleep 50
}
ExitApp
INIT:
; check file
if FileExist(saveFile)
{
SetTimer, customMsgbox, 50
Msgbox, 307,alte Datei gefunden!, Es existiert bereits eine Kopie von`n"%saveFile%"`n`nNeue Datei beginnen (Backup wird angelegt),`noder mit der alten Datei weiterarbeiten?
Ifmsgbox Yes
{
; make backup
Filemove, %saveFile%, %saveFileName%_%timestamp%.%saveFileExt%
; create new file
file := FileOpen(saveFile, "w")
if !IsObject(file)
{
MsgBox Can't open "%saveFile%" for writing.
ExitApp
}
file.Write("ItemID;other`n")
file.Close()
}
else Ifmsgbox Cancel
{
ExitApp
}
}
else
{
; create new file
file := FileOpen(saveFile, "w")
if !IsObject(file)
{
MsgBox Can't open "%saveFile%" for writing.
ExitApp
}
file.Write("ItemID;other`n")
file.Close()
}
return
appendClipboard(location)
{
sleep 100
Send ^c
StringReplace, clipboard, clipboard,`r`n,, All
file := FileOpen(location, "a")
if !IsObject(file)
{
MsgBox Can't open "%saveFile%" for writing.
ExitApp
}
file.Write(clipboard . ";`n")
file.Close()
cursorMessage("Added """ . clipboard . """")
return
}
customMsgbox:
{
IfWinNotExist, alte Datei gefunden!
return ; Keep waiting.
SetTimer, customMsgbox, off
WinActivate
ControlSetText, Button1, &Neu
ControlSetText, Button2, &Weiter
ControlSetText, Button3, &Abbrechen
return
}
cursorMessage(string, time = 750)
{
WaitClose := 1
SetTimer, cursorTime, %time%
Tooltip, %string%
return
}
; tooltip timer
cursorTime:
{
SetTimer, cursorTime, off
Tooltip,
WaitClose := 0
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment