Fretwise Posted August 5, 2010 Posted August 5, 2010 I have a extremely simple program used for automating basic actions within a program. The problem is, due to it being executed within a while loop its causing the cpu usage to go to 50% just for the process, thus making the original process that it's mimicking actions for having slow down issues. Is there a better way to do this without it using all the cpu? Thanks in advance expandcollapse popup$Run = 0 $We = 1 ;Global $Paused HotKeySet("e", "CON") HotKeySet("d", "SMI") HotKeySet("f", "SYN") HotKeySet("g", "TEL") HotKeySet("/", "Quit") HotKeySet("'", "Pause") While 1 If $Run = 1 Then If $We = 1 Then Send("{F6}") Send("{F2}") $Run = 0 ElseIf $We <> 1 Then Send("w") Send("e") $We = 1 EndIf EndIf If $Run = 2 Then If $We = 2 Then Send("{F3}") Send("{F4}") $Run = 0 ElseIf $We <> 2 Then Send("w") Send("d") $We = 2 EndIf EndIf If $Run = 3 Then If $We = 1 Then Send("{F5}") Send("{F2}") $Run = 0 ElseIf $We <> 1 Then Send("w") Send("f") $We = 1 EndIf EndIf If $Run = 4 Then If $We = 2 Then Send("{F1}") MouseClick("Right") Send("{F3}") Send("{F4}") $Run = 0 ElseIf $We <> 2 Then Send("w") Send("g") $We = 2 EndIf EndIf WEnd Func CON() $Run = 1 EndFunc Func SMI() $Run = 2 EndFunc Func SYN() $Run = 3 EndFunc Func TEL() $Run = 4 EndFunc ;Func Pause() ; Send("{ENTER}") ; $Paused = NOT $Paused ; While $Paused ; sleep(100) ; ToolTip('Script is "Paused"',200,200) ; WEnd ; ToolTip("") ;EndFunc Func Quit() Exit EndFunc
somdcomputerguy Posted August 5, 2010 Posted August 5, 2010 Add this Sleep(10) as the last line in the While loop. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Fretwise Posted August 5, 2010 Author Posted August 5, 2010 Thanks, I was almost positive a sleep or waiting for an input would have done the trick but wasnt quite sure in autoit. Thanks for the help
somdcomputerguy Posted August 5, 2010 Posted August 5, 2010 You bet man. Good luck. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
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