Skip to content

Commit 1e0dbec

Browse files
committed
Update flashpresence.py
agora verifica por 'flashplayer_debug.exe' e tbm pega versão do executavel
1 parent b7f3c02 commit 1e0dbec

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

flashpresence.py

+47-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import psutil
22
from pypresence import Presence
33
import time
4-
4+
import win32api
55

66
def checkprocess(targetname):
77
for proc in psutil.process_iter():
@@ -12,6 +12,43 @@ def checkprocess(targetname):
1212
psutil.ZombieProcess):
1313
pass
1414
return False
15+
def get_file_properties(fname):
16+
"""
17+
Read all properties of the given file return them as a dictionary.
18+
"""
19+
prop_names = ('Comments', 'InternalName', 'ProductName',
20+
'CompanyName', 'LegalCopyright', 'ProductVersion',
21+
'FileDescription', 'LegalTrademarks', 'PrivateBuild',
22+
'FileVersion', 'OriginalFilename', 'SpecialBuild')
23+
24+
props = {'FixedFileInfo': None, 'StringFileInfo': None, 'FileVersion': None}
25+
26+
# try:
27+
# backslash as parm returns dictionary of numeric info corresponding to VS_FIXEDFILEINFO struc
28+
fixed_info = win32api.GetFileVersionInfo(fname, '\\')
29+
props['FixedFileInfo'] = fixed_info
30+
props['FileVersion'] = "%d.%d.%d.%d" % (fixed_info['FileVersionMS'] / 65536,
31+
fixed_info['FileVersionMS'] % 65536,
32+
fixed_info['FileVersionLS'] / 65536,
33+
fixed_info['FileVersionLS'] % 65536)
34+
35+
# \VarFileInfo\Translation returns list of available (language, codepage)
36+
# pairs that can be used to retreive string info. We are using only the first pair.
37+
lang, codepage = win32api.GetFileVersionInfo(fname, '\\VarFileInfo\\Translation')[0]
38+
39+
# any other must be of the form \StringfileInfo\%04X%04X\parm_name, middle
40+
# two are language/codepage pair returned from above
41+
42+
str_info = {}
43+
for propName in prop_names:
44+
str_info_path = u'\\StringFileInfo\\%04X%04X\\%s' % (lang, codepage, propName)
45+
str_info[propName] = win32api.GetFileVersionInfo(fname, str_info_path)
46+
47+
props['StringFileInfo'] = str_info
48+
# except:
49+
# pass
50+
51+
return props
1552

1653
if __name__ == "__main__":
1754

@@ -24,14 +61,17 @@ def checkprocess(targetname):
2461

2562
client_id = '1013717821122936873' # Fake ID, put your real one here
2663
RPC = Presence(client_id)
27-
fpd = "flashplayer_32_sa_debug.exe"
64+
fpd = "flashplayer_debug.exe"
2865
fp = "flashplayer.exe"
2966
while True: # The presence will stay on as long as the program is running
3067
time.sleep(4)
3168

3269
if checkprocess(fpd) == True:
3370
print("Found Debug Build")
3471
TYPE = "Debug"
72+
props = get_file_properties(fpd)
73+
#VERSION = props['StringFileInfo']['ProductVersion']
74+
VERSION = props['FileVersion']
3575
if DebugRunning == False and RPCRun == False:
3676
RPC.connect()
3777
RPCRun = True
@@ -48,6 +88,9 @@ def checkprocess(targetname):
4888
if checkprocess(fp) == True:
4989
print("Found Standalone Build")
5090
TYPE = "Standard"
91+
props = get_file_properties(fp)
92+
#VERSION = props['StringFileInfo']['ProductVersion']
93+
VERSION = props['FileVersion']
5194
if StandaloneRunning == False and RPCRun == False:
5295
RPC.connect()
5396
RPCRun = True
@@ -62,6 +105,7 @@ def checkprocess(targetname):
62105
RPC.close()
63106

64107
if DebugRunning == True and StandaloneRunning == True:
65-
TYPE = "Multiple Running"
108+
TYPE = "Multiple Running"
109+
VERSION = "Multiple Running"
66110
if RPCRun == True:
67111
RPC.update(state="Idle", details="Not Quite Dead Yet.", large_image="afp32_big", large_text=f"Version {VERSION} ({TYPE})")

0 commit comments

Comments
 (0)