gpt4 book ai didi

python - pyHook event.Time 返回不规则时间戳

转载 作者:太空宇宙 更新时间:2023-11-04 00:16:23 27 4
gpt4 key购买 nike

我一直在用 Python 编写一个基本的键盘记录器。在检查我的日志时,我发现我使用 event.Time 记录的时间戳不是 Unix 时间戳。它是什么类型的时间戳,如何将其转换为可读格式?

import pyHook, pythoncom, sys, logging
advancedLog="path\\advanced_log.txt"

def OnKeyboardEvent(event):

logging.basicConfig(filename=advancedLog, level=logging.DEBUG, format='%(message)s')

logging.log(10,chr(event.Ascii))
logging.log(10,'MessageName: {}'.format(event.MessageName))
logging.log(10,'Message: {}'.format(event.Message))

logging.log(10,'Time: {}'.format(event.Time))

logging.log(10,'Window: {}'.format(event.Window))
logging.log(10,'WindowName: {}'.format(event.WindowName))
logging.log(10,'Ascii: {}'.format(event.Ascii))
logging.log(10,'Key: {}'.format(event.Key))
logging.log(10,'KeyID: {}'.format(event.KeyID))
logging.log(10,'--------------')

return True


hookManager = pyHook.HookManager()
hookManager.KeyDown = OnKeyboardEvent
hookManager.HookKeyboard()
pythoncom.PumpMessages()

我收到的输出:

Time: 561750343

最佳答案

这不是实际的时间戳。它是“自上次启动以来的毫秒数”。如果你想保存当前时间,你可以使用 time图书馆。

It's not "number of seconds since the epoch". It comes straight from the "time" member of the Win32 EVENTMSG struct, which is in units of "milliseconds since last boot".

来源: Python.org

关于python - pyHook event.Time 返回不规则时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50805474/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com