russell Posted September 3, 2010 Share Posted September 3, 2010 (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 September 3, 2010 by russell muppet hands are so soft :) Link to comment Share on other sites More sharing options...
jaberwacky Posted September 3, 2010 Share Posted September 3, 2010 Look up Adlib in the helpfile Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
russell Posted September 3, 2010 Author Share Posted September 3, 2010 Look up Adlib in the helpfileok i give it a try thanks muppet hands are so soft :) Link to comment Share on other sites More sharing options...
Varian Posted September 3, 2010 Share Posted September 3, 2010 Does the entire script need to loop? Link to comment Share on other sites More sharing options...
russell Posted September 3, 2010 Author Share Posted September 3, 2010 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 :) Link to comment Share on other sites More sharing options...
russell Posted September 3, 2010 Author Share Posted September 3, 2010 Does the entire script need to loop?yes, every 120 mins muppet hands are so soft :) Link to comment Share on other sites More sharing options...
jaberwacky Posted September 3, 2010 Share Posted September 3, 2010 (edited) Maybe this? Btw, what do you mean by it uses a box? A function? expandcollapse popupHotKeySet("{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 September 3, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Varian Posted September 3, 2010 Share Posted September 3, 2010 Just like malware, huh???? Link to comment Share on other sites More sharing options...
russell Posted September 3, 2010 Author Share Posted September 3, 2010 Maybe this? Btw, what do you mean by it uses a box? A function? expandcollapse popupHotKeySet("{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 :) Link to comment Share on other sites More sharing options...
jaberwacky Posted September 3, 2010 Share Posted September 3, 2010 Then you misunderstood the helpfile. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
russell Posted September 3, 2010 Author Share Posted September 3, 2010 Maybe this? Btw, what do you mean by it uses a box? A function? expandcollapse popupHotKeySet("{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 :) Link to comment Share on other sites More sharing options...
jaberwacky Posted September 3, 2010 Share Posted September 3, 2010 Just like malware, huh????*FacePalm* I'm too trusting I guess.<<< Fellow North Carolinian. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted September 3, 2010 Share Posted September 3, 2010 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. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
russell Posted September 3, 2010 Author Share Posted September 3, 2010 I was reffering to the Adlib in the helpfile. it said something about a box displayed to avoid cpu usage i thinkok 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 :) Link to comment Share on other sites More sharing options...
russell Posted September 3, 2010 Author Share Posted September 3, 2010 (edited) hmmm would changeing the last sleep (2000) to 120 mins do it? Im not 100% sure Edited September 3, 2010 by russell muppet hands are so soft :) Link to comment Share on other sites More sharing options...
ShawnW Posted September 3, 2010 Share Posted September 3, 2010 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. Link to comment Share on other sites More sharing options...
russell Posted September 3, 2010 Author Share Posted September 3, 2010 hmm nevermind i see it would only delay till it shutdown pc. hmmmm muppet hands are so soft :) Link to comment Share on other sites More sharing options...
russell Posted September 3, 2010 Author Share Posted September 3, 2010 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 :) Link to comment Share on other sites More sharing options...
ShawnW Posted September 3, 2010 Share Posted September 3, 2010 (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 September 3, 2010 by ShawnW Link to comment Share on other sites More sharing options...
jaberwacky Posted September 3, 2010 Share Posted September 3, 2010 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 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now