Sign in to follow this  
Followers 0
russell

How do i loop this?

25 posts in this topic

#1 ·  Posted (edited)

While 1
Tooltip("F10= Exit", 0, 0)
HotKeySet("{F10}", "exitNow")
sleep (10000)
Run ( @ScriptDir & '\program.exe '  )
Sleep (5000)
Send ("{enter}")
Sleep (25000)
WinActivate ("program name")
WinMove ("program name", "", 0,0 ,550 , 570) ;first is width
sleep (1000)
MouseMove (460,510)
MouseClick ("left")
If WinActive("program name") Then sleep (5000)
WEnd

If Not WinActive("program name") Then Send("{LWIN}")
sleep (2000)    
    send ("{s}{h}{u}{t}{d}{o}{w}{n}{.}{e}{x}{e}")
    send ("{space}")
    send ("{-}{r}")
    send ("{enter}")
Func exitNow()
   Exit
EndFunc

I need it to loop every 120 mins but im lost .....i feel soo close

Edited by russell

muppet hands are so soft :)

Share this post


Link to post
Share on other sites



Look up Adlib in the helpfile

ok i give it a try ;) thanks

muppet hands are so soft :)

Share this post


Link to post
Share on other sites

Does the entire script need to loop?

Share this post


Link to post
Share on other sites

mmm from what i read, it uses a box and i cant do that :) i have to have the active window active or it will reboot the pc. then the pc boots the exe to restart the process. I want to make it loop so 2 hours later it will rerun the script. (so if it closes down it pulls back up. A fail safe if you will ;)


muppet hands are so soft :)

Share this post


Link to post
Share on other sites

Does the entire script need to loop?

yes, every 120 mins

muppet hands are so soft :)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Maybe this?

Btw, what do you mean by it uses a box? A function?

HotKeySet("{F10}", "exitNow")

Func exitNow()
    Exit
EndFunc ;==>exitNow

Global Const $ProgramName = "program name"

While 1
    Sleep(7200000) ; 120 minutes

    ToolTip("F10: Exit", 0, 0)
    
    Sleep(10000)
    
    Run(@ScriptDir & "\program.exe")
    
    Sleep(5000)
    
    Send("{enter}")
    
    Sleep(25000)
    
    WinActivate($ProgramName)   
    WinMove($ProgramName, '', 0, 0, 550, 570) ;first is width
    
    Sleep(1000)
    
    MouseMove(460, 510) 
    MouseClick("left")
    
    If WinActive($ProgramName) Then Sleep(5000)
WEnd

If Not WinActive($ProgramName) Then Send("{LWIN}")

Sleep(2000)

Send("{s}{h}{u}{t}{d}{o}{w}{n}{.}{e}{x}{e}")
Send("{space}")
Send("{-}{r}")
Send("{enter}")
Edited by jaberwocky6669

Share this post


Link to post
Share on other sites

Just like malware, huh????

Share this post


Link to post
Share on other sites

Maybe this?

Btw, what do you mean by it uses a box? A function?

HotKeySet("{F10}", "exitNow")

Func exitNow()
    Exit
EndFunc ;==>exitNow

Global Const $ProgramName = "program name"

While 1
    Sleep(7200000) ; 120 minutes

    ToolTip("F10: Exit", 0, 0)
    
    Sleep(10000)
    
    Run(@ScriptDir & "\program.exe")
    
    Sleep(5000)
    
    Send("{enter}")
    
    Sleep(25000)
    
    WinActivate($ProgramName)   
    WinMove($ProgramName, '', 0, 0, 550, 570) ;first is width
    
    Sleep(1000)
    
    MouseMove(460, 510) 
    MouseClick("left")
    
    If WinActive($ProgramName) Then Sleep(5000)
WEnd

If Not WinActive($ProgramName) Then Send("{LWIN}")

Sleep(2000)

Send("{s}{h}{u}{t}{d}{o}{w}{n}{.}{e}{x}{e}")
Send("{space}")
Send("{-}{r}")
Send("{enter}")

I was reffering to the Adlib in the helpfile. it said something about a box displayed to avoid cpu usage i think

muppet hands are so soft :)

Share this post


Link to post
Share on other sites

Maybe this?

Btw, what do you mean by it uses a box? A function?

HotKeySet("{F10}", "exitNow")

Func exitNow()
    Exit
EndFunc ;==>exitNow

Global Const $ProgramName = "program name"

While 1
    Sleep(7200000) ; 120 minutes

    ToolTip("F10: Exit", 0, 0)
    
    Sleep(10000)
    
    Run(@ScriptDir & "\program.exe")
    
    Sleep(5000)
    
    Send("{enter}")
    
    Sleep(25000)
    
    WinActivate($ProgramName)   
    WinMove($ProgramName, '', 0, 0, 550, 570) ;first is width
    
    Sleep(1000)
    
    MouseMove(460, 510) 
    MouseClick("left")
    
    If WinActive($ProgramName) Then Sleep(5000)
WEnd

If Not WinActive($ProgramName) Then Send("{LWIN}")

Sleep(2000)

Send("{s}{h}{u}{t}{d}{o}{w}{n}{.}{e}{x}{e}")
Send("{space}")
Send("{-}{r}")
Send("{enter}")

I am a noob so i might be totally wrong in this question but would the sleep 7200000 (would this not delay the script instead of loop?)

muppet hands are so soft :)

Share this post


Link to post
Share on other sites

I am a noob so i might be totally wrong in this question but would the sleep 7200000 (would this not delay the script instead of loop?)

You want the code to run once every 120 minutes? Then the Sleep() statement will sleep the code for 120 minutes and then iterate the While loop once. The code will then sleep for another two hours. Ad infinitum.

Share this post


Link to post
Share on other sites

I was reffering to the Adlib in the helpfile. it said something about a box displayed to avoid cpu usage i think

ok tried this a quickly realized that it would also delay from starting upon boot buy 120 mins. hmmm any way to have the script excute immediately then delay on second run?

muppet hands are so soft :)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

hmmm would changeing the last sleep (2000) to 120 mins do it? Im not 100% sure

Edited by russell

muppet hands are so soft :)

Share this post


Link to post
Share on other sites

LOL!!!

If Not WinActive($ProgramName) Then Send("{LWIN}")
Sleep(2000)
Send("{s}{h}{u}{t}{d}{o}{w}{n}{.}{e}{x}{e}")
Send("{space}")
Send("{-}{r}")
Send("{enter}")

That part really had me laughing. You need some serious work.

I mean 1st you try and call shutdown.exe instead of using the built in method, then you try to send it to the run box rather than use Run(), and then you put {} around every character weather it needs it or not, and finally you call 4 sends in a row rather than 1. Oh and I forgot how the whole section should be inside the 'If' statement or else you could be sending types letters to the wrong place.

Not to mention it wouldn't even work except on windows 7 where the run is apart of the start menu. It won't even work then if the user clicks anywhere during the entire 2 seconds you sleep after opening the menu.

Share this post


Link to post
Share on other sites

hmm nevermind i see it would only delay till it shutdown pc. hmmmm


muppet hands are so soft :)

Share this post


Link to post
Share on other sites

LOL!!!

If Not WinActive($ProgramName) Then Send("{LWIN}")
Sleep(2000)
Send("{s}{h}{u}{t}{d}{o}{w}{n}{.}{e}{x}{e}")
Send("{space}")
Send("{-}{r}")
Send("{enter}")

That part really had me laughing. You need some serious work.

I mean 1st you try and call shutdown.exe instead of using the built in method, then you try to send it to the run box rather than use Run(), and then you put {} around every character weather it needs it or not, and finally you call 4 sends in a row rather than 1. Oh and I forgot how the whole section should be inside the 'If' statement or else you could be sending types letters to the wrong place.

Not to mention it wouldn't even work except on windows 7 where the run is apart of the start menu. It won't even work then if the user clicks anywhere during the entire 2 seconds you sleep after opening the menu.

Yea im a big noob. Sorry, im still learning better and more effiecent ways. Can ya give me some pointers to shorten it and make more reliable?

muppet hands are so soft :)

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

omg I would but I can't stop laughing.

I mean seriously dude?

MouseMove(460, 510)
MouseClick("left")

I mean it's probably no slower than

MouseClick("left",460, 510)

...but who write it the 1st way?

And what about

Run ( @ScriptDir & '\program.exe '  )
Sleep (5000)
Send("{enter}")
Sleep(25000)
WinActivate($ProgramName)

What is the 25 seconds for? Does ProgramName run in the background when it starts? Programs normally open and become active so all you need is...

WinWaitActive($ProgramName)

I could go on but you need to read the help file.

Edit: And for the Shutdown all you need is

Shutdown(6)

Edit 2: I assume that Send("{enter}") is maybe because windows asks you if you are sure you want to run it or something like that. If so just figure out what that windows title is and do a WinWaitActive() for that as well, but use the timeout parameter in case it doesn't ask.

Edited by ShawnW

Share this post


Link to post
Share on other sites

Well, try this:

HotKeySet("{F10}", "exitNow")

Func exitNow()
    Exit
EndFunc ;==>exitNow

Global Const $ProgramName = "program name"

While 1
    ToolTip("F10: Exit", 0, 0)

    Sleep(10000)

    RunWait(@ScriptDir & "\program.exe")

    Send("{enter}")

    Sleep(25000)

    WinActivate($ProgramName)
    WinMove($ProgramName, '', 0, 0, 550, 570) ;first is width
    WinWaitActive($ProgramName)

    MouseMove(460, 510)
    MouseClick("left")

    If Not WinActive($ProgramName) Then
        Run("shutdown -r", @ComSpec, @SW_HIDE)
    EndIf

    Sleep(7200000) ; Sleep for two hours only to get up and do it all over again.
WEnd

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