itauto3 Posted May 25, 2018 Share Posted May 25, 2018 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? Link to comment Share on other sites More sharing options...
Andreik Posted May 25, 2018 Share Posted May 25, 2018 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. Link to comment Share on other sites More sharing options...
Juvigy Posted May 25, 2018 Share Posted May 25, 2018 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. Link to comment Share on other sites More sharing options...
itauto3 Posted May 25, 2018 Author Share Posted May 25, 2018 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? Link to comment Share on other sites More sharing options...
itauto3 Posted May 25, 2018 Author Share Posted May 25, 2018 Why can't I just use WinClose($var[$i][0]) after MsgBox code? Link to comment Share on other sites More sharing options...
itauto3 Posted May 25, 2018 Author Share Posted May 25, 2018 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. Link to comment Share on other sites More sharing options...
itauto3 Posted May 25, 2018 Author Share Posted May 25, 2018 I've added #RequireAdmin and it's working now. Link to comment Share on other sites More sharing options...
itauto3 Posted May 25, 2018 Author Share Posted May 25, 2018 Another question: why aren't all windows closed at the same time? It goes one by one... Link to comment Share on other sites More sharing options...
itauto3 Posted May 25, 2018 Author Share Posted May 25, 2018 Ok, I've added one for statement. Link to comment Share on other sites More sharing options...
itauto3 Posted May 25, 2018 Author Share Posted May 25, 2018 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? Link to comment Share on other sites More sharing options...
itauto3 Posted May 28, 2018 Author Share Posted May 28, 2018 Please, can anyone help me with closing app, that is running in background/behind other windows, that I don't want to close. Link to comment Share on other sites More sharing options...
itauto3 Posted January 10, 2019 Author Share Posted January 10, 2019 No one answered, so, the 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? Link to comment Share on other sites More sharing options...
Juvigy Posted January 10, 2019 Share Posted January 10, 2019 Show us your code... Link to comment Share on other sites More sharing options...
itauto3 Posted January 10, 2019 Author Share Posted January 10, 2019 (edited) I've tried another option: #include <Timers.au3> #include <Array.au3> #RequireAdmin $count = 0 While 1 Local $var = WinList("[REGEXPTITLE:(?i)(.*X.*|.*Y.*|.*Z.*)]") _ArrayDisplay($var) For $i = 1 To $var[0][0] $state = WinGetState($var[i][0]) $count += 1 If $var[$i][0] = "" or $state = 0 Then $count = 0 If $count > 10 Then WinClose($var[i][0]) ToolTip("count = " & $count, 0, 0, "state = " & $state) Next Sleep(1000) WEnd Edited January 11, 2019 by itauto3 Wrong copy/paste Link to comment Share on other sites More sharing options...
itauto3 Posted January 11, 2019 Author Share Posted January 11, 2019 No answer? Link to comment Share on other sites More sharing options...
Juvigy Posted January 11, 2019 Share Posted January 11, 2019 And what doesnt work on that option ? Link to comment Share on other sites More sharing options...
itauto3 Posted January 11, 2019 Author Share Posted January 11, 2019 No tooltip and consequently no counting and no closing. Link to comment Share on other sites More sharing options...
itauto3 Posted January 11, 2019 Author Share Posted January 11, 2019 (edited) Now I get a tooltip, but the window doesn't close after count gets to 5 - everytime I get this error: Unknown function name.: If $count > 5 Then WinClose($aWindows If $count > 5 Then WinClose($aWindows[^ ERROR >Exit code: 1 Time: 10.48 Edited January 11, 2019 by itauto3 Fault Link to comment Share on other sites More sharing options...
Juvigy Posted January 11, 2019 Share Posted January 11, 2019 Strange, what version of AutoIt do you have? Also what is your current code as in the error i see If $count > 5 Then WinClose($aWindows And in your example code i see: If $count > 10 Then WinClose($var[0]) Which is different and i am guessing you have changed more things... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 11, 2019 Moderators Share Posted January 11, 2019 itauto3, The error tells you what is wrong and where: If $count > 10 Then WinClose($var[i][0]) You are missing the leading $ from the $i variable - so AutoIt thinks you are using a first class function, which of course does not exist! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now