Jump to content
Sign in to follow this  
carlosale214

Application Log

Recommended Posts

carlosale214

Hey so this is my first post on any Autoit Forum and I'm sorry if i break any rules. I often see people get yelled at for breaking any rule or being stupid. Anyways, im pretty sure this is allowed.

I need help with this Application History Program (no malicious intent) I have it scripted as so:

Basically to sum up my code for you guys is I'm just getting the current winTitle and comparing it with the last and if they're not the same i'm adding it to the log.html

$dir = @AppDataCommonDir&"\Practice Work"
$s = "-"& @MON & "_" & @MDAY & ".html"
$currMin = (@YDAY*24*60) + (@HOUR * 60) + @MIN
$currProg = WinGetTitle("")


_FileCreate($dir & "\System Program\log" & $s)
_FileCreate($dir & "\System History\log" & $s)

$progLog=FileOpen($dir & "\System Program\log" & $s)
$histLog=FileOpen($dir & "\System History\log" & $s)

Func _shinCode()
if not WinGetTitle("") == $currProg then
  $currProg = WinGetTitle("")
  if StringRegExp($currProg,"Internet Explorer|Google Chrome|Firefox|Opera|Safari|.com|.net|.org|.info|.gov") = 1 Then
   FileWrite($histLog, "<table border="&""""&"2"&""""&"><tr><th>Date:"&"["&"<i>"&@MON&"/"&@MDAY&"/"&@YEAR&"</i>"&"] Time: ["&@HOUR&":"&@MIN&"] User: [ "&@UserName&" ]</th>"&"</tr></table>")
   FileWriteLine($dir & "\System History\log" & $s, "&nbsp &nbsp &nbsp &nbsp - "&$currProg&"-")
  Else
   if(StringLen($currProg)>0) then
    FileWrite($progLog, "<table border="&""""&"2"&""""&"><tr><th>Date:"&"["&"<i>"&@MON&"/"&@MDAY&"/"&@YEAR&"</i>"&"] Time: ["&@HOUR&":"&@MIN&"] User: [ "&@UserName&" ]</th>"&"</tr></table>")
    FileWriteLine($dir & "\System Program\log" & $s, "&nbsp &nbsp &nbsp &nbsp - "&$currProg)
   EndIf
  EndIf
EndIf
EndFunc


while True
_shinCode()
WEnd

However, the file comes up blank with no history of any programs or internet history...I dont know why? any help...?

Thanks!

Share this post


Link to post
Share on other sites
jchd

Welcome to the forum.

$currProg = WinGetTitle("") is the first culprit. You must not specify an empty string here. Maybe WinGetTitle("[active]") is what you want.

Now help files warn you against mixing File* calls using handles and filenames.

When something may fail, always check for error (usually by testing @error). That will help you everyday wrtiting clean and robust code.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×