Tinnu Posted September 28, 2010 Share Posted September 28, 2010 i was thinking if this is possible to close all other autoit programs when my program is running. how to do it? Link to comment Share on other sites More sharing options...
HavikTech Posted September 28, 2010 Share Posted September 28, 2010 So, you want to run only one existence of your program? or close other autoit programs too? Link to comment Share on other sites More sharing options...
Tinnu Posted September 28, 2010 Author Share Posted September 28, 2010 not only those which are associated with current script. but i want to close all running AutoIt programs. Link to comment Share on other sites More sharing options...
HavikTech Posted September 28, 2010 Share Posted September 28, 2010 i think you can WinList("[REGEXPCLASS:.*?AutoIt.*?]") and then close Windows & processes. Link to comment Share on other sites More sharing options...
Tinnu Posted September 28, 2010 Author Share Posted September 28, 2010 i need some more explanation. because i could not understand your idea. please help! Link to comment Share on other sites More sharing options...
HavikTech Posted September 28, 2010 Share Posted September 28, 2010 See, what you have to do is Get a list of AutoIt running programs, then get their process Ids and Kill/Close them. Link to comment Share on other sites More sharing options...
Tinnu Posted September 28, 2010 Author Share Posted September 28, 2010 But that way my own script will be closed. Link to comment Share on other sites More sharing options...
HavikTech Posted September 28, 2010 Share Posted September 28, 2010 Exclude @AutoItPID by comparing with other AutoIt Process IDs. Link to comment Share on other sites More sharing options...
KaFu Posted September 28, 2010 Share Posted September 28, 2010 Nice idea with the Winlist ... _AutoIt_Close_Other_Instances() Func _AutoIt_Close_Other_Instances() $aWinlist = WinList("[REGEXPCLASS:.*?AutoIt.*?]") Local $s_PID, $s_PIDs For $i = 1 To UBound($aWinlist) - 1 $s_PID = WinGetProcess($aWinlist[$i][1]) If Not StringInStr($s_PIDs, $s_PID) Then $s_PIDs &= $s_PID & ";" Next $s_PIDs = StringLeft($s_PIDs, StringLen($s_PIDs) - 1) $a_PIDs = StringSplit($s_PIDs, ";") For $i = 1 To $a_PIDs[0] If ProcessExists($a_PIDs[$i]) Then If $a_PIDs[$i] <> @AutoItPID Then ProcessClose($a_PIDs[$i]) EndIf Next EndFunc ;==>_AutoIt_Close_Other_Instances  OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Tinnu Posted September 28, 2010 Author Share Posted September 28, 2010 (edited) Thanks to HavikTech for the idea & KaFu for the script. now i am trying to understand it. Edited September 28, 2010 by Tinnu Link to comment Share on other sites More sharing options...
HavikTech Posted September 28, 2010 Share Posted September 28, 2010 I think this one 'll be easy to understand... Close_Autoit_Programs() Func Close_Autoit_Programs() Local $My_Process_ID = @AutoItPID Local $Get_List = WinList("[REGEXPCLASS:.*?AutoIt.*?]") Local $PID = 0 For $i = 1 To $Get_List[0][0] $PID = WinGetProcess($Get_List[$i][1]) If $PID <> $My_Process_ID Then WinKill($Get_List[$i][1]) ProcessClose($PID) EndIf Next Return EndFunc Link to comment Share on other sites More sharing options...
Tinnu Posted September 28, 2010 Author Share Posted September 28, 2010 Thanks HavikTech for the short version. but i want to know that which one is fast and better? Your script or KaFu's? 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