Jabberwock Posted June 15, 2006 Posted June 15, 2006 Anyone want to try and explain why such a simple program is using soo much cpu load while running in the background? seems to do it with any hotkey. HotKeySet("{F11}", "hello") While 1 Wend Func hello() Send("Hello") Send("{Enter}") EndFunc
Moderators SmOke_N Posted June 15, 2006 Moderators Posted June 15, 2006 Anyone want to try and explain why such a simple program is using soo much cpu load while running in the background? seems to do it with any hotkey. HotKeySet("{F11}", "hello") While 1 Wend Func hello() Send("Hello") Send("{Enter}") EndFuncYou need to add a sleep in your script, if all your doing is hotkeys you could do:HotKeySet("{F11}", "hello") While 1 Sleep(1000000) Wend Func hello() Send("Hello {ENTER}") EndFunc 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.
marfdaman Posted June 15, 2006 Posted June 15, 2006 Or if you want to use things inside your loop as well you could just put a GuiGetMsg() in it, instead of a sleep. Alzo Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Moderators SmOke_N Posted June 15, 2006 Moderators Posted June 15, 2006 (edited) Or if you want to use things inside your loop as well you could just put a GuiGetMsg() in it, instead of a sleep.AlzoThat's a good point marf, I wonder if there is a default delay for GuiGetMsg() like there is for AdlibEnable().Edit:The test I did looks like 10 milleseconds... but I'm not sure if that was programmed that way. (I'm sure it was) Edited June 15, 2006 by SmOke_N 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.
Uten Posted June 15, 2006 Posted June 15, 2006 (edited) I always (most of the time ) do a While 1 $msg = GetGuiMsg() ; select switch or if if $msg = 0 then sleep(250) ; or as long as I dare, nothing to do anyway WEnd But as @SmoKe_N pointed out you don't need the GuiGetMsg when only using hotkeys. Edited June 15, 2006 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
w0uter Posted June 15, 2006 Posted June 15, 2006 he just wants this. dont confuse him HotKeySet("{F11}", "hello") While 1 Sleep(10) Wend Func hello() Send("Hello{Enter}") EndFunc My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
Moderators SmOke_N Posted June 15, 2006 Moderators Posted June 15, 2006 and it's useless if using GUIOnEventMode. That depends on 2 things, if 1, you actually have a reason for using Opt('GUIOnEventMode', 1) (like using a GUI) and 2, if you don't mind a Sleep(250) in Uten's example every time (which I agree is a waiste in that aspect), becuase with Opt('GUIOnEventMode', 1), then GUIGetMsg() returns 0 every time (thus the Sleep(250)). 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.
Uten Posted June 15, 2006 Posted June 15, 2006 Either way you need the loop and this script sample will probably grove. So why not learn "good" habits? Sleep as long as you dare (to off load your system) but not to much either because you will miss something important. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
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