Can an AppleScript tell if it was activated by the LogIn Items?

I want to use a single script to act as a StartUp (LogIn) item that does a task automatically and that acts as an app that is clickable with dialog-box options.
So far, I have the script recognize that it's in the StartUp folder or in the loginwindow.plist file, that the other secondary app that the script activates isn't already running, and it checks to see how long the user has been logged in.
I have (do shell script "w") to get minutes logged in. I set my script to run the StartUp portion if the login time is 0 (by way of (if ReadThisSucka contains " --" then). It has worked OK so far, but I'd rather replace it with something more reliable and accurate like this:
if process of login tasks is active
or if thisApp was activated by user "login task doer" then...
*on run*
--Is the other app running?
tell application "Finder"
set OtherAppStatus to (get exists of application process "application2")
end tell
--Is the MagicScript a login item?
set theFileContents to (read file ((path to preferences as text) & "loginwindow.plist"))
--Gets the time logged in
set CurrentDate to (do shell script "w")
--If logged in time is - - then it will act like a startup item
if (CurrentDate contains " - -") then
set BeginUpTime to "1"
else
set BeginUpTime to "0"
end if
--If it is a login item, it will use this app
if (theFileContents contains "MagicScript") and (OtherAppStatus is false) and (BeginUpTime is "1") then
do shell script "wow, I'm a shell script"
else
--If it isn't a LogIn Item, it will do this
if OtherAppStatus is false then
display dialog "To run the function of application2, click App2." buttons {"Cancel", "App2"} with icon 1
if button returned of result = "App2" then
do shell script "wow, I'm a shell script"
end if
else
display dialog "To stop the App2, click Stoppit." buttons {"Cancel", "Stoppit"} with icon 1
if button returned of result = "Stoppit" then
--do shell script "killall App2"
tell application "App2" to quit
end if
end if
end if
end run
Message was edited by: Joey Delli Gatti
Message was edited by: Joey Delli Gatti

I realized that I had two viable solutions:
1. Have the script check and see if it is in the LogIn Items and if the login timer (part of the OS) started less than 1 minute ago.
2. Create a second app for the startup script that automatically starts.
I'd be open to a third option, but this works for now.

Similar Messages

  • I have a new iPhone and when it was activated at the store I had not saved my pictures from the old phone.  Is there a way to still do this?

    I have a new iPhone and when it was activated at the store I had not saved my pictures.  I there still a way that I can download the pictures from the old phone since it does not have service anymore?

    No.

  • My old computer died just after I transferred iTunes via external HD.  When I transferred the content from the HD to the new computer, most songs won't play.  Message is "Can't identify source".  Sharing was on in the old computer when it died.

    My old computer died just after I transferred iTunes via external HD.  When I transferred the content from the HD to the new computer, most songs won't play.  Message is "Can't identify source".  Sharing was on in the old computer when it died.

    Is there no ANSWER TO THIS PROBLEM?

  • I urgently need to know how I can connect 8 thunderbolt display, I was thinking with the new mac pro will come out, but I wonder if it is possible to connect an iMac to 4GB of graphics card, but suffers from the imac. thanks

    I urgently need to know how I can connect 8 thunderbolt display, I was thinking with the new mac pro will come out, but I wonder if it is possible to connect an iMac to 4GB of graphics card, but suffers from the imac. thanks

    I tightened all HD screws and it didn't help. With the machine running and side of the case off, I physically stopped both the video card fan and the front case fan with my finger for a couple seconds and the noise continued. I also took all hard drives out one by one and rebooted each time. Again, the noise continued until I took out the Mac HD in Bay 1, rebooted, and I had a very quiet, silent machine. The issue is the hard drive in bay 1 that shipped with the computer, it's without a doubt causing the hum/woosh sound. I still need to know if I can safely swap the Mac HD from bay 1 to bay 4 without any issues to the operating system. I would like to try that to see if it dampens the noise but I also want to make sure this swap won't screw up my machine at all.

  • CAN SOMEONE PLZ TELL ME HOW TO SHUT OFF THE LIGHT FROM FLASHING WHEN I RECIEVE A CALL?

    CAN SOMEONE PLZ TELL ME HOW TO SHUT OFF THE LIGHT FROM FLASHING WHEN I RECIEVE A CALL?

    Settings>general>accessibility>led flash alerts off

  • Can any body tell me, how to send/receive the sms from java application

    Hi All,
    Can any body tell me, how to send/receive the sms from java application to mobile phones.
    I have installed the jsms engine and when i try to connect to the mobile device ,the jsms server is giving
    the following error.
    Cannot connect to GSM Device, error : -11

    The best place to ask your question is at the JSMS website, forum or mailing list since this is no error that directly comes from a class belonging to the core Java classes.

  • When i login to my mac, it opens iTunes, Skype and AIM. I've tried deleting these from the login items, but they are not on the list.  Can anyone help?

    When i login to my mac, it opens iTunes, Skype and AIM. I've tried deleting these from the login items, but they are not on the list.  Can anyone help?

    babowa wrote:
    If you do not lock that folder immediately after deleting all the contents, it will simply populate again (Resume - a "feature" in Lion). You do that by doing a Get Info (highlight folder and press Command + I keys), unlock the lock at the bottom, enter your admin password, then check the box to lock the folder. lock the lock and you're done.
    Yes, that is correct. The alternative is to quit all applications prior to logging out. Lion will then have a chance to remove the saved states.
    babowa also wrote:
    And, for the OP:
    It has also been a regular feature of Mac OS to automatically open any window that was open at shutdown. To avoit that behavior, simply close any Finder windows and  properly quit applications by closing their window and using Command + Q (or File >Quit).
    This was true only for the Finder. Prior to Lion, no other apps would launch unless they were included in the Login Items for the account. And the OS would not restore windows for other apps.
    A very small number of apps (TextWrangler is an example) implemented this capability prior to Lion. They could restore previously opened windows. But that is an application feature, and can be controlled by the application's preferences. Lion implements it at the system level, and users have virtually no control on a per application basis.

  • I upgraded to mountain lion a week ago and now on startup of my macbook pro, microsoft excel and word start up automatically and then crash? very strange can anyone please help? I have checked the login items under users and groups and there is nothing.

    I upgraded to mountain lion a week ago and now on startup of my macbook pro, microsoft excel and word start up automatically and then crash? very strange can anyone please help? I have checked the login items under users and groups and there is nothing.

    Are you using the Office for Mac 2011 version, as you need to do?  The Office for Mac 2004 is Not at all compatible with Mountain Lion, and the 2008 version has been noted to have some problems running with ML.
    Hope this helps

  • How would you tell if there was damage on the inside?

    I was just wondering, would there be any signs that if you dropped it, something was broken on the inside? Or is there nothing to really break on the inside?

    The symptom is that it does not work right

  • I just got a new Mac Airbook with MAC OS 10.6.8 and now every time I load Firefox, it tells me it was downloaded from the internet and am I sure I want to open it. How can get rid of that message?

    I know this is a standard MAC message but I never got it with Firefox before changing computers. I also downloaded Firefox 5.0 and it is still doing it.

    Thanks, Jim, for taking the time, but the reply is unfortunately vague in the exact area of my confusion!  "you need to copy that file to your new computer..."  Well, the Import/Export instructions make it seem as if the two computers should be able to communicate this file thru wifi, but that's the linkage I can't seem tocreate with Import/Export.  Should I instead email a copy to myself (thats what applecare suggested)?  Copy it to and from a thumb drive?  But then place the file where?  And the article was helpful, but should I be trying to move the Library file or the Library.xml file (as iTunes Help suggests)?  Sorry to be so clueless about it...I suppose I buy Apple in the hopes of not having to think about this stuff, which approach seems not to be serving me well. Thanks again for your time!

  • Can someone please tell me if I qualify for the subsidized iPhone pricing?

    I am a Verizon customer. My two year plan with Verizon ends 1/29/09. I don't know if my Razr was subsidized by Verizon when I first got it. I plan to pay Verizon's early termination fee, and buy a 16GB iPhone asap. Can anyone tell me if I qualify for AT&T's subsidized prices. Does AT&T even care about my Verizon plan or phone, or only the status of AT&T customer's plans and phones when it comes to the subsidized prices? Thanks so much for your help!

    You will becoming a new AT&T customer...so you will be able to purchase the iPhone at a subsidized price. The 16GB one is $299.00! Make sure you bring a photo ID (Driver's License) and your Verizon account # and password, so AT&T can port your Verizon # over and take care of cancelling your Verizon contract. Also bring a credit card in your name and your SS#.

  • TS3899 I am getting emails on my iphone5, but when I try to reply it tells me recipient was rejected by the server because it does not allow relaying. How do I fix this?

    I am getting emails on my new iphone5, but when I try to reply it tells me "the recipient was rejected bythe server because it does not allow relaying" and I don't know how to fix it. Does anyone know how to fix it?

    see the "more like this" section on the right side of this page as your question has been asked and answered many times already.

  • Can I play a game that was made for the iPhone or iPad on my computer?

    I downloaded a game from the itunes and thought i could play it on my mac. It was Words With Friends. But I guess i have to the the game center to play it. Is that right? Anyway around it?

    Unfortunately, no.  The apps that are published to the App Store are specifically designed to work only on iOS devices (iPhone, iPad, and iPod Touch).
    If you want something like the App Store for your Mac, then you can check out the Mac App Store.

  • Can CC and CS6 be installed and active on the same desktop?

    Only one of the CS series can be installed and active on a single computer. Is this true with CC and CS6?

    Only one of the CS series can be installed and active on a single computer.
    Where did you hear that? That's simply completely untrue. Using multiple versions of CS products never has been an issue and neither is it for CC and CS6. Each major version uses it's own unique activation.
    Mylenium

  • Can you please tell me how to shut off the plug-in update checker?

    I like to check plug-in updates from time to time on my own. The "plug-in update checker" that pops up simultaneously EVERYTIME I open Firefox is VERY annoying. Though I have tried, I can't figure out how to stop that from happening. It is so annoying that I have considered going back to using Internet Explorer which I do not like. Please help me disable, turn off, delete this feature. Thank you

    You can go into your Audio Preferences and disable the UV bridge. There is also the option in the drop down menu next to the speaker icon that allows you to mute just the telephone audio. This would make it so just the VoIP audio is heard, but I believe the telephone audio is still recorded.
    This sounds like you either need to disconnect the phone from your room or call into the phone bridge as a host/leader. Ultimately this is a function of your phone bridge, not Connect.

Maybe you are looking for

  • Can't enter text in text fields

    I'm typing this up in text edit and then having to copy/paste everything i type into this text field. I had to do the same with my username and password. I just downloaded the most recent OS update, which 'upgraded' my safari to 3.0.4, I'm running a

  • Out of order photos

    I'm trying to synch my photos from iphone 3GS to my new macbook pro, but the photos are completely out of order, are all contained as one event, with the date being the date of the synch,  and there is no recognition of duplicates.  It transfers all

  • Valuation class and Account Category reference

    Dear Friends. Please Can I know Valuation class and Account Category reference for following Material Types? 1)     Advertisement material- what is Valuation class and Account Category reference ? 2)     Asset Material- what is Valuation class and Ac

  • User settings and reinstall

    Hey all, For various reasons I would like to do an archive and install of Leopard. I am currently running Sno-Leapord and wish to downgrade the system. When I run the Leopard installer, my concern, is that the secondary radio button for "Preserving U

  • How to use Nast in program

    Hello,         I want to use the attribute OBJKY in NAST.But how do I use the structure NAST in my prgoram.