Alex Hall wrote:
> Regarding question 2, about only receiving one number for two cores, I
> have a counter in the loop which gets incremented each time the loop
> runs. This counter always ends up at 1, not 2, so it is only
> incremented once. When I first started this last week I did put any
> returns into a list, but the list was always just one element long.
> This seems to tell me that I am only getting one number, but I should
> be getting two. Is there a syntax thing that I am missing or confused
> about, or is wmi refusing me the information about my other core? Is
> there a different class I should be using to get the load per core?

The number you are getting is the average load for the physical
processor, which includes all of the cores and hyperthreaded modules. 
If you have a dual core machine, you'll find that c.NumberOfCores is 2. 
Check this MSDN article:
    http://msdn.microsoft.com/en-us/library/aa394317.aspx

It describes the WMI Win32_PerfRawData_PerfOS_Processor class, which
includes information per logical processor, and describes how to figure
that out from the Win32_Processor information.


> As far as pyHook, it sounds like it is not going to work too well. Are
> you saying it could be the cause of the wmi troubles?

Well, you didn't say what the actual error was until just a few minutes
ago, so I didn't know the troubles were in WMI.  I assumed you were
having troubles reaching the "Say" class or doing a "print".  It's
possible that some of the processes you are hooking do not have
permission to access WMI.


> If so, is there another library I should use instead? I want this to
> be a global thing, so no matter where in Windows you are, you need
> only press a hotkey to hear the status of your hardware, like a
> sighted person need only glance at their resource monitor
> gadget/sidebar app. For that reason I avoided pyGame and wx since, as
> I understand it, they only monitor keypresses in their windows, not
> through the entire system.

In that case, why use a hook at all?  Why not just have a single script
that fetches and says the resource usage and then exits?  You could have
that tied to an Explorer hotkey, just like you do now.  Windows hooks
are a very heavyweight technology.  Your hook code gets executed for
every keystroke and every mouse motion.


> Finally, when you say "calling pythoncom.CoInitialize() in every
> callback", what do you mean by 'callback'?

Your OnKeyDown and OnKeyUp functions are being called in response to
external events.  You pass those functions to pyHooks, and it "calls you
back" when something happens.  Functions that you provide for someone
else to call are called "callbacks".

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to