Closing active terminal window with applescript

I made a very basic script to lock my screen, and I like how it works. Some of my co-workers would also like it but it has one problem.
When the script runs, a terminal box pops up at the end saying [process complete]. I can click through this and I don't care, they do.
I can't just killall terminal because we use terminal and that could kill our work.
We sometimes need to see output from a script and like the process complete, so don't want to reconfigure our systems to never display it.
I'm trying to find a way to use applescript or something to kill the active terminal window, or the window with the title of LockScreen or something.
Anyone have an idea?
I was hoping something like this would exist but it doesn't seem to: tell application "Terminal" to close window

Here is an easy approach.  Start Applications -> Automator
Select Application
In Automator search for "Start Screen Saver".  This should be under Library->Utilities
Drag "Start Screen Saver" to the right side panel.
Save the Automator app.
If the user has System Preferencs -> Security -> Require Password ... set, then one the screen saver has started running, it will require the user to enter their password before getting control back.
This Automator app can be double clicked, it will not require the terminal.
With respect to your script.  If this is a shell script, AND if you wish to continue using it, then you could create an Automator app that uses "Run Shell Script" under Automator Library->Utilities.  This will also NOT require the use of Terminal, however, be aware that when Automator runs a shell script it DOES NOT have the same environment as when you are running a shell script at your Terminal prompt.  There are very few environment variables set, and for example the USER, HOME, current working directory, PATH, etc... may not be the same.  If you have dependencies on specific environment information, you may want to write a simple automator script the using "Run Shell Script" to output various environment information into a file so you can see what you have to work with
(id -a
pwd
echo "$#"
echo "$@"
printenv
) >/tmp/automator.environment.txt

Similar Messages

  • Can I open new terminal window with the same path?

    Hello.
    I use Terminal for bash-shell.
    When I work at a certain directory, can i open new terminal(command + N) with the same directory?
    For example, when i am in /Developer and press command+N, I want a new terminal window with /Developer path.
    Thanks for reading and I'm sorry for my short english.

    Command-N will open a new Terminal window in your Home (~) Directory by default.
    Use the "Open Terminal Here" script for more control
    http://www.entropy.ch/software/applescript/

  • My tabs are seperated into groups. Once I accidentaly opened a site in a new window (not a new tab). After that, I accidentaly closed the Firefox window with all my grouped tabs. Now, I can't recover it. Are there any solutions?

    I have my tabs seperated into several groups (for example, bank tabs, music tabs, social life tabs and so on). I do this with the help of the button in the top left corner. While I was surfing the internet, I accidentaly opened a site not in a new tab (as I usually do), but in a new window. The new window was without all the grouped tabs, which I had in the previous Firefox window. And then I accidentaly closed the Firefox window with all my grouped tabs. Now I can't recover it. Are there any solutions?

    Hi,
    We have rolled out a fix for this issue.
    Please log off and log back in to your machine and the issue should be resolved automatically. In case that does not work, please manually run the msi installer posted here (may require reboot).
    For details, please refer to the KB article here: Multiple RunOnce keys created 11.0.10 and 10.1.13 Acrobat | Reader
    Please let us know if you still face any issues.
    Thanks,
    Ashu Mittal

  • (SOLVED) Closing a terminal window

    When I am through using the terminal window, I hit the X at the top right corner but get this message: There is still a process running in this terminal. Closing the terminal will kill it.
    Why do I get this? I think I have nothing running. is there a bug?
    Last edited by mcduling (2011-12-19 22:23:54)

    It is complaining because you are still running su. That's a fair warning, not a bug.
    If you don't like it, use sudo instead. It's safer anyway than leaving a terminal sitting around in su-mode for arbitrary lengths of time.
    Edit: btw, if you have run su to gain root access, and you want to close the terminal, you can get out of su by typing "exit". Then you should be able to close the terminal.
    But really, don't use su. That's just asking for trouble. Sudo is your friend.
    Last edited by /dev/zero (2011-12-19 09:59:43)

  • When one window containing 1 tab is closed, the other window with several tabs closes also

    I have a set of web pages that reproducibly causes Firefox to act incorrectly. When Firefox is first started I click the "Restore previous desktop" button. Then I have 2 Firefox windows. The first to open has 6 tabs; the second has 1 tab. When I close the 2nd window (with 1 tab), it also closes Firefox completely with no error message. When I run Firefox again, "Restore" creates both windows exactly as they were before.
    I don't know yet if the actual URLs make a difference, but here they are anyway:
    '''''Window 1:'''''
    https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2Fu%2F0%2F%3Fshva%3D1%26ui%3Dhtml%26zy%3Dl&bsv=llya694le36z&ss=1&scc=1&authuser=0&ltmpl=default&ltmplcache=2&from=login#inbox
    http://branamsmile.com/gum/?gclid=CLepiIaAhqkCFVJ25QodSyk1nw
    http://www.google.com/search?hl=&q=root+viewsonic+g+tablet&sourceid=navclient-ff&rlz=1B3GGLL_enUS412US412&ie=UTF-8&aq=0&oq=root+viewsoni
    ***** NOTE THIS TAB IS PROBLEMATIC *****
    When I press Alt+D, Ctrl+C, and Ctrl+V it into this comment box, I get
    '''woot'''
    When I look at the actual contents of the web page being displayed, it is the verizon wireless rebate page:
    '''www.verizonwireless.com/rebates'''
    The page has definitely finished being rendered (the refresh icon is displayed after the url "woot"), but the URL does not match the page. The URL displayed is not even in its proper form (i.e., www.woot.com).
    Remember that this page was RESTORED by Firefox from a previous session. It is as if I was on that tab at verizon, tried to go to woot.com by typing "woot" (which would of course bring up a search rather than the web page), DIDN'T PRESS ENTER, and Firefox is duplicating that entire sequence.
    ********* END PROBLEMATIC *************
    chrome://foxtab/content/newTabMessage.html
    https://www.bankofamerica.com/Control.do?page_msg=signoff&body=signoff
    '''''Window 2:'''''
    http://www.freewaregenius.com/2011/06/01/the-best-freeware-file-manager-a-comparative-analysis/
    With this exact set of windows and tabs, as restored by Firefox in a brand new instance of it, double-clicking the red Firefox in the top left corner of the 2nd window causes both windows to close.
    I wish I could save this configuration so I could always reproduce the error, but I need my computer :)

    You can check for problems with the sessionstore.js and sessionstore.bak files in the Firefox Profile Folder that store session data.
    Delete the sessionstore.js file and possible sessionstore-##.js files with a number and sessionstore.bak in the Firefox Profile Folder.
    *Help > Troubleshooting Information > Profile Directory: Open Containing Folder
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    Deleting sessionstore.js will cause App Tabs and Tab Groups and open and closed (undo) tabs to get lost, so you will have to create them again (make a note or bookmark them).
    *http://kb.mozillazine.org/Multiple_profile_files_created

  • Opening a Terminal window in AppleScript

    Hello, I am having dificulties getting a terminal window to open from an AppleScript. I recently upgraded from OS X SnowLeopard to Lion. Under SnowLeopard the following AppleScript would activate Terminal and open a Terminal window:
    tell application "Terminal"
           activate
    end tell
    However, now that I am using Lion, when I run the above script Terminal will activate but a Terminal window does not open. Does anybody know how to modify this script so that Terminal activates and a Terminal window opens? Thanks George

    Hello, I figured out the answer. I just needed to tell the applescript to open a new window using the system events command. Here is the revised script:
    tell application "Terminal"
           activate
          tell application "System Events" to keystroke "n" using {command down}
    end tell
    Thanks, George

  • Retrieving all UI Elements from window with Applescript

    Hi All..
    I want to retrieve all the ui elements from one of the window in runtime with Applescript.
    The problem is in order to get the elements of the particular window i need to pass thru the hierarchy like UI element 1 of scroll area 1 of window 1 etc..
    How do i get the hierarchy at the runtime??
    For eg: if the hierarchy level is 3, i can get the UI elemets like.. ui elements of ui elements of ui elements of window 1.. this works fine
    but i want to repeat the same statement in loop, till i get some elements, how do i achieve the same??
    I tried the below code its not working for me... Pls suggest
    set allButtons to {}
    set i to 0
    tell application "System Events"
        tell process "Install Adobe Reader"
            set num to count of UI elements of window 2
            set element to every UI element of window 2
                  repeat with i from 0 to num
                if class of element is button then
                    return true
                else
                    set element to (a reference to UI elements of element)
                    set num to count of UI elements of element
                    end if
            end repeat
        end tell
    end tell

    madhusudhanjr wrote:
    actually am implementing Applescripts in Java, the output what we get in Java is not exactly similar to Applescript.. Is their any way to make a list or Array of the above codes output??
    Because they are objects.
    Here's how to convert these objects in  text format :
    set allButtons to ""
    tell application "System Events"
          tell process "Install Adobe Reader"
                with timeout of 0 seconds
                      set tElements to entire contents of window 1
                end timeout
                repeat with i in tElements
                      if class of i is button then try
                            i as text
                      on error err
                            tell my cleanUpErr(err) to if it is not "" then set allButtons to allButtons & it & linefeed
                      end try
                end repeat
          end tell
    end tell
    allButtons
    on cleanUpErr(t)
          set oTID to text item delimiters
          try
                set text item delimiters to "«" -- remove description of the error at beginning of the text
                set t to "«" & (text items 2 thru -1 of t) as text
                set text item delimiters to " of «class pcap»" -- remove 'of process "xxxx" of application "System Events"'
                set r to text item 1 of t
                set text item delimiters to oTID
                return r -- return object in text format
          end try
          set text item delimiters to oTID
          return ""
    end cleanUpErr
    You will get a button to each line (the last line will be empty).
    Here is an example of the result :
    «class butT» 1 of window "xyz"
    «class butT» "bla" of window "xyz"
    «class butT» 3 of window "xyz"
    «class butT» "OK" of «class scrb» 1 of «class scra» 1 of window "xyz"
    Each line is compilable in (osascript or in the Editor) without changing the text even if some of the classes are Raw Code --> «class butT»

  • Opening application then closing its window with Applescript.

    Hello there. I am trying to write a Applescript the will open the Application XQuartz (X11), but then close its xterm window as soon as it opens, so I don't have to close it manually. This script will be run at login. This is what I have so far: 
    tell application "XQuartz"
    activate
    end tell
    tell application "System Events"
              repeat while (count (process whose name is "xterm")) is 0
                        delay 0.5
              end repeat
              if (count (process whose name is "xterm")) is 1 then
                        do shell script "killall xterm"
              else
                                  return
              end if
    end tell
    which results in the error Can’t get process whose name = "xterm". Any help would be much appreciated.
    Also, I have tried;
    tell application "XQuartz"
    activate
    end tell
    tell application "System Events"
    key down {command}
    keystroke "w"
    key up {command}
    end tell
    which does not close the xterm window.

    well, the simple fix to your problem is the addition of the keyword 'every':
    count (process whose name is "xterm") --> doomed to failure
    count (every process whose name is "xterm") -- returns the number of matching processes
    There's a second problem in that I never see any process called 'xterm', so your initial loop (waiting for the app to load) is doomed to failure - or, at least, doomed to wait indefinitely.
    On my machine, the only relevant processes I see are 'X11.bin' and 'quartz-wm'. You should delve a little more deeply to identify the process in question.
    Once you have that, I suspect the command-W solution is your best bet, but that should be written like:
      keystroke "w" using {command down}
    rather than emulating (and holding) the command key.

  • Closing open mail windows with one command

    I get tons of email. Often I fail to close each one before opening another. Result? A dozen or more open emails. Is there a simple way to close them all at once?
    thanks,
    Tim

    In many applications, holding the Option key causes the File > Close Window command to change to Close All Windows, but for some reason Mail doesn't do it.
    What does work in Mail is holding down the Option key while clicking the red close button at the top left of any window. Problem is... it will actually close all windows...
    Just type ⌘1 (Command-1) afterwards to open the Message Viewer window again. This is actually the command shortcut for selecting the Inbox mailbox (Mailbox > Go To > In), but it also opens the Message Viewer window if there are no message windows open -- yes, interestingly enough, ⌘1 doesn't work and beeps at you when the frontmost window is a message window, regardless of whether the Message Viewer window is open or not...
    ...and, yet more interesting, ⌘1 works again if you open Preferences in front of the message window that caused that command to beep before, but only if the Message Viewer is closed. On the other hand, if the Message Viewer is open, then typing ⌘1 does nothing when Preferences is the frontmost window, it does not even beep, although the menu title does blink as if Mail had actually executed the command (but it hasn't)...
    ...and don't worry if the last paragraph above just doesn't make sense to you, it can safely be ignored...
    iMac G5 17" (iSight)   Mac OS X (10.4.4)  

  • Move terminal window with simple mouseclick+drag in openbox

    Hej,
    as i don't need the mouse in terminals i am wondering if there was a way to drag an undecorated urxvt window without the need of pressing the ALT-key. i am using openbox as a wm. does anyone know of an elegant way to achieve that?
    thank you

    there should be an option under the file menu to move the current window. but then again u'd still have to press alt+f to open the file menu.

  • Accidentally closed a Terminal window

    Is there any way to recover the window if the process is still running?

    In most cases, when you close a window, any process running in that window (or, more technically, the shell) will terminate.
    That's not always the case, but you usually have to go to extra lengths to make a process persist beyond the current shell session.
    So the chances are that the process is no longer running anyway.
    AFAIK, the screen suggestions will only work for a process that was launched via screen. You cannot attach to an arbitrary process.

  • Terminal shows blank window with 80x24 and nothing happens

    Hi!
    I was trying to make Isync work with my unsupported nokia 6086 phone, and it required pasting text using vi editor. later I tried vim, and at some point just closed the terminal window. Now the terminal does not show bin/bash prompt, just a blank window where I can type anything, but nothing happens..
    I tried to create another user account to reset the shell but same thing happens there..

    Same happened to me today trying to install Clang, did you find a fix for this? Thanks

  • Keyboard shortcuts: adding service to open a Terminal window not being saved

    Hi
    Objective: A shortcut to open a terminal window with the path of the 'in-focus' Finder window (Mavericks).
    Solution (that doesn't work): Apple Menu/System Preferences/Keyboard
    Select: Shortcuts
    Select: Services
    Check box for: New Terminal At Folder
    Close System Preferences
    This approach seems to be advised on quite a few sites. When I do it, the service I add simply doesn't get saved. I go back into the System Preferences and look under the path above and see that the box for New Terminal Åt Folder is unchecked.
    Any help in being able to achieve my objective would be greatly appreciated :-)

    Those things are saved as part of the workspace. It sounds as if the current workspace file has become corrupt. Close ID, then go to your user profile and you'll find the workspaces folder under \Application Data\Adobe\InDesign\Version 6.0\<language>\Workspaces. Delete the "current" xml file for the workspace and restart ID. The workspace will be restored to the conditions set when it was saved, but hopefully will remember changes again when you close the program.

  • How to open a terminal window in a path currently visible in the Finder?

    I often need to open a terminal window with the current visible folder (a long, deep path) as the working directory.
    In Windows I used to have the little "Open command window here..." hack available in the context menu in Explorer.
    How can I achieve the same on OS X to avoid tediously typing the path?

    open a finder window and navigate to one-level above
    this visible folder.
    open a terminal window.
    drag the folder of interest from the finder window
    into the terminal window. now you see the whole path
    to that folder has been typed out for you....
    so, if you wanted to 'cd' into that folder in
    terminal, you'd type cd, then a space, into the
    terminal window, then drag that folder in there from
    the finder, then hit return.... viola!
    If the folder you want is already open, you can drag the icon at the top of the Finder window. You don't have to go one level up.

  • Make a GUI with AppleScript

    H i want to make a window with AppleScript, i dont really like the dialog thing.. (Kind of annoying.. :P) is there any way of doing that or is it any program that i can make it with??

    You can use AppleScriptObjC in Xcode, or something like CocoaDialog or Pashua.

Maybe you are looking for

  • I'm being charged TWICE for one purchase, how can I get my money back for that second charge?

    I bought an album and two songs which added up to about $13 and I went to check my credit card account and saw that itunes is charging me twice for that same thing along with an extra $1 for something else. One of the transactions is on 11/05/11 whil

  • Kerberos Configuration Manager for SQL Server: Access of system information failed!

    I'm trying to use the new Kerberos Configuration Manager for SQL Server tool that was released recently to verify SPN on several SQL Servers, but any time I attempt to connect to a server I get the following error in the log: 6/24/2013 3:48:22 PM Inf

  • Exporting using JAR tool

    Hi, I've created a Java Project in Eclipse, wich makes use of several external classes in the classpath. When viewing in the applet viewer, it works without trouble. But now I want to export it and test it from (a simple) html site. It gives a "Class

  • My Powerbook G4 refuses to recognise it's battery.............

    My powerbook refuses to recognise that it has a battery installed. Naturally this happened just weeks after the extended warranty ran out! The battery icon on the top right side of the toolbar has a cross in it and yes, I have checked it with another

  • Infinity blocking one site

    Since having infinity installed I cant access a particular site,if I connect on my work computer or via 3g on iphone or ipad there is no problem at all, bt tech help can access the site but can't explain what the problem is and why I cant, anyone abl