Jump to content

Why while 1 to Wend CPU 100%


 Share

Recommended Posts

Hi

i want to to know y between While1 to Wend take 100% cpu usage sleep time will reduce cpu usage

but any one know any better solution for continue loop :lmao:

If your loop is waiting for you to press a button or select something you could use GUIGetMsg


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Hi

i want to to know y between While1 to Wend take 100% cpu usage sleep time will reduce cpu usage

but any one know any better solution for continue loop :lmao:

put a Sleep(100) in your While 1 Loop. That should not spike the CPU usage. ;)

[quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD()

Link to comment
Share on other sites

AutoIt is trying it's best to do tasks the fastest it can, and that also counts

for loops. Also, if there's no point in the loop where the script gets any time

to "rest", the CPU-usage will go to 100%, which is understandable...

As the other people said, you will avoid this problem if you add a tiny Sleep

to your script. I personally use Sleep(1), and in some script I even use the

GUIGetMsg()..also for non-GUI scripts.

Link to comment
Share on other sites

  • Moderators

AutoIt is trying it's best to do tasks the fastest it can, and that also counts

for loops. Also, if there's no point in the loop where the script gets any time

to "rest", the CPU-usage will go to 100%, which is understandable...

As the other people said, you will avoid this problem if you add a tiny Sleep

to your script. I personally use Sleep(1), and in some script I even use the

GUIGetMsg()..also for non-GUI scripts.

I did a time test on Sleep(1) to Sleep(9) and they were all the same as Sleep(10) :lmao:;)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hi

Thanks okay helge how to use GUIGETMSG() for non-GUI script

for example in this case here sleep(100) works but i really want to avoid sleep() so tell how GUIGETMSG() works here in non-GUI script

While 1
   If ProcessExists('NOTEPAD.EXE') Then ProcessClose('NOTEPAD.EXE')
WEnd

I did a time test on Sleep(1) to Sleep(9) and they were all the same as Sleep(10)

yup i agree i also test 1 to 9 same as 10 no differnce i feel

Edited by autoitxp
Link to comment
Share on other sites

  • Moderators

More than you ever wanted to know about that issue can be found in this tread:

http://www.autoitscript.com/forum/index.ph...showtopic=13415

Here's my useles contribution :lmao:

For $i = 1 To 100
    $Time = TimerInit()
    Sleep($i)
    ConsoleWrite('Time for Sleep(' & $i & ') = ' & TimerDiff($Time) / 1000 & @LF)
Next

My output:

Time for Sleep(1) = 0.0105192140341859

Time for Sleep(2) = 0.0106588965916059

Time for Sleep(3) = 0.0107122553285404

Time for Sleep(4) = 0.0107170045354926

Time for Sleep(5) = 0.0107150489796888

Time for Sleep(6) = 0.0107223124726746

Time for Sleep(7) = 0.0107253854889378

Time for Sleep(8) = 0.0107061092960139

Time for Sleep(9) = 0.0107209156471004

Time for Sleep(10) = 0.010718121995952

Time for Sleep(11) = 0.010718121995952

Time for Sleep(12) = 0.021476472568441

Time for Sleep(13) = 0.0214482566918421

Time for Sleep(14) = 0.0214739582824074

Time for Sleep(15) = 0.0214435074848898

Time for Sleep(16) = 0.0214915582846423

Time for Sleep(17) = 0.0214175265292097

Time for Sleep(18) = 0.0214742376475222

Time for Sleep(19) = 0.0214365233570188

Time for Sleep(20) = 0.0214524471685647

Time for Sleep(21) = 0.0214611074871248

Time for Sleep(22) = 0.0214599900266654

Time for Sleep(23) = 0.0322074453596756

Time for Sleep(24) = 0.0321976675806562

Time for Sleep(25) = 0.032204931073642

Time for Sleep(26) = 0.0322082834550201

Time for Sleep(27) = 0.0322026961527233

Time for Sleep(28) = 0.0321781120226174

Time for Sleep(29) = 0.0322080040899053

Time for Sleep(30) = 0.0321951532946226

Time for Sleep(31) = 0.0322010199620343

Time for Sleep(32) = 0.0322052104387569

Time for Sleep(33) = 0.042963281646131

Time for Sleep(34) = 0.0429280816416612

Time for Sleep(35) = 0.042944005453207

Time for Sleep(36) = 0.0429359038648767

Time for Sleep(37) = 0.0430211102249029

Time for Sleep(38) = 0.0428604752838699

Time for Sleep(39) = 0.0435602848965441

Time for Sleep(40) = 0.0423352688679706

Time for Sleep(41) = 0.0429132752905746

Time for Sleep(42) = 0.0429487546601593

Time for Sleep(43) = 0.0429512689461929

Time for Sleep(44) = 0.0536816830071978

Time for Sleep(45) = 0.0536665972909965

Time for Sleep(46) = 0.0536984449140882

Time for Sleep(47) = 0.0536531877654842

Time for Sleep(48) = 0.0536964893582844

Time for Sleep(49) = 0.0536749782444417

Time for Sleep(50) = 0.0537012385652366

Time for Sleep(51) = 0.05365179093991

Time for Sleep(52) = 0.0537199560279309

Time for Sleep(53) = 0.0536515115747951

Time for Sleep(54) = 0.0536802861816236

Time for Sleep(55) = 0.0644411510401462

Time for Sleep(56) = 0.0644523256447398

Time for Sleep(57) = 0.0643891891287859

Time for Sleep(58) = 0.0644322113564713

Time for Sleep(59) = 0.0644489732633617

Time for Sleep(60) = 0.0643891891287859

Time for Sleep(61) = 0.06442578595883

Time for Sleep(62) = 0.06443444627739

Time for Sleep(63) = 0.0644171256402699

Time for Sleep(64) = 0.064418801830959

Time for Sleep(65) = 0.0644336081820455

Time for Sleep(66) = 0.0752123524079178

Time for Sleep(67) = 0.0761038064893722

Time for Sleep(68) = 0.0751570381151794

Time for Sleep(69) = 0.0751609492267872

Time for Sleep(70) = 0.0751589936709833

Time for Sleep(71) = 0.0751643016081653

Time for Sleep(72) = 0.075224085742741

Time for Sleep(73) = 0.0761574445914215

Time for Sleep(74) = 0.0750899904876178

Time for Sleep(75) = 0.0751570381151794

Time for Sleep(76) = 0.0751754762127589

Time for Sleep(77) = 0.0859005823365819

Time for Sleep(78) = 0.0859064490039935

Time for Sleep(79) = 0.0859257251969175

Time for Sleep(80) = 0.0868752872222587

Time for Sleep(81) = 0.085886334715725

Time for Sleep(82) = 0.0859243283713433

Time for Sleep(83) = 0.0858891283668734

Time for Sleep(84) = 0.0859190204341613

Time for Sleep(85) = 0.0869138396081066

Time for Sleep(86) = 0.0859338267852478

Time for Sleep(87) = 0.0965776376606524

Time for Sleep(88) = 0.0966329519533907

Time for Sleep(89) = 0.0966491551300514

Time for Sleep(90) = 0.096658653543956

Time for Sleep(91) = 0.0966458027486734

Time for Sleep(92) = 0.0966351868743094

Time for Sleep(93) = 0.096656977353267

Time for Sleep(94) = 0.0966343487789649

Time for Sleep(95) = 0.096658653543956

Time for Sleep(96) = 0.0966432884626398

Time for Sleep(97) = 0.107375378714334

Time for Sleep(98) = 0.107401918400244

Time for Sleep(99) = 0.107375937444563

Time for Sleep(100) = 0.107401359670014

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

...Thanks okay helge how to use GUIGETMSG() for non-GUI script

for example in this case here sleep(100) works but i really want to avoid sleep() so tell how GUIGETMSG() works here in non-GUI script...

;) Hmm...just put it in your script, where you would normally put the Sleep() :lmao:

Note that I rarely use this method; it's basically only when speed really matter,

and when I also want to avoid using to much CPU-power, thanks to the auto-idle.

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