Jump to content
Sign in to follow this  

Practice with Example Notebook

Recommended Posts


I'm trying to practice adding a timer to a script.

So I edited the Notepad example and added a loop with Sleep.

The script runs but it doesn't sleep for the 1 minute

What did I do wrong?

Here is my code:


; AutoIt Version: 3.0

; Language: English

; Platform: Win9x/NT

; Author: Jonathan Bennett (jon@hiddensoft.com)


; Script Function:

; Opens Notepad, types in some text and then quits.


HotKeySet("f","toggla"); Placing the hotkey in here is not necessary, but will allow you to do the function manually if you want to.

HotKeySet("{ESC}", "Terminate");a way to break out of the script

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)

$answer = MsgBox(4, "AutoIt Example (English Only)", "This script will run Notepad type in some text and then quit. Run?")

; Check the user's answer to the prompt (see the help file for MsgBox return values)

; If "No" was clicked (7) then exit the script

If $answer = 7 Then

MsgBox(0, "AutoIt", "OK. Bye!")



; Run Notepad


; Wait for the Notepad become active - it is titled "Untitled - Notepad" on English systems

WinWaitActive("Untitled - Notepad")

While 1


sleep(60000000); or however long you want to wait in microseconds.


Func toggla()

Send("Hello from Notepad.{ENTER}1 2 3 4 5 6 7 8 9 10{ENTER}")



Func Terminate()



; Now that the Notepad window is active type some text

; Now quit by pressing Alt-f and then x (File menu -> Exit)



; Now a screen will pop up and ask to save the changes, the window is called

; "Notepad" and has some text "Yes" and "No"



; Now wait for Notepad to close before continuing

WinWaitClose("Untitled - Notepad")

; Finished!

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.