Jump to content

Start and Stop at certain times with loop.


 Share

Recommended Posts

Yes, I admit I am new to this, but I really want it to work.

The script is a very simple macro scrip with a loop and some hotkeys. So far it's working great, but I want it to be timed aswell, so I don't even need to be at the computer to start and stop it. I've searched through the forum, but even with this endless flow of topics I found no straight answer to my question.

This is my code, what command would I use and where in the script would I put it?

Global $stop;the variable for start / stop, has to be declared at the beginning

Hotkeyset("{F8}","go") ;starthotkey

Hotkeyset("{F9}","stop");stophotkey

hotkeyset("{F10}","quit"); shuts the lossbot down

Func Lossbot()

While $stop > 2;starts loop

sleep(9000);9 sec delay before it starts another quick game

send("!q");start quickgame

sleep(510000);7 min delay before lossbot will leave

send("!q"); opens leave menue

send("!q") ; quits mission

sleep(5000);5 sec delay before it presses enter to exit scoretable

send("{enter}");leaves out of the scoretable

Wend;ends loop

EndFunc

while 1 ;the idling loop that the program wont close

sleep(10)

WEnd

func go() ;function to start the bot

$stop = 3 ; if stop > 2 ==> loop will be done until stop hotkey will be pressed

Lossbot()

EndFunc

func stop() ; function to stop the bot

$stop = 1;if stop < 2 ==> loop will run until the end and func lossbot will end too.

EndFunc

func quit() ;closes the lossbot, i think it speaks for itself :D

MsgBox(0,"","Lossbot closed")

Exit

Endfunc

Thanks -

Link to comment
Share on other sites

Yes, I admit I am new to this, but I really want it to work.

The script is a very simple macro scrip with a loop and some hotkeys. So far it's working great, but I want it to be timed aswell, so I don't even need to be at the computer to start and stop it. I've searched through the forum, but even with this endless flow of topics I found no straight answer to my question.

This is my code, what command would I use and where in the script would I put it?

Global $stop;the variable for start / stop, has to be declared at the beginning

Hotkeyset("{F8}","go") ;starthotkey

Hotkeyset("{F9}","stop");stophotkey

hotkeyset("{F10}","quit"); shuts the lossbot down

Func Lossbot()

While $stop > 2;starts loop

sleep(9000);9 sec delay before it starts another quick game

send("!q");start quickgame

sleep(510000);7 min delay before lossbot will leave

send("!q"); opens leave menue

send("!q") ; quits mission

sleep(5000);5 sec delay before it presses enter to exit scoretable

send("{enter}");leaves out of the scoretable

Wend;ends loop

EndFunc

while 1 ;the idling loop that the program wont close

sleep(10)

WEnd

func go() ;function to start the bot

$stop = 3 ; if stop > 2 ==> loop will be done until stop hotkey will be pressed

Lossbot()

EndFunc

func stop() ; function to stop the bot

$stop = 1;if stop < 2 ==> loop will run until the end and func lossbot will end too.

EndFunc

func quit() ;closes the lossbot, i think it speaks for itself :D

MsgBox(0,"","Lossbot closed")

Exit

Endfunc

Thanks -

Welcome to the AUtoIt forums Aue :D

Once you start your script and press F8 it will start a game then after 7 minutes it leaves the game then after 9 seconds it starts the game again so what do you need that's different? Do you mean that you want to be able to set the script to start a game at a certain time and then end the game at some other set time?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 3 weeks later...

Welcome to the AUtoIt forums Aue :)

Once you start your script and press F8 it will start a game then after 7 minutes it leaves the game then after 9 seconds it starts the game again so what do you need that's different? Do you mean that you want to be able to set the script to start a game at a certain time and then end the game at some other set time?

Oh right, I must have failed to make my needs clear.

I want it to start at a time, and stop at a time.

Example: Starts running the loop at 24:00 and runs the loop until 06:00 in the morning.

That more clear? ^^

Link to comment
Share on other sites

Oh right, I must have failed to make my needs clear.

I want it to start at a time, and stop at a time.

Example: Starts running the loop at 24:00 and runs the loop until 06:00 in the morning.

That more clear? ^^

Why can't you just use windows scheduled tasks app to start and stop the script?

Edited by netman74501
Link to comment
Share on other sites

Why can't you just use windows scheduled tasks app to start and stop the script?

Because I am quite sure this can be done in the autoit language, and therfor removing the need of yet another app.
Link to comment
Share on other sites

  • 1 month later...

how would i make the hotkeys into a gui button i tryed but the stop button dosnt work when the script is running. cos i am using sleep in it how would i get around this?

Global $stop;the variable for start / stop, has to be declared at the beginning

Hotkeyset("{F8}","go") ;starthotkey
Hotkeyset("{F9}","stop");stophotkey
hotkeyset("{F10}","quit"); shuts the lossbot down

Func Lossbot()
While $stop > 2;starts loop

sleep(9000);9 sec delay before it starts another quick game

send("!q");start quickgame

sleep(510000);7 min delay before lossbot will leave

send("!q"); opens leave menue

send("!q") ; quits mission

sleep(5000);5 sec delay before it presses enter to exit scoretable

send("{enter}");leaves out of the scoretable




Wend;ends loop
EndFunc

while 1 ;the idling loop that the program wont close
sleep(10)
WEnd

func go() ;function to start the bot
$stop = 3 ; if stop > 2 ==> loop will be done until stop hotkey will be pressed
Lossbot()
EndFunc

func stop() ; function to stop the bot
$stop = 1;if stop < 2 ==> loop will run until the end and func lossbot will end too.
EndFunc

func quit() ;closes the lossbot, i think it speaks for itself :)
MsgBox(0,"","Lossbot closed")
Exit
Endfunc
Link to comment
Share on other sites

try this script...

#script start here

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.0.0

Author: rvn

Script Function:

auto loop with time

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

Global $nMsg, $status

$status = 0

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Manual loop", 184, 41, -1, -1)

$Button1 = GUICtrlCreateButton("Start", 8, 8, 75, 25, 0)

$Button2 = GUICtrlCreateButton("Stop", 96, 8, 75, 25, 0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

start_()

Case $Button2

stop_()

EndSwitch

If (@HOUR = 24 Or (@HOUR >=1 And @HOUR <= 6 )) Then ; range 24 - 6 morning

$status = 1

Else

$status = 0

EndIf

If $status = 0 Then

Else

ToolTip ( "Loop ur script here",Random(1,@DesktopWidth),Random(1,@DesktopHeight),"Loop ur script here")

EndIf

WEnd

Func start_()

$status = 1

EndFunc

Func stop_()

$status = 0

EndFunc

#end of script

Link to comment
Share on other sites

@epicfail

Please stick to your own thread.

@Aue

Take a look at @hour in the helpfile.

Edit: @rvn, codeboxes make it a lot easier to read code, especially autoit codeboxes.

Edited by Hawkwing

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

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