Failed login = take a photo with iSight and save to desktop

I constantly have to log out of my mac as I have a younger sister who wont stay off it. Can anyone make a script so that when someone fails a log=in attemp at the login screen the built-in iSight will take a picture and save it to the desktop and if you can show the date and time there was a failed login. This way I can catch her in the act when im not at home.

If someone attempts to log in but doesn’t type the correct password at the login window, the mac takes a photo and places it on the desktop

It must do this when its at the login window and when it comes out of sleep and requests the log-in password. so anytime the login password is needed.

Thanks, Pedro.

Model: iMac G5
AppleScript: 2.1.1
Browser: Safari 417.8
Operating System: Mac OS X (10.4)

Here is one of the first scripts I worte. It is set up to take 5 pictures with the iSight. It will then send them to your email and notify you with a text message to check your email. You can modify it to take more or less pics if you want. Find what parameter you want to trigger the script, and then have it run this one upon that action. For example…you could hve the system events app monitor if the screen saver (app) is on every minute or so. If it is notm then it means someone is there, and will take the pics. Here you go…

 ---Made by Ian Dopps 2005 
---This script will email you 5 iSight pictures that are about 5 seconds apart. It will also send a text message to your phone, telling you to check your email. You can change the number of pictures and time interval if you desire. It will then put the pictures in the trash and close all programs involved so nobody knows. It is great when used with a motion detector trigger in Indigo. Questions? doctorlambo@gmail.com 
--- SUBSTITUTE YOUR INFORMATION (NAME) IN 3 PLACES BELOW! 


tell application "iChat" 
   activate 
end tell 
delay 2 
repeat 5 times ---CHANGE THIS NUMBER TO EDIT THE NUMBER OF PICTURES TAKEN 
   tell application "System Events" 
      tell process "iChat" 
         click menu item "Video Preview" of menu "Video" of menu bar item "Video" of menu bar 1 
         delay 1 
         click menu item "Take Snapshot" of menu "Video" of menu bar item "Video" of menu bar 1 
      end tell 
   end tell 
   delay 5 ---CHANGE THIS NUMBER TO EDIT THE DELAY BETWEEN PICTURES 
end repeat 
set mainpath to path to desktop as Unicode text 
set need_fold to "iSEEu" 
tell application "Finder" 
   if not (folder (mainpath & need_fold) exists) then 
      make new folder at mainpath with properties {name:need_fold} 
   end if 
   tell application "Finder" 
      move (every file of desktop whose name contains "Video") to (folder "iSEEu" of desktop) 
   end tell 
    
end tell 
tell application "Mail" 
   set bodyvar to "Your home security has captured new images. They have been sent to your email inbox." 
   set addrVar to "3162205537@messaging.sprintpcs.com" ---PHONE ADDRESS HERE. FOR DETAILS, SEE: http://www.livejournal.com/tools/textmessage.bml?mode=details    
    
   set subjectvar to "CHECK YOUR EMAIL!" 
   set newMessage to (a reference to (make new outgoing message)) 
   tell newMessage 
      make new to recipient at beginning of to recipients with properties {address:addrVar} 
      set the subject to subjectvar 
      set the content to bodyvar 
   end tell 
   send newMessage 
end tell 
tell application "Mail" 
   set bodyvar to "Here is the photo taken when your motion detector was set off:" 
   set addrVar to "doctorlbo@gmail.com" ---EMAIL ADDRESS HERE 
   set subjectvar to "Motion Detector Set Off" 
   set attachmentVar to "/Users/dopps/Desktop/iSEEu" ---CHANGE FILE NAME HERE (THE USER NAME SHOULD BE THE ONLY DIFFERENT THING) 
   set newMessage to (a reference to (make new outgoing message)) 
   tell newMessage 
      make new to recipient at beginning of to recipients with properties {address:addrVar} 
      set the subject to subjectvar 
      set the content to bodyvar 
      tell content 
         make new attachment with properties {file name:attachmentVar} 
      end tell 
   end tell 
   send newMessage 
end tell 
delay 2 
tell application "Finder" 
   delete folder "iSEEu" 
end tell 

But when will it take those pictures. Im new to scripting and dont know the thread for failed login

Pedro, try this. You will have to do a little work to make it work on your computer. There are 3 places where you need to edit the script to suit your personal needs. There are 1. your email address, 2. Your cell phone number, 3.The file location on the desktop. I put stars by these 3 things in the script. try it out. When you change these 3 things, save it as an application. Start the saved application and then turn the screen saver on before you leave. It will take 5 pics and then email them to you. It also saves them on your computer, but they go straight to the trash. Let me know

repeat
	delay 5 * minutes
	tell application "System Events"
		if not (exists process "screensaverengine") then
			tell application "iChat"
				activate
			end tell
			delay 2
			repeat 5 times ---CHANGE THIS NUMBER TO EDIT THE NUMBER OF PICTURES TAKEN 
				tell application "System Events"
					tell process "iChat"
						click menu item "Video Preview" of menu "Video" of menu bar item "Video" of menu bar 1
						delay 1
						click menu item "Take Snapshot" of menu "Video" of menu bar item "Video" of menu bar 1
					end tell
				end tell
				delay 5 ---CHANGE THIS NUMBER TO EDIT THE DELAY BETWEEN PICTURES 
			end repeat
			set mainpath to path to desktop as Unicode text
			set need_fold to "iSEEu"
			tell application "Finder"
				if not (folder (mainpath & need_fold) exists) then
					make new folder at mainpath with properties {name:need_fold}
				end if
				tell application "Finder"
					move (every file of desktop whose name contains "Video") to (folder "iSEEu" of desktop)
				end tell
				
			end tell
			tell application "Mail"
				set bodyvar to "Your home security has captured new images. They have been sent to your email inbox."
				set addrVar to "3162205537@messaging.sprintpcs.com" ---******PHONE ADDRESS HERE. FOR DETAILS, SEE: http://www.livejournal.com/tools/textmessage.bml?mode=details    
				
				set subjectvar to "CHECK YOUR EMAIL!"
				set newMessage to (a reference to (make new outgoing message))
				tell newMessage
					make new to recipient at beginning of to recipients with properties {address:addrVar}
					set the subject to subjectvar
					set the content to bodyvar
				end tell
				send newMessage
			end tell
			tell application "Mail"
				set bodyvar to "Here is the photo taken when your motion detector was set off:"
				set addrVar to "doctorlbo@gmail.com" ---****EMAIL ADDRESS HERE 
				set subjectvar to "Motion Detector Set Off"
				set attachmentVar to "/Users/dopps/Desktop/iSEEu" ---*****CHANGE FILE NAME HERE (THE USER NAME SHOULD BE THE ONLY DIFFERENT THING) 
				set newMessage to (a reference to (make new outgoing message))
				tell newMessage
					make new to recipient at beginning of to recipients with properties {address:addrVar}
					set the subject to subjectvar
					set the content to bodyvar
					tell content
						make new attachment with properties {file name:attachmentVar}
					end tell
				end tell
				send newMessage
			end tell
			delay 2
			tell application "Finder"
				delete folder "iSEEu"
			end tell
		end if
	end tell
end repeat

I would look into http://sourceforge.net/projects/webcam-tools
then use a terminal command to take the picture

sam

Not related to AppleScript, but If you have a laptop with a motion sensor, you can also try to use

http://www.macupdate.com/info.php/id/21860

that.

Oh, and remember to set auto-login off if you have it enabled (even if you have a desktop), as someone could force a restart with the restart button.