Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


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

20 Oct 2015   #1
edwinprakoso

Windows 7 Professional 64Bit
 
 
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 System SpecsSystem Spec
.
02 Nov 2015   #2
D3LL

 
 

You would need to Google for some third party software to enable you to this. This is not possible with the Windows features.
My System SpecsSystem Spec
02 Nov 2015   #3
UsernameIssues

W7 Pro SP1 64bit
 
 

Quote   Quote: Originally Posted by D3LL View Post
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 System SpecsSystem Spec
.

02 Nov 2015   #4
edwinprakoso

Windows 7 Professional 64Bit
 
 

Thanks guys,

Are there any links for a documentation about this feature in PowerShell? Probably I can check it myself.
My System SpecsSystem Spec
03 Nov 2015   #5
UsernameIssues

W7 Pro SP1 64bit
 
 

I'm not familiar with PowerShell resources/tutorials.

If someone does not help you out soon...
...take a look at AutoIt; specifically, WinGetState.
My System SpecsSystem Spec
03 Nov 2015   #6
edwinprakoso

Windows 7 Professional 64Bit
 
 

Thanks @UsernameIssues,

I will take a look.
My System SpecsSystem Spec
03 Nov 2015   #7
UsernameIssues

W7 Pro SP1 64bit
 
 

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.
My System SpecsSystem Spec
03 Nov 2015   #8
edwinprakoso

Windows 7 Professional 64Bit
 
 

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 System SpecsSystem Spec
03 Nov 2015   #9
UsernameIssues

W7 Pro SP1 64bit
 
 

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 System SpecsSystem Spec
05 Jul 2016   #10
tomwilliams123

Windows 7
 
 

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 System SpecsSystem Spec
Reply

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




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
I need a .VBS script for a tool to save and automatically close
i want to make netpass.exe window automatically close after make his job and save the password list in a .TXT file Can anyone help me with that please? here the pack to work and test U can downlaod the tool from here: https://www.sendspace.com/file/rcj5oz ...
General Discussion
How to schedule programs to start/close automatically
I want to have my Computer automatically start at 9pm, have utorrent start and run til midnight, then, at midnight, have steam start and run til 6am and have my computer shutdown then, so just to recap: 9PM Computer Start, Utorrent Starts 12AM Utorrent Closes, Steam Starts 6AM Computer Shutdown
General Discussion
How To Close (But Not Force Close) Program Automatically On A Schedule
not sure if it's possible in Task Scheduler but i really want it to work. Basically I know how to automatically start program in Task Scheduler and how to also force close it. If we want to force close it we just create a .bat file with text like TASKKILL /F /IM "nameofprogram.exe" and schedule to...
General Discussion
Is normal start menu close automatically after 1 min?
when I click on start menu and dont move the mouse after 1 minute is disappear the start menu. this normal.?
General Discussion
Program to automatically close and open other programs?
When I'm running on battery power, I'd like to be able to close certain programs to save power (e.g. that send a smile/frown thing for MS Office 2010 beta, Skype, MSN, my dictionary program etc), but instead of closing them one by one, which is a bit of a kerfuffle, I'd like to able to do it with a...
Software
Team Fortress 2 it will close after about 4 seconds idle?
DON'T WORRY I FIXED IT Thanks for your help anyway Regards Jack.
Gaming


Our Sites

Site Links

About Us

Find 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 19:40.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App