Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Nov 12, 2010, 01:39 AM   #1
macrumors 6502
Join Date: Sep 2008
On Idle Script in Login Items Doesn't Stay Open

I have an On Idle Applescript application, saved with stay-open selected, that works perfectly if I open it after I've logged in (i.e. it stays open and does its thing), but seems to return immediately if I put it in my login items. Any idea why this happens or how to troubleshoot what's happening?

Here's the script in case it helps. It sets the mouse off in the corner of my screen if certain apps are running and if PandoraBoy is running it quits it if it remains in a paused state for too long (I launch PandoraBoy from Plex and I need PandoraBoy to quit so Plex will relaunch). Thanks for any help!

property idleTime : 3
global mouseLoc
global counter
global counterMax
set mouseLoc to "maybeBad"
set counter to 0
set counterMax to 3

on idle
	tell application "System Events"
		set thisApp to name of first process whose frontmost is true
		if thisApp is "EyeTV" or thisApp is "Hulu Desktop" or thisApp is "Plex" then
			if mouseLoc is "maybeBad" then
				do shell script "python -c 'from Quartz import *; CGEventPost(kCGHIDEventTap, CGEventCreateMouseEvent(None, kCGEventMouseMoved, CGPointMake(0,1080), kCGMouseButtonLeft))'"
				set mouseLoc to "maybeGood"
			end if
			set mouseLoc to "maybeBad"
		end if
		if thisApp is "PandoraBoy" then
			tell application "PandoraBoy"
				if player state is paused then
					--say "player not playing"
					set counter to (counter + 1)
					set counter to 0
				end if
				if counter is counterMax then
					set counter to 0
				end if
			end tell
			set counter to 0
		end if
	end tell
	return idleTime
end idle
astrorider is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Login items Typswif2fingers OS X Mavericks (10.9) 2 Mar 30, 2014 03:07 PM
Login Script Lew4484 OS X 10.8 Mountain Lion 1 Aug 22, 2013 08:14 AM
Login items priority? stiwi OS X 10.8 Mountain Lion 0 Feb 3, 2013 04:02 PM
run script when system is idle? yukonluke Mac Programming 0 Aug 10, 2012 04:52 PM
Anyway to set login items to open in the background (aka light on in dock)? NMF OS X 2 Jul 19, 2012 03:35 PM

Forum Jump

All times are GMT -5. The time now is 02:07 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC