Jump to content
Sign in to follow this  
reviewoutlawyes

New to Auto it

Recommended Posts

reviewoutlawyes

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 = 0
Do
If ProcessExists(“ProcessName”) = True Then
ProcessWaitClose(“ProcessName”)
ElseIf ProcessExists(“ProcessName”) = False Then
ProcessClose(“ProcessName”) FileDelete(@TempDir)
$i = $i + 1
EndIf
Until $i = 1

 

and this just not sure how to join these scripts?

 

Shutdown(6)

should reboot it

Share this post


Link to post
Share on other sites
alienclone

while 1
do
sleep(5000); 5 seconds
until not processexists("notepad.exe")
Shutdown(6)
WEnd

Edited by alienclone

if @error Then
	MsgBox(262192,"",@ComputerName&" slaps "&@UserName&" around a bit with a large trout!")
	EndIf

>Exit code: 0

REAL search results

"Yeah yeah yeah, patience. How long will that take?"  -Ed Gruberman

Share this post


Link to post
Share on other sites
SmOke_N

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×