Jump to content

While.. Func.. EndFunc...Wend


Recommended Posts

I've made a little script for my PC to stop it from sleeping, but i just can't seem to make this function loop ;)

I'm very new to the scripting and development with AutoIt3.

At the moment i have the following..

HotKeySet("{F1}", "start")
HotKeySet("{F2}", "stop")

Func start()
    MouseMove(303, 180, 20)
    Sleep(300)
    MouseMove(323, 210, 20)
    Sleep(300)
EndFunc

Func stop()
    Sleep(0)
EndFunc

and when i do press F1 it run's once, but it doesn't loop. Even when i add While 1 ... WEnd it comes up with a error saying 'While doesn't have a Wend statement'

Sorry i did search for keywords like 'loop' and 'while ... wend' and i didn't get anything i wanted.

I hope you can help.

Thankyou.

Link to comment
Share on other sites

  • Developers

Have you looked at the HotKeySet() example which is probably more or less what you want?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I've made a little script for my PC to stop it from sleeping, but i just can't seem to make this function loop ;)

I'm very new to the scripting and development with AutoIt3.

At the moment i have the following..

HotKeySet("{F1}", "start")
HotKeySet("{F2}", "stop")

Func start()
    MouseMove(303, 180, 20)
    Sleep(300)
    MouseMove(323, 210, 20)
    Sleep(300)
EndFunc

Func stop()
    Sleep(0)
EndFunc

and when i do press F1 it run's once, but it doesn't loop. Even when i add While 1 ... WEnd it comes up with a error saying 'While doesn't have a Wend statement'

Sorry i did search for keywords like 'loop' and 'while ... wend' and i didn't get anything i wanted.

I hope you can help.

Thankyou.

Here's the code that should work

CODE
HotKeySet("{F1}", "start")

HotKeySet("{F2}", "stop")

HotKeySet("{PAUSE}", "pause")

Local $Paused

While 1

Sleep(100);This is so that your function doesn't start right away

WEnd

Func start()

While 1

MouseMove(303, 180, 20)

Sleep(300)

MouseMove(323, 210, 20)

Sleep(300)

WEnd

EndFunc

While 1

Sleep(100);Same reason

WEnd

Func Pause();You can take this out if you want

$Paused = NOT $Paused

While $Paused

ToolTip("Script is paused", 0, 0)

sleep(100)

ToolTip("")

WEnd

EndFunc

While 1

Sleep(100)

WEnd

Func stop()

Exit;Exits script

EndFunc

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

Have you looked at the HotKeySet() example which is probably more or less what you want?

Jos

I have yeah, but i still dont understand it.

What i want is for that function to loop without any errors. (That hotkey {F1}) ;)

Edited by retrylater
Link to comment
Share on other sites

Thanks minikori, i adapted your script to make it work nicely. Though, i kept the stop() exit function, because i couldn't make it stop or 'sleep' :D and it made my computer a fool. Hopefully this should stop my computer from going to sleep at night time when im downloading my stuff for my WoW game ;)

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