Code: Select all
Printscreen::
Insert current date & time in Column A ; A1..A2..A3 and so on. If A3 exists, go to A4
Tooltip that shows result of Average(A4-A3, A3-A2,A2-A1) ; i.e. average time elapsed
return ; without showing the excel file itself
Code: Select all
Printscreen::
Insert current date & time in Column A ; A1..A2..A3 and so on. If A3 exists, go to A4
Tooltip that shows result of Average(A4-A3, A3-A2,A2-A1) ; i.e. average time elapsed
return ; without showing the excel file itself
Code: Select all
#Persistent
tmstmp := A_MM "/" A_DD "/" A_YYYY " " A_Hour ":" A_min ":" A_Sec "." A_MSec
cnt := 0, sum := 0
xl := ComObjCreate("excel.application")
wrkbk := xl.workbooks.open(a_scriptdir . "\timestamp.xlsx")
nwrw := xl.Range("A" xl.Rows.Count).End(-4162).Row + 1
xl.range("a" nwrw).value := tmstmp
xl.range("a2:a" nwrw).NumberFormat := "0.00"
for c in xl.activesheet.range("a2:a" nwrw)
if (c.offset(1,0).value)
sum += xl.worksheetfunction.Sum(c.offset(1,0).value, -c.value) * 86400, ++cnt
tooltip % sum / cnt
xl.range("a2:a" nwrw).NumberFormat := "m/d/yyyy h:mm:ss;@"
wrkbk.close(1)
xl.quit()
settimer, ttoff, -3000
return
ttoff:
tooltip
return
Code: Select all
#SingleInstance, Force
SetWorkingDir, A_ScriptDir
F10::Run test.csv ; display test file
F11::FileAppend,% A_Now ";", test.csv ; writing timestamp into test file
F12::
delta:=0 ; reset
FileRead, content, test.csv ; get timestamps from test file
arr := StrSplit(RTrim(content,";"),";") ; trim trailing ';' and split timestamps into an array
Loop % arr.Count()-1 ; loop number of items in array
delta += arr[A_Index+1]-arr[A_Index] ; substract following timestamp from previous to get time delta
MsgBox % delta/arr.Count() ; divide added number of seconds through number of timestamps to get average time elapsed
Return
the con of this approach is that all the inputs are in 1 cell, which makes it difficult to manipulate / do further analysis manually in excel. Is it possible to store 1 timestamp in each own cell instead?BoBo wrote: ↑14 Mar 2022, 17:06Code: Select all
#SingleInstance, Force SetWorkingDir, A_ScriptDir F10::Run test.csv ; display test file F11::FileAppend,% A_Now ";", test.csv ; writing timestamp into test file F12:: delta:=0 ; reset FileRead, content, test.csv ; get timestamps from test file arr := StrSplit(RTrim(content,";"),";") ; trim trailing ';' and split timestamps into an array Loop % arr.Count()-1 ; loop number of items in array delta += arr[A_Index+1]-arr[A_Index] ; substract following timestamp from previous to get time delta MsgBox % delta/arr.Count() ; divide added number of seconds through number of timestamps to get average time elapsed Return
Excel files are not text files and appending text to them will corrupt them. So adding cells to an excel file without opening Excel itself is - afaik - not possible. That said, with my script, you will never know that excel was launched.
for now it will just be 1 column and 10000 rows.flyingDman wrote: ↑15 Mar 2022, 17:28Can you give me an idea of how large that spreadsheet is (number of rows?) Any other columns than that one?
Code: Select all
st := A_TickCount
nstmp := a_now
dataSource := a_scriptdir . "\timestamp.xlsx"
objConnection := ComObjCreate("ADODB.Connection")
objRecordSet := ComObjCreate("ADODB.Recordset")
try objConnection.Open("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" . dataSource . "; Extended Properties='Excel 12.0 xml;HDR=no;IMEX=1';")
catch
{
msgbox Error! Data could not be retrieved
exitapp
}
objRecordset.Open("Select * FROM [Sheet1$]", objConnection, 3, 3, 1)
pFields := objRecordset.Fields
arr := [], sum:= 0
Loop
{
arr.push(pFields.Item(0).value)
objRecordset.MoveNext
} Until objRecordset.EOF
for x,y in arr
if arr[x+1]
{
stmp1 := arr[x], lststmp := stmp2 := arr[x+1]
stmp2 -= stmp1, s
sum += stmp2
}
sum += (nstmp - lststmp)
tooltip % sum / arr.count()"`n" A_TickCount - st "`n" arr.count() ; gives average, elapsed time to run and number of timestamps
objRecordSet.close
objConnection.close
objRecordset := objConnection := ""
xl := ComObjCreate("excel.application")
wrkbk := xl.workbooks.open(a_scriptdir . "\timestamp.xlsx")
nwrw := xl.Range("A" xl.Rows.Count).End(-4162).Row + 1
xl.range("a" nwrw).value := nstmp
wrkbk.close(1)
xl.quit()
tooltip
return