reviewoutlawyes Posted November 26, 2014 Share Posted November 26, 2014 Just trying to make a simple script if Notepad gets closed then the computer will restart, and it will keep checking every 5 secs if it's closed. how would i go about that? $var = ProcessExists(“notepad.exe”);Author = no17$i = 0DoIf ProcessExists(“ProcessName”) = True ThenProcessWaitClose(“ProcessName”)ElseIf ProcessExists(“ProcessName”) = False ThenProcessClose(“ProcessName”) FileDelete(@TempDir)$i = $i + 1EndIfUntil $i = 1 and this just not sure how to join these scripts? Shutdown(6) should reboot it Link to comment Share on other sites More sharing options...
Solution alienclone Posted November 26, 2014 Solution Share Posted November 26, 2014 (edited) while 1 do sleep(5000); 5 seconds until not processexists("notepad.exe") Shutdown(6) WEnd Edited November 26, 2014 by alienclone If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 26, 2014 Moderators Share Posted November 26, 2014 Use the AutoIt code tag (the blue A) on the bar above your text when typing to insert code, it makes it much easier to read. ; pseudo code Global $gsz_Process = "notepad.exe" Global $gn_PID = 0 While 1 $gn_PID = ProcessExists($gsz_Process) If $gn_PID Then ProcessWaitClose($gn_PID) Sleep(5000); wait your 5 seconds ; whatever other code you want to do, eg. ShutDown() EndIf Sleep(250); CPU rest from loop 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...
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