How to close a software automatically when it's idle?

Page 1 of 3 123 LastLast

  1. Posts : 4
    Windows 7 Professional 64Bit
       #1

    How to close a software automatically when it's idle?


    Hi guys,

    First post here.
    I need help to close a software automatically after it's not used for some time. Not Windows idle, but that particular software. Let's say I open a software and work it with. Then I switch to other software without closing it. After 10 mins not using it, I want it to automatically close.
    The reason I want to do this is because the license is concurrent, and I want it to close so other users can use it.
    My initial idea is to use task scheduler. But it seems that the only option is to trigger the task when the computer is idle. Not that specific software.

    Can anyone suggest an idea?
      My Computer


  2. Posts : 570
    Windows 7
       #2

    You would need to Google for some third party software to enable you to this. This is not possible with the Windows features.
      My Computer


  3. Posts : 10,485
    W7 Pro SP1 64bit
       #3

    D3LL said:
    You would need to Google for some third party software to enable you to this. This is not possible with the Windows features.
    I think that the Windows native PowerShell could handle a task like this. If I were going to do this, I would use AutoIt - but that is only because I know AutoIt better than PowerShell.

    Let's see if some forum member wants to write a PowerShell script for edwinprakoso.
      My Computer


  4. Posts : 4
    Windows 7 Professional 64Bit
    Thread Starter
       #4

    Thanks guys,

    Are there any links for a documentation about this feature in PowerShell? Probably I can check it myself.
      My Computer


  5. Posts : 10,485
    W7 Pro SP1 64bit
       #5

    I'm not familiar with PowerShell resources/tutorials.

    If someone does not help you out soon...
    ...take a look at AutoIt; specifically, WinGetState.
      My Computer


  6. Posts : 4
    Windows 7 Professional 64Bit
    Thread Starter
       #6

    Thanks @UsernameIssues,

    I will take a look.
      My Computer


  7. Posts : 10,485
    W7 Pro SP1 64bit
       #7

    I decided to play with this a bit.

    You can still wait on a PowerShell solution if you don't want to install the free 3rd party app named AutoIt.


    You can install AutoIt3 from here:
    https://www.autoitscript.com/site/autoit/downloads/
    Accept all of the defaults during the installation.

    After the installation completes:
    Right click on the desktop and select New > AutoIt v3 Script from the context menu.
    (You might need to select the desktop and press F5 to get that context menu.)
    Then right click on the newly created file and select Edit Script from the context menu.

    Copy/paste the info below into the newly created file:
    (You can paste over the info that is already in the new file.)

    Code:
    Opt("WinTitleMatchMode", 3) ;3 = exact title match
    Opt("TrayIconDebug", 1)
    
    $S_running = "check-4-app" ;name the script
    If WinExists($S_running) Then Exit
    AutoItWinSetTitle($S_running)
    
    $title = "Untitled - Notepad"
    $count = 0
    While 1
        $state = WinGetState($title)
        $count += 1
    
        If $state = 15 Or $state = 47 Or $state = 0 Then $count = 0
    
        If $count > 10 Then WinClose($title)
    
        ToolTip("count = " & $count, 0, 0, "state = " & $state)
        Sleep(1000)
    WEnd
    Save that file.
    Move it to the Startup folder.
    Right click on the file and select Run Script from the context menu.

    You can end the script by clicking on the AutoIt icon in the notification area down by the clock.

    If you would rather not have an AutoIt icon in the notification area, add this line...
    #NoTrayIcon
    ...as the first line of the script.
    If you do that, then you can kill the script (if need be) via Task Manager.
    Kill the process named AutoIt3.exe.


    The script in the code box above is going to close the app after 6 seconds.
    Change
    If $count > 6 Then WinClose($title)
    to
    If $count > 600 Then WinClose($title)
    to make it wait 10 minutes (600 seconds).

    Change the text in this line to match the app that you want to close:
    $title = "Untitled - Notepad"
    The title needs to be an exact match.
    If the title of the app to be closed changes a bit (like notepad's title changes once you save a file), then we can change the code to handle matching a part of the title.

    If the app to be closed can get into a state where it will not close (like notepad with unsaved changes), then we can add code to deal with that. If need be, we can kill the app and lose the unsaved changes.

    Hide the ToolTip that I used for debugging by adding a semicolon before that line as shown in the video





    This part of the script just sets a name for the invisible window that the script will create:
    Code:
    $S_running = "check-4-app" ;name the script
    If WinExists($S_running) Then Exit
    AutoItWinSetTitle($S_running)
    You can change "check-4-app" to anything that you want... maybe "~~check-4-app-2-close~~". Just pick a name that won't exist in any other app window title that you run. If you happen to start a second instance of the script, that second copy should just exit because it sees a window with its name already running.
    Last edited by UsernameIssues; 22 Sep 2016 at 09:50. Reason: changed code to - If $state = 15 Or $state = 47 Or $state = 0 Then $count = 0
      My Computer


  8. Posts : 4
    Windows 7 Professional 64Bit
    Thread Starter
       #8

    That is awesome UsernameIssues!
    Now I will have to confirm this with our IT department head if he allows us to use AutoIt.
    But if someone post a PowerShell script, I think I will go that way. But at least now I have an alternative that actually works!

    Thanks for the solution!
      My Computer


  9. Posts : 10,485
    W7 Pro SP1 64bit
       #9

    You are welcome.

    As part of your pitch to IT, you can mention that AutoIt has been around since 1998. https://www.autoitscript.com/autoit3...ev_history.htm

    I have used it since 1999 and I'm still an amateur


    I leave most of my scripts as text files. I usually only compile them if I'm going to give them to coworkers.
      My Computer


  10. Posts : 4
    Windows 7
       #10

    Just thought I would add to this. I found this looking for a similar solution. I found and used Idle Software Closer yesterday. Does the trick try it Idle Software Closer - Automatically Close Programs Auto
      My Computer


 
Page 1 of 3 123 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:37.
Find Us