toonboon Posted November 21, 2008 Posted November 21, 2008 How can I detect whether a process is already running? Not the script itself, there's a function to check that, but a standalone process. Please help me Thanks in advance. [right]~What can I say, I'm a Simplistic person[/right]
Andreik Posted November 21, 2008 Posted November 21, 2008 How can I detect whether a process is already running?Not the script itself, there's a function to check that, but a standalone process.Please help me Thanks in advance.Use ProcessExists() or ProcessList ().
toonboon Posted November 21, 2008 Author Posted November 21, 2008 With ProcessExists() I can check whether a process exists.. but I know the process exists. I need to know whether it exists twice I'll try ProcessList though thanks for the tip. (NO I'm not closing the process and then running ProcessExists() to see whether the process is still there xD) [right]~What can I say, I'm a Simplistic person[/right]
cheatera Posted November 21, 2008 Posted November 21, 2008 (edited) ;Run("notepad.exe"); testing with notepad ;Run("notepad.exe") $name = InputBox("enter process name", "enter", "notepad.exe") $list = ProcessList($name) for $i = 1 to $list[0][0] For $t = 1 to $list[0][0] If $list[$t][0] = $list[$i][0] And $list[$t][1] <> $list[$i][1] then;checks if there is proccess with SAME name but with DIFFERENT PID. MsgBox(0, "process exists twice OR more:", $list[$t][0] & " - PID: " & $list[$t][1] & @CRLF & $list[$i][0] & " - PID: " & $list[$i][1]) EndIf Next next try this, i think it will help if u want to close the most new process - close this one with the higher PID, and if for the first started - the lower PID (i think) Edited November 21, 2008 by cheatera Is There A Life BEFORE Death?im stupidSaved warn logs: cheateraSmOke_N Note Added 17 January 2009 - 02:54 PM Added to warn level Posting a way to hack the registry and force sending someones desktop via TCP. Jos Note Added 25 November 2008 - 02:52 PM Added to warn level for being an impolite rookie.once a year i go bad ... what will happen in 2010??[u]Its GOOD to be BAD ... (Warlock's Succubus - World of Warcraft)[/u]
toonboon Posted November 21, 2008 Author Posted November 21, 2008 (edited) $name = InputBox("enter process name", "enter", "notepad.exe") $amount = Processlist($name) While $amount[0][0]>1 ProcessClose($name) $amount = Processlist($name) WEnd MsgBox(0,"1 left","the is now only one process left of notepad.exe") I prefer my coding, I think it's a bit simpler. EDIT: typo Edited November 21, 2008 by toonboon [right]~What can I say, I'm a Simplistic person[/right]
cheatera Posted November 21, 2008 Posted November 21, 2008 what about 3 processes? or u are sure there are only 2? i mean in my example it shows all processes (2,3, ... 55 ... ) but yes yours it simplier btw just checked: the most rescent open process is with the higher PID, so if u want to close the most rescent - kill the process with higher PID. cheerz Is There A Life BEFORE Death?im stupidSaved warn logs: cheateraSmOke_N Note Added 17 January 2009 - 02:54 PM Added to warn level Posting a way to hack the registry and force sending someones desktop via TCP. Jos Note Added 25 November 2008 - 02:52 PM Added to warn level for being an impolite rookie.once a year i go bad ... what will happen in 2010??[u]Its GOOD to be BAD ... (Warlock's Succubus - World of Warcraft)[/u]
toonboon Posted November 21, 2008 Author Posted November 21, 2008 there can also be 1000 processes, but my script kills each and every one untill only one remains. so that's what I need. I don't think it matters whether I close the older or the newer.. but I'll check. [right]~What can I say, I'm a Simplistic person[/right]
bouncingmolar Posted December 1, 2008 Posted December 1, 2008 How can I detect whether a process is already running?Not the script itself, there's a function to check that....sorry to hijack this thread (it seems u've already found a solution) but what is this function that detects whether the script itself is already running?
Moderators SmOke_N Posted December 1, 2008 Moderators Posted December 1, 2008 sorry to hijack this thread (it seems u've already found a solution) but what is this function that detects whether the script itself is already running?Look for _Singleton in the help file. 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.
bouncingmolar Posted December 2, 2008 Posted December 2, 2008 Look for _Singleton in the help file.cool thanks!
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