18 posts in this topic
How do I setup a Hotkey without using so much of the CPU. There must be a better way.
HotKey Patient History.au3
Im looking to measure cpu usage thats free, and measure cpu usage of a program.
My goal is to turn intel speed step off under light cpu load.
I think I can do that, if I can find the cpu usage.
I have been using a script at work for the last 6 months or so. It gets some information from the window title and keeps it in its memory for retrieval.
currently I am running an infinite loop to look for the window title, the information in the memory is only updated if a few window title is detected.
The trouble with this approach as you can see, is the cpu usage. I was wondering if somehow I can only run this script when a windows change event occurs, otherwise the script stays dormant.
I have no idea how to do that, searched on forum and found some solutions that were years old and did not work for me.
AutoIt SysInfo Clock is a small tool in widget style to show the clock, current CPU usage, CPU speed, memory usage and network activity (tcp, ip and udp). Additionally you can use it as an alarm clock. To stop alarm clock tone press the left LED (mail) or wait 60 seconds.
The current CPU usage code is beta and might be not working for some CPUs!
Move mouse to area below seconds and press rmb to select different color scheme.
Alarm Clock window:
Credits: see scroller (select About).
Special thanks to trancexx for helping me to read out current CPU speed using the WinAPI stuff, AndyG for troubleshooting performance counter issue, czardas for composing "Für Elise" and Ascend4nt for the support!
Download source code + compiled version: Click Me (previous downloads: 1386)
(Please don't use any download manager!)
Compiled version only: MediaFire.com or 4Shared.com
Coded on Win7 x64 using Aero / Win8.1 x64 and AutoIt v220.127.116.11.
This project is discontinued!
v0.9.5.0 build 2013-06-14: initial release
v0.9.6.0 build 2013-06-15: added _WinAPI_CreateRoundRectRgn() to fix transparency issue on non Aero desktops, small internal modifications and added check for whether performance counters are enabled
v0.9.6.5 build 2013-06-15: fixed a bug when "Reset Windows Position" was selected twice and color of scroller will fit to clock color schema
v0.9.8.0 build 2013-06-20: added little music to About part -> many thanks to czardas for mus++ and arranging "Für Elise", added date to clock, replaced CPU usage code -> thanks Ascend4nt
v0.9.9.0 build 2013-06-21: added 2 more color schemas (mint and purple), added network traffic LED, compiled exe now included in archive
v0.9.9.0 build 2013-06-22: forgot to increase a variable in ini section
v0.9.9.0 build 2013-06-24: found also missing modification in context menue after adding two more color schemas
v0.9.9.0 build 2013-06-26: Ops, forgot to change also radio item proper check in clock color schema sub menu
v0.9.9.1 build 2013-06-27: added option to select whether SysInfo Clock should start at windows startup
v0.9.9.2 build 2013-07-01: added yellow-red mark to the small info indicators and additional info when hovering about the small indicators, small internal changes
v0.9.9.5 build 2013-07-05: added features: singleton, update check, visit web site, bring GUI to front and fixed some smaller bugs + some internal changes
v0.9.9.6 build 2013-07-11: added alarm clock feature
v0.9.9.7 build 2014-06-23: adapted code to run on AutoIt version 18.104.22.168
v0.9.9.7 build 2014-08-27: some internal "cosmetic" changes -> this project is discontinued!
this is a part from my script
#include <Misc.au3> $dll = DllOpen("user32.dll") While 1 If _IsPressed("31", $dll) Then one() If _IsPressed("32", $dll) Then two() WEnd Func one() MsgBox(0, "", "1") While _IsPressed("31") or _IsPressed("61") Sleep(1) WEnd EndFunc Func two() MsgBox(0,"", "2") While _IsPressed("32") or _IsPressed("62") Sleep(1) WEnd EndFunc it is working fine but it takes 30 % of the CPU usage and it is a small simple script
when i put sleep(100) in the while loop the CPU is 1%
i think that this is a good solution but not for my case cuz the rest of my script really depends on time and 100 msec will matter
can i reduce the CPU usage without using sleep ?