Jump to content
Sign in to follow this  

New to Auto it

Recommended Posts

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


and this just not sure how to join these scripts?



should reboot it

Share this post

Link to post
Share on other sites

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

Edited by alienclone

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

>Exit code: 0

REAL search results

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

Share this post

Link to post
Share on other sites

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
        Sleep(5000); wait your 5 seconds
        ; whatever other code you want to do, eg. ShutDown()
    Sleep(250); CPU rest from loop

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  

  • Create New...