Reading the APM value from windows registry

Posts: 2
Hi, complete and total coding newbie here, trying to learn Python. I'm guessing this is the most appropriate forum for something like this.

As a little personal project of my own, I'm attempting to make a program that reads the APM value from the windows registry and display it in a little window, kinda like the existing plugin for sc2gears (which as far as I know also uses this method)

My problem though, is once I've finally managed to get this value from the registry, it's nothing like the actual current apm in SC2. The value in the registry could be 700+, while the number from the SC2 plugin is 276, and the actual ingame APM is 122.

Could someone tell me what's going on? I assume I probably have to divide the registry value by a certain something (1.38?) to convert to BlizzardTime™, but 1.38 doesn't make the registry value come close to the actual ingame APM or the Sc2Gears APM, and the regkey probably doesn't update as fast as the ingame APM display anyway.

Anyway, to cut the ramble short, I was just wondering if there was any documentation on this that I haven't seen, or something like that. My google-fu has only brought me to:
which doesnt really explain my weird registry key values.
This is how I am reading the APM btw, looping every second:

from _winreg import *
key = OpenKey(HKEY_CURRENT_USER, r'Software\Razer\Starcraft2', 0, KEY_ALL_ACCESS)
StartModule = QueryValueEx(key, "StartModule")[0]
#Startmodule is 1 when game is loading or in game

APMValue = [int(QueryValueEx(key, "APMValue")[0])]
# APMValue should be APM value but clearly isnt
Edited by Merc on 8/10/2013 7:51 AM PDT
Reply Quote
Posts: 28
You have to substract 5 from the first digit, 4 from the 2nd digit etc. If it "underflows" (e.g. negative), you have to add 10 to it.
Reply Quote
Posts: 2
Thank you!

I think I figured out how to decode it. Probably not "pythonic" enough but it works and as a newbie I'm thrilled enough by that. Here's what I did if anyone's interested (or would like to tell me how to do it better):

x = 5
decode = []
for i in range (0, len(str(APM))):
num = int(str(APM)[i])-x
if (num < 0):
num += 10
x -= 1
NewAPM = ''.join(str(e) for e in decode)
Edited by Merc on 8/12/2013 8:36 AM PDT
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Explain (256 characters max)