Jump to content

New to Auto it


Go to solution Solved by alienclone,

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
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

Link to comment
Share on other sites

  • Solution

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

"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

  • Moderators

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...