Elapsed Time/Billing

I need to make an app that starts recording the time since login, then automatically opens a screen at the end to bill for that time (maybe I just provide a link to a website where the credit card info can be added)?

Essentially, it’s billing someone for the time they use the computer (like you would see at a Kinkos/Fedex, but for Mac).

Here’s an example:

  1. User will login to the public computer this software would be used on;
  2. This program then starts counting the elapsed time since the login (runs in the background, and can not be turned off);
  3. When the person is ready to log off, they click the “log-off” button on this software, which then brings them to the billing screen (maybe even open a website link where billing can be done - whichever is easier);
  4. The system then automatically inputs the time the computer was used, and calculates the total;
  5. User then enters CC information, and clicks submit. After the payment is processed successfully, the computer runs a program to delete all files and downloads user installed, and logs the computer off.

I think it’s pretty simple. I looked around online to find software that does this (or for various components of applescript that would eventually make this software when pieced together), but have had no luck. Is anyone here able to do this? Are you aware of software that already exists that does this (for Mac, obviously)? Thank you in advance!

Well it’s not :wink:

  1. What if the users uses the terminal, looks up the process, kills it and start it right before he ends his session. Instead of hours only a few minutes are recorded.
  2. AppleScripts is no saint and it can crash, what should you do then?
  3. If the AppleScript is managed by launchd to tackle down problem #2, the recorded time is still not accurate because it will quit and restarts processes by its own will (to make Mac OS X look faster than other OS’es).
  4. What to do with fast user switching?
  5. You can cancel out the login by creating an process where the delegate method applicationShouldTerminate: returns false but what do you do when the user force quits? The user won’t see a recording screen and can logout for free. Re-login will reset the timer to 0.
  6. What if the users halts the system?
  7. What if an kernel panic occurs (Mac OS X’s version of BSOD)?

These are common problem when you see in practice and therefore internet cafes uses different solutions.

I agree with DJ that getting this right would be a significant programming project, not a quick Applescript.

Unless you want to hire a team of developers for months, you want something off-the-shelf. Do more Googling. It didn’t take me long to find some possibilities:

iCafe, but it appears to be discontinued: https://www.macupdate.com/app/mac/15760/icafesystem

Hodomon Timer http://www.hodoman.com/

eCrisper http://ecrisper.com/

Hi DJ and T.Spoon,

Thank you both for your input. I’ll look into the links T.Spoon provided (obviously my Googling skills need to be improved :smiley: )

Thank you!!

Those programs seem to be more for online use. I need the entire computer (not just the internet) use billable. Say someone wants to create a Word document. That needs to be billed time while logged in. What am I missing from my google searches?

Thank you!!! :smiley: :smiley:

Sorry, I didn’t find much else. I’m surprised there isn’t much out there, but I wasn’t finding it in a few quick searches.

I agree also that this has got lots of ifs and buts to it but I put this script together that I think should cover points 1-3 of the original post:

set currUser to do shell script "whoami"
set loginTime to do shell script "w -h " & currUser & " | awk '{print $4}' | awk 'NR==1{print}'"
set currDateString to date string of (current date)
set fullLoginTime to date (currDateString & " at " & loginTime)
set loginSeconds to (current date) - fullLoginTime

---------------------------------------------this part is credit to StefanK http://macscripter.net/viewtopic.php?id=43844---------------------------------------------
set totalLoginTime to secondsToHMS from loginSeconds

display dialog currUser & " has been logged in for " & totalLoginTime

on secondsToHMS from theSeconds
	tell theSeconds to return my pad(it div hours) & ":" & my pad(it mod hours div minutes) & ":" & my pad(it mod minutes)
end secondsToHMS

on pad(v)
	return text -2 thru -1 of (v + 100 as text)
end pad
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Hope this helps,
Nik

Sorry it took me so long to reply. I don’t often check this website.

I’ll test out that script here shortly, and get back to you! Thank you very much for your help!!

It seems to work fine for points 1-3. Thank you! I’ll see what else I can piece together for the rest (if anything), and will try to remember to post back. lol

Thank you!!!