展开全部

我觉得不是时间戳(或者说,不是通常意义下的时间戳)。e69da5e887aa3231313335323631343130323136353331333335303437

这里的event可能是KeyboardEvent或 MouseEvent(视钩子类型而定)。而这两个类又都是HookEvent的子类。

HookEvent有如下几个成员:

Message: Keyboard or mouse event message

Time: Seconds since the epoch when the even current

Window: Window handle of the foreground window at the time of the event

WindowName: Name of the foreground window at the time of the event

这里,对Time成员的描述是:

Seconds since the epoch when the even current

这里的epoch很有意思。

一般上,我们在使用Python中的time模块,或者C标准库中的time.h时,认为epoch是(摘自Python2.7 time模块的文档):

The epoch is the point where the time starts. On January 1st of that year, at 0 hours, the “time since the epoch” is zero. For Unix, the epoch is 1970.

但是,这里的epoch却不是。看下面一段改编自pyhook官网的小例子:# -*- coding: utf-8 -*-

import pythoncom, pyHook

import win32api

import time

def OnKeyboardEvent(event):

print event.Time

# Return the time in seconds since the epoch as a floating point number.

#

# The epoch is the point where the time starts. On January 1st of that year,

# at 0 hours, the “time since the epoch” is zero. For Unix, the epoch is 1970.

print time.time()

# Returns the number of milliseconds since windows started

print win32api.GetTickCount()

print 'MessageName:',event.MessageName

print 'Message:',event.Message

print 'Time:', time.ctime(time.time())

print 'Window:',event.Window

print 'WindowName:',event.WindowName

print 'Ascii:', event.Ascii, chr(event.Ascii)

print 'Key:', event.Key

print 'KeyID:', event.KeyID

print 'ScanCode:', event.ScanCode

print 'Extended:', event.Extended

print 'Injected:', event.Injected

print 'Alt', event.Alt

print 'Transition', event.Transition

print '---'

# return True to pass the event to other handlers

return True

# create a hook manager

hm = pyHook.HookManager()

# watch for all keyboard events

hm.KeyDown = OnKeyboardEvent

# set the hook

hm.HookKeyboard()

# wait forever

pythoncom.PumpMessages()

其中:

print event.Time

print time.time()

print win32api.GetTickCount()

我发现,event.Time和GetTickCount返回的值是一样的。而GetTickCount的含义是:

Returns the number of milliseconds since windows started

也就是,从本次开机到GetTickCount调用时经过的毫秒数。

所以,不能依赖event.Time来获取时间了。而time模块就派上用场了。比如:

print 'Time:', time.ctime(time.time())

就可以打印消息发生时的年月日时分秒了。

python pyhook_python使用pyHook.HookManager()返回来的event中,event.Time怎么转换成为datetime形式?...相关推荐

  1. python中将HTTP头部中的GMT时间转换成datetime时间格式

    原文: https://blog.csdn.net/zoulonglong/article/details/80585716 需求背景:目前在做接口的自动化测试平台,由于接口用例执行后返回的结果中的时 ...

  2. 【Python】监测鼠标各种事件(左键/中键/右键是否点下)

    目录 0. 前言 1. 安装PyHook3 2. 检测鼠标左键/中键/右键是否按下 3. PyHook3详细讲解 0. 前言 最近在写一个脚本,需要用到监测用户是否点击鼠标中键,然后触发相应的功能.这 ...

  3. python三引号 内部变量_python在三引号中使用变量

    1.定义和运算: 变量名 = 值 定义变量举例: # 定义一个变量 myCar = "比亚迪F0" # 输出一个变量 print(myCar) 变量之间的简单运算举例: price ...

  4. python watchdog 同时检测到多个事件_python中watchdog文件监控与检测上传功能

    引言 上一篇介绍完了观察者模式的原理,本篇想就此再介绍一个小应用,虽然我也就玩了一下午,是当时看observer正好找到的,以及还有Django-observer,但Django很久没用了,所以提下这 ...

  5. python自带的sum()函数和numpy库中的sum()函数的区别

    在学习<机器学习实战>一书的第十章时,对 return np.sqrt(sum(np.power(vecA - vecB, 2))) 这样一条语句输出的结果老是不对,明明想要输出的是对两个 ...

  6. python批量读取文件名_python - 从路径中提取文件名,无论os / path形式如何

    python - 从路径中提取文件名,无论os / path形式如何 无论操作系统或路径格式是什么,我可以使用哪个Python库从路径中提取文件名? 例如,我想要所有这些路径返回c: a/b/c/ a ...

  7. bat脚本中获取上级目录_使用Python写一个可以监控Tomcat 运行的脚本,并且把.py文件转换成.exe文件...

    使用Python写一个可以监控Tomcat 运行的脚本,并且把.py文件转换成.exe文件 文章来源与博主本人的CSDN博客,博客地址:https://blog.csdn.net/weixin_435 ...

  8. java执行python脚本_使用Runtime.getRuntime().exec()在java中调用python脚本

    举例有一个Python脚本叫test.py,现在想要在Java里调用这个脚本.假定这个test.py里面使用了拓展的包,使得pythoninterpreter之类内嵌的编译器无法使用,那么只能采用ja ...

  9. python 数据框缺失值_Python:处理数据框中的缺失值

    python 数据框缺失值 介绍 (Introduction) In the last article we went through on how to find the missing value ...

  10. 手机上python编程工具3和3h有区别吗_Python3.5内置模块之time与datetime模块用法实例分析...

    本文实例讲述了Python3.5内置模块之time与datetime模块用法.分享给大家供大家参考,具体如下: 1.模块的分类 a.标准库(Python自带):sys.os模块 b.开源模块(第三方模 ...

最新文章

  1. python怎么导入时间-python初步学习-import和datetime模块
  2. 【计算机网络】网络层 : 网络层设备 ( 路由器 | 输入端口处理 | 输出端口处理 | 物理层、数据链路层、网络层 设备对比 | 路由表 与 路由转发 )
  3. java基础-Eclipse开发工具介绍
  4. C++与C#混合编程
  5. 是否应该饮用酵素和自制的葡萄酒
  6. 2020非全日计算机博士,在职攻读博士是不是非常难,免考在职博士和非全日博士有什么不同...
  7. C++之运算符重载(前置++和后置++)
  8. 每周学算法/读英文/知识点心得分享 3.4 - 3.8
  9. HashMap学习之transient
  10. VS2012下基于Glut OpenGL GL_POLYGON_STIPPLE示例程序:
  11. Ros代码迁移,编译头文件报错解决办法
  12. POJ 2686 Traveling by Stagecoach 壮压DP
  13. cpu型号怎么看服务器,看不懂CPU?学会看CPU只要五分钟
  14. 【pytorch图像分类】AlexNet网络结构
  15. c51单片机扩展64K的RAM
  16. Maya Xgen交互式毛发的导出导入,用于其他项目
  17. 网站服务器拥挤如何进去,教你一招:有效解决网络拥挤的办法!
  18. 低代码里程碑版—JeecgBoot 3.4.3 版本发布,低代码功能专项升级
  19. 区间类动态规划(dp)
  20. windows7 专业版安装中文语言包

热门文章

  1. 学会查找问题的源头:网吧系统强制下载QQ浏览器
  2. 搞懂PDCA循环,学会闭环思维
  3. BOOT.BIN文件
  4. js控制Windows Media Player
  5. python 视频教程推荐_求各位大佬推荐Python学习视频教程?
  6. 新手入门C语言易错点
  7. 小米平板4twrp一键刷入工具_不要浪费小米10的双扬声器!杜比全景音刷入教程分享...
  8. Java实现动态切换IP的方法(一)
  9. 微信群聊在哪个服务器,微信怎么找附近的群聊?微信群不见了怎么找?
  10. 本地KMS虚拟服务器,搭建kms本地服务器