Ravel Posted April 13, 2006 Share Posted April 13, 2006 I am trying to create a script that will stay paused until a certain process becomes active (runs) and then close it. But after it closes... I would like to keep the script paused to close any future instances of the program that might become active. I have posted what i have so far below... does anyone know what i am doing wrong? If so could you show me what i am missing? Thanks in advance. HotkeySet('{PAUSE}', 'Terminate') while 1 If ProcessExists("sysLOAD_INI.pif") Then ProcessClose("sysLOAD_INI.pif") Endif Wend Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
greenmachine Posted April 13, 2006 Share Posted April 13, 2006 Assuming that's the actual process name, then it looks fine. However, for the sake of your CPU, you might want to add a sleep in the While loop. while 1 If ProcessExists("sysLOAD_INI.pif") Then ProcessClose("sysLOAD_INI.pif") Endif Sleep (20) Wend Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 13, 2006 Moderators Share Posted April 13, 2006 If I understand you correctly, you want to wait until the first instance is ran, then if another instance is opened, then you want to close any other instances other than the original instance... you can try this... I'm not sure if you can mod maybe the _SingleTon() in beta to do this, but this worked when I tested it on notepad.Global $FirstEXE = '', $Found = '' While 1 If ProcessExists('Notepad.exe') And $Found <> 1 Then $FirstEXE = ProcessExists('Notepad.exe') $Found = 1 EndIf Local $aProcList = ProcessList('Notepad.exe') If UBound($aProcList) - 1 > 1 Then For $icount = 1 To UBound($aProcList) - 1 If $aProcList[$icount][1] <> $FirstEXE Then ProcessClose($aProcList[$icount][1]) Next EndIf Sleep(10) WEnd Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
greenmachine Posted April 13, 2006 Share Posted April 13, 2006 If I understand you correctly, you want to wait until the first instance is ran, then if another instance is opened, then you want to close any other instances other than the original instance... you can try this... I'm not sure if you can mod maybe the _SingleTon() in beta to do this, but this worked when I tested it on notepad.Might want to try reading it again. It sure sounds to me like he just wants to wait around (forever) for a process to open, and immediately close it.. over and over. Link to comment Share on other sites More sharing options...
Ravel Posted April 13, 2006 Author Share Posted April 13, 2006 Might want to try reading it again. It sure sounds to me like he just wants to wait around (forever) for a process to open, and immediately close it.. over and over.Yea thats exactly what i want it to do. Until I can figure out a way to get the program off the pc... i just want to keep it closed... (it is some spin off of aol). Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 13, 2006 Moderators Share Posted April 13, 2006 Might want to try reading it again. It sure sounds to me like he just wants to wait around (forever) for a process to open, and immediately close it.. over and over.I would like to keep the script paused to close any future instances of the program that might become active.That's the part that had me confused is why I said "If I understand correctly". Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Ravel Posted April 13, 2006 Author Share Posted April 13, 2006 Its cool I appreciate the help. Thanks. 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