AutoHotkey Community

It is currently May 27th, 2012, 4:46 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: February 24th, 2010, 8:52 pm 
Offline

Joined: May 22nd, 2006, 2:12 pm
Posts: 150
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 9:12 pm 
Offline

Joined: December 24th, 2008, 3:25 am
Posts: 1401
Location: :noitacoL
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)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 9:21 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
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 ???
Code:
0:=cnt


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 February 24th, 2010, 9:39 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 9:23 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 9:24 pm 
Offline

Joined: May 22nd, 2006, 2:12 pm
Posts: 150
Thanks for the help! You guys are amazing!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2010, 5:33 pm 
Offline

Joined: May 22nd, 2006, 2:12 pm
Posts: 150
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[code][/code]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2010, 6:24 pm 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
SetTimer

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Yahoo [Bot] and 61 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group