Jump to content

Loop script


Recommended Posts

hi,

so i have this script that loop

and i would like to add a script into the loop but that will only run once each hour or so then continue back to other script

any idéa ;)? how does ContinueLoop, ExitLoop work?

Edited by HackUser
Link to comment
Share on other sites

  • Moderators

HackUser,

Welcome to the AutoIt forum. ;)

I would also look at AdlibRegister - with that function you can break into the script every hour very easily. :)

M23

P.S. Nothing personal - but with a nick like that, can you please make sure you read the Forum Rules before too long. :)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

thanks hannes08

Would you mind put that code into my script ;)?

Global $Paused, $Runner
HotKeySet("q" , "loggin")
HotKeySet("w", "Terminate")
HotKeySet("{PAUSE}", "TogglePause")

While 1
    Sleep(10)
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(10)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func loggin ()
    
    $Runner = Not $Runner
    While $Runner
    MouseClick("left", 300, 420, 1)
    Sleep(4000)
    MouseClick("left", 700, 450, 1)
    Sleep(1000)
    MouseMove(300, 450, 1)
    Sleep(100)
    MouseWheel("down",3)
    Sleep(100)
    MouseClick("left", 300, 820, 1)
    Sleep(1500)

WEnd

EndFunc

This is the script i want to happen, once each hour

Send("{ESC}")

MouseClick ( "left", 970, 600, 1)

Sleep(13000)

EDIT

HackUser,

Welcome to the AutoIt forum. :)

P.S. Nothing personal - but with a nick like that, can you please make sure you read the Forum Rules before too long.

thank you! my nick doesnt reflect my scripts or attentions at all, just like the name :) i will make sure to read the forum rules Edited by Melba23
Added code tags
Link to comment
Share on other sites

  • Moderators

HackUser,

Have you even looked at the Help file concerning that function yet? ;)

You try and put in in yourself first. :)

M23

P.S. When you post code please use Code tags - put [autoit] before and [/autoit] after your posted code. I will change the post above for you. :)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thank you for letting me TRY first ;)

not that im lazy, i read and look old posts in google, just that i learn best when seeing other exampels :) havent found one.

is this close? btw 1000 > 60 * 60, meens 1 sec multiply 60, =1 minut, multiply 60 = 1hour?

Global $Paused, $Runner
HotKeySet("q" , "loggin")
HotKeySet("w", "Terminate")
HotKeySet("{PAUSE}", "TogglePause")

While 1
    Sleep(10)
WEnd

While 1
    If TimerDiff($t) / 1000 > 60 * 60 Then
    $tTimer = TimerInit()

Send("{ESC}")
MouseClick ( "left", 970, 600, 1)
Sleep(13000)

    EndIf
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(10)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func loggin ()

$tTimer = TimerInit()

    $Runner = Not $Runner
    While $Runner
    MouseClick("left", 300, 420, 1)
    Sleep(4000)
    MouseClick("left", 700, 450, 1)
    Sleep(1000)
    MouseMove(300, 450, 1)
    Sleep(100)
    MouseWheel("down",3)
    Sleep(100)
    MouseClick("left", 300, 820, 1)
    Sleep(1500)

WEnd

EndFunc
Edited by HackUser
Link to comment
Share on other sites

  • Moderators

HackUser,

Thank you for letting me TRY first

That is how we work here - think of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever". We try to be net makers and repairers, not fishmongers. ;)

How do you think you will ever leave the first loop? You only need the one:

Global $Paused, $Runner
HotKeySet("q", "loggin")
HotKeySet("w", "Terminate")
HotKeySet("{PAUSE}", "TogglePause")

; Initialise the timestamp
$tTimer = TimerInit()

While 1
    ; Wait for 60 mins
    If TimerDiff($t) / 1000 > 60 * 60 Then
        ; Reinitialise the timestamp
        $tTimer = TimerInit()
        ; Run the code
        Send("{ESC}")
        MouseClick("left", 970, 600, 1)
        Sleep(13000)
    EndIf
    ; Prevent the CPU overheating
    Sleep(10)
WEnd

; Rest of code

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

That is how we work here - think of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever". We try to be net makers and repairers, not fishmongers. :)

My teacher said that same quote to me aswell when i went economic school :)

Thank you for helping, i get error. might showing me the problem? ;)

edit: something with WEnd or EndFunc is wrong

Global $Paused, $Runner
HotKeySet("q", "loggin")
HotKeySet("w", "Terminate")
HotKeySet("{PAUSE}", "TogglePause")

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
    Sleep(10)
    ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

; Initialise the timestamp
$tTimer = TimerInit()

While 1
    ; Wait for 60 mins
    If TimerDiff($t) / 1000 > 60 * 60 Then
        ; Reinitialise the timestamp
        $tTimer = TimerInit()
        ; Run the code
     Send("{ESC}")
        MouseClick("left", 970, 600, 1)
        Sleep(13000)
    EndIf
    ; Prevent the CPU overheating
    Sleep(10)
WEnd


Func loggin ()
    $Runner = Not $Runner
    While $Runner
        
    MouseClick("left", 300, 420, 1)
    Sleep(6000)
    MouseClick("left", 700, 450, 1)
    Sleep(1000)
    MouseMove(300, 450, 1)
    Sleep(100)
    MouseWheel("down",3)
    Sleep(100)
    MouseClick("left", 300, 820, 1)
    Sleep(1500)

WEnd
EndFunc
Edited by HackUser
Link to comment
Share on other sites

  • Moderators

HackUser,

The only error I get from that script is that you need to change the variable here: ;)

TimerDiff($t) ; Should be TimerDiff($tTimer)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I don't know if this is the cause of whatever error you're getting, but TimerDiff($t) should probably be TimerDiff($tTimer).

yes worked now.

thank you both!

EDIT: i will try become a good fisher ;)

Edited by HackUser
Link to comment
Share on other sites

I'm glad that your script is working for you, and that I was apparently on the same page as the illustrious M23. A modified version of that quote that I use from time to time is this, "Give a man a fish and he eats a meal, teach him to fish and he learns how to sit in a boat and drink beer" ;)

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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