Jump to content
Sign in to follow this  
itauto3

Script to close an application

Recommended Posts

itauto3

This solution works, but there's other problem we are facing now. Our application (it's processes are closed using similar script as in the link) doesn't detect this as logout, so user status/session is still seen as 'login' instead of 'logout'. If we click on X in application window, this is regarded as 'logout' as it should be. Application is one of the ERP solution. Any suggestions?

 

Share this post


Link to post
Share on other sites
Andreik

So in what circumstances the user status goes from login to logout? Ask this question and then make a script to automate this and then simply kill the process.


When the words fail... music speaks

Share this post


Link to post
Share on other sites
Juvigy

Easy and fast is to send an mouse click to the coordinates of the "X" which are always the same. More elegant solution is to use the IE UDF to logout/close the app.

Share this post


Link to post
Share on other sites
itauto3

I tried this (it shows all opened windows containing expression1/exp2/exp3):

#include <Array.au3>

Local $var = WinList("[REGEXPTITLE:(?i)(.*exp1.*|.*exp2.*|.*exp3.*)]")
For $i = 1 To $var[0][0]
   If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
        MsgBox(0, "Open windows containing exp1/exp2/exp3", "Title=" & $var[$i][0])
   EndIf
Next

Func IsVisible($handle)
   If BitAND(WinGetState($handle), 2) Then
       Return 1
    Else
       Return 0
   EndIf
EndFunc

Now, where shoud I put a loop through the returned array and run WinClose on each one?

Share this post


Link to post
Share on other sites
itauto3

Why can't I just use WinClose($var[$i][0]) after MsgBox code?

Share this post


Link to post
Share on other sites
itauto3

If I use this:

$var = WinList("[REGEXPTITLE:(?i)(.*Note.*)]")

all Notepad windows are normally closed with posted code. If I enter part of the name of our ERP window(s), no success.

Share this post


Link to post
Share on other sites
itauto3

I've added #RequireAdmin and it's working now.

Share this post


Link to post
Share on other sites
itauto3

Another question: why aren't all windows closed at the same time? It goes one by one...

Share this post


Link to post
Share on other sites
itauto3

Ok, I've added one for statement.

Share this post


Link to post
Share on other sites
itauto3

I think at the moment this script reacts when user is inactive (idle) for some time (n seconds) regardless the app, e. g. if I have ERP app opened, and I go to other application, after n seconds ERP app won't close, if I act like I'm idle, it will close. Any idea?

Share this post


Link to post
Share on other sites
itauto3

Please, can anyone help me with closing app, that is running in background/behind other windows, that I don't want to close.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×