Sign in to follow this  
Followers 0
Steve1040

Practice with Example Notebook

3 posts in this topic

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:

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!")

Exit

EndIf

; Run Notepad

Run("notepad.exe")

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

WinWaitActive("Untitled - Notepad")

While 1

Toggla()

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

WEnd

Func toggla()

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

Sleep(60000000);

EndFunc

Func Terminate()

Exit

EndFunc

; Now that the Notepad window is active type some text

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

Send("!f")

Send("x")

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

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

WinWaitActive("Notepad")

Send("n")

; Now wait for Notepad to close before continuing

WinWaitClose("Untitled - Notepad")

; Finished!

Share this post


Link to post
Share on other sites



This may be your issue at first glance.

sleep(60000000) is not 1 minute

sleep(60000) is 1 minute

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