 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
john tuomi
Joined: 22 May 2006 Posts: 150
|
Posted: Wed Feb 24, 2010 7:52 pm Post subject: Help inserting a timestamp in a script output file |
|
|
Hi, I'm trying to adapt a file that I found on the forums. The file keeps track of each keystroke used, and outputs the total amount of the keys pressed.
What I'm trying to do (quite unsuccessfully) is to put a timestamp and the user name in the line that is saved in the ini file, but I keep receiving a missing variable error.
Also, does anyone know how to set a timer to make this run every hour on the hour?
| Code: | nSize:= VarSetCapacity(sName, 256) + 1
DllCall("advapi32\GetUserNameA", "str", sName, "UintP", nSize)
nSize:= VarSetCapacity(sFull, 1023) + 1
DllCall("secur32\GetUserNameExA", "Uint", 3, "str", sFull, "UintP", nSize)
MsgBox, 32,, Greetings %sFull%!,2
Return
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Loop
{
Input Key, L1 V, {ScrollLock}{CapsLock}{NumLock}{TAB}{Esc}{BS}{Enter}{PrintScreen}{Pause}{LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}
cnt++
}
;~*LButton::
;~*RButton::
;~*MButton::
cnt++
return
=::
FileAppend %,%Sname%,%A_now%¬% "," cnt, data completion totals.ini
0:=cnt
return |
|
|
| Back to top |
|
 |
Carcophan
Joined: 24 Dec 2008 Posts: 1308 Location: :noitacoL
|
Posted: Wed Feb 24, 2010 8:12 pm Post subject: |
|
|
I dont think you can 'fileappend' to an INI like that, you need iniWrite.
If you want 'fileappend', try:
fileappend, %sName% `, %A_now%, c:\path\file.txt
IniWrite, %sName%"-"%A_Now%, Filename/filepath_here, Section, Key
(don't know if you can even use a variable in the 'value' section of the iniWrite line honestly) |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
Posted: Wed Feb 24, 2010 8:21 pm Post subject: |
|
|
Instead of the DLL call to get thr user name, why not use the built- in variable
| Code: | | msgbox The logon name of the user is %A_UserName%. |
is this a typo ???
You have too many parameters in the following statement.
I have no idea what it will do so I'm not going to run it.
What is the actual format that you want?
| Code: | | FileAppend %,%Sname%,%A_now%¬% "," cnt, data completion totals.ini |
| Quote: | | Also, does anyone know how to set a timer to make this run every hour on the hour? |
I read what you wrote, but don't quite understand it.
Perhaps you want the "Fileappend" line to run on the hour ?
If that is what you want do, follow the steps below
before your Msgbox Greeting add these lines
| Code: | start:=A_now
settimer, log_chk, 30000 ; 30*1000 => 30 seconds * 1000ms, check twice a minute |
and replace your logging routine with this
| Code: | =::
log_chk:
if (A_Hour=0 and A_Min=0)
{
FileAppend %`,%Sname%`,%A_now%¬% "," cnt, data completion totals.ini
cnt:=0
}
return |
Last edited by Leef_me on Wed Feb 24, 2010 8:39 pm; edited 1 time in total |
|
| Back to top |
|
 |
da_boogie_man Guest
|
Posted: Wed Feb 24, 2010 8:23 pm Post subject: |
|
|
| Carcophan wrote: | I dont think you can 'fileappend' to an INI like that, you need iniWrite.
If you want 'fileappend', try:
fileappend, %sName% `, %A_now%, c:\path\file.txt
IniWrite, %sName%"-"%A_Now%, Filename/filepath_here, Section, Key
(don't know if you can even use a variable in the 'value' section of the iniWrite line honestly) |
Yes, you can use a variable. But it would be either:
| Code: | IniWrite, %sName% - %A_Now%, Filename/filepath_here, Section, Key ;--No quotes {"} needed here.
OR
myValue := sName " - " A_Now
IniWrite, %myValue%, Filename/filepath_here, Section, Key |
The 2nd is what I would recommend, just makes it a little bit "cleaner"
Also, you can fileappend using any file extension. Doing so using the method "john tuomi" is won't make it a true INI file though, just a text file with an INI extension.
--> "john tuomi" -- If you look up in the Docs for A_Now you'll see how to make the Time/Date format whichever way you want.
DBM |
|
| Back to top |
|
 |
john tuomi
Joined: 22 May 2006 Posts: 150
|
Posted: Wed Feb 24, 2010 8:24 pm Post subject: |
|
|
| Thanks for the help! You guys are amazing! |
|
| Back to top |
|
 |
john tuomi
Joined: 22 May 2006 Posts: 150
|
Posted: Wed Mar 10, 2010 4:33 pm Post subject: |
|
|
What I am looking to do is have a timer running in the background that would trigger the sequence below every hour on the hour (based on the system clock) as long as the script is running.
[/code]=::
FileAppend %,%Sname%,%A_now%¬% "," cnt, data completion totals.ini
0:=cnt
return |
|
| Back to top |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Wed Mar 10, 2010 5:24 pm Post subject: |
|
|
SetTimer _________________ "Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried."
Antonio França
My stuff: Google Profile |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|