Ok, now it's getting a bit too complicated for me. Firstly I'm on Win7 32-bit and dmg´s original script doesn't seem to log logouts correct when using 0x80000000. Instead it gets logged as a shutdown. If changing to the corresponding integer -2147483648 I get correct logging. Why is that? Secondly I have no idea how to pick apart logging for "System hibernation" and "System resuming from hibernation" when not enitierly knowing whats the integer for these two are. My aim is to get the script to log standbys/hibernates as well. Maybe someone can help me out? Here's the Log out logger script I'm using with changes and comments for changed parts:
Code: Select all
#noenv
#singleinstance, ignore
setbatchlines, 10ms
setworkingdir, %a_scriptdir%
;---------------------------------------------------------create files if not present.
fileinstall, readme.txt, readme.txt, 0
fileinstall, settings.ini, settings.ini, 0
sleep, 20
;---------------------------------------------------------read installation and icon settings.
iniread, installed, settings.ini, settings, installed
iniread, tray, settings.ini, settings, tray
;---------------------------------------------------------if there is a tray icon, create tray menu.
if tray = no
{
menu, tray, noicon
}
else
{
menu, tray, nostandard
menu, tray, add, View log, view
menu, tray, add, Edit settings, edit
menu, tray, add
menu, tray, add, Uninstall, uninstall
menu, tray, add, Exit, exit
menu, tray, default, View log
menu, tray, icon, D:\TV\test\Shutdownlogger\glasses.ico
}
;---------------------------------------------------------if not installed, start installing.
if installed = 0
{
msgbox, 33, Install, Welcome to Log Out Logger`, a simple`nutility to monitor system startup and`nshutdown. Do you want to install`nand start using Log Out Logger?, 20
ifmsgbox, cancel
{
goto, exit
}
ifmsgbox, timeout
{
goto, exit
}
ifmsgbox, ok
{
filecreateshortcut, %a_scriptfullpath%, %a_startup%\Log Out Logger.lnk
iniwrite, 1, settings.ini, settings, Installed
msgbox, 64, Install, Log Out Logger has been installed and`nwill start monitoring on next system log in., 10
goto, exit
}
}
continue:
;---------------------------------------------------------if uninstall, start uninstalling.
if installed = uninstall
{
msgbox, 33, Uninstall, Are you sure you want to uninstall Log Out Logger?, 20
ifmsgbox, ok
{
filedelete, %a_startup%\Log Out Logger.lnk
iniwrite, 0, settings.ini, settings, Installed
msgbox, 64, Uninstall, Log Out Logger has been uninstalled.`nYou may now delete the application`nfiles from your system., 10
goto, exit
}
ifmsgbox, cancel
{
iniwrite, 1, settings.ini, settings, Installed
return
}
ifmsgbox, timeout
{
goto, exit
}
}
;---------------------------------------------------------log start up time and start monitoring for shutdown.
fileappend, %a_dd%/%a_mm%/%a_yyyy% %a_hour%:%a_min% - System log in.`n, log.txt
onmessage(0x11, "on_shutdown") ; WM_QUERYENDSESSION = 0x11
onmessage(0x218, "on_shutdown") ; WM_POWERBROADCAST = 0x218
;---------------------------------------------------------start timer to clear memory every 10 minutes. end autoexecute.
settimer, emptymem, 600000
return
;---------------------------------------------------------menu item, view log.
view:
{
ifnotexist, log.txt
{
msgbox, 48, Error, Log file not found!, 10
}
else
{
run, log.txt
}
}
return
;---------------------------------------------------------menu item, edit settings.
edit:
{
ifnotexist, settings.ini
{
msgbox, 48, Error, Settings file not found. Please restart to generate default settings., 10
}
else
{
run, settings.ini
}
}
return
;---------------------------------------------------------menu item, uninstall.
uninstall:
{
iniwrite, uninstall, settings.ini, settings, Installed
iniread, installed, settings.ini, settings, installed
goto, continue
}
return
;---------------------------------------------------------menu item, exit program.
exit:
{
exitapp
}
return
;---------------------------------------------------------function to be called on shutdown or log out.
on_shutdown(param1, param2) ;
{
if param2 = -2147483648 ;The original 0x80000000 doesn't work ;check if log out.
{
fileappend, %a_dd%/%a_mm%/%a_yyyy% %a_hour%:%a_min% - User has logged out.`n, log.txt
}
else ;if not log out then shutdown.
{
fileappend, %a_dd%/%a_mm%/%a_yyyy% %a_hour%:%a_min% - System shutdown.`n, log.txt
}
if param1 = ??? ; integer for system hibernation seems to be 4
{
fileappend, %a_dd%/%a_mm%/%a_yyyy% %a_hour%:%a_min% - System hibernation.%param1% > %param2%`n, log.txt
}
if param1 = ??? ; integer for resuming hibernation seems to be either 18 or 7.
{
fileappend, %a_dd%/%a_mm%/%a_yyyy% %a_hour%:%a_min% - System resuming from hibernation.%param1% > %param2%`n, log.txt
}
}
return
;---------------------------------------------------------clear memory function.
emptymem:
{
dllcall("psapi.dll\EmptyWorkingSet", "UInt", -1)
}
return