dota监測
执行环境:win7 32位.
python版本号:3.4.1
因为用到了一些win32api,这些并不是python标准库自带的,所以你须要先去下载pywin32模块.去http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/找到相应你的系统及python版本号的包,一路next安装就可以.

#coding=gbk
import win32com.client
import time
import os def IsExsit(processName):
WMI = win32com.client.GetObject('winmgmts:')
processCodeCov = WMI.ExecQuery(
'select * from Win32_Process where Name="%s"' % processName)
if len(processCodeCov) > 0:
return 1
else:
return 0 oldStatus = 0
newStatus = 0 #0代表进程不存在.1代表存在
totalTime = 0 def ShutDown(fp):
cmd = "cmd.exe /k shutdown -s -t 0"
structTime = time.localtime(time.time())
currentTime = time.strftime('%Y-%m-%d %H:%M:%S', structTime)
info = "关机:" + currentTime + "\n"
fp.write(info)
os.system(cmd) def Handle(processName,fp):
global oldStatus, newStatus,totalTime
newStatus = IsExsit(processName)
structTime = time.localtime(time.time())
currentTime = time.strftime('%Y-%m-%d %H:%M:%S', structTime)
print(oldStatus, newStatus,currentTime) #更新进程执行总时间.
if newStatus == 1:
totalTime += 60
if totalTime >= 60*60*3: #超过3小时则关机
ShutDown(fp) #在进程状态改变时记录到文件里
if (oldStatus != newStatus):
oldStatus = newStatus
structTime = time.localtime(time.time())
strTime = time.strftime('%Y-%m-%d %H:%M:%S', structTime)
if newStatus:
strTmp = processName + "开启"
else:
strTmp = processName + "关闭"
info = strTime + "********" + strTmp + "\n"
fp.write(info)
#fp.close()
else: #
pass if __name__ == '__main__':
fp = open("records.txt", "a+")
structTime = time.localtime(time.time())
currentTime = time.strftime('%Y-%m-%d %H:%M:%S', structTime)
info = "開始监控:" + currentTime + "\n"
fp.write(info)
while True:
Handle('war3.exe',fp)
#5分钟检測一次
time.sleep(60)

dota监測的更多相关文章
- Atitit.软件仪表盘(2)--vm子系统--资源占用监測
Atitit.软件仪表盘(2)--vm子系统--资源占用监測 1. Jvisualvm.exe 2. jprofile 3. Heap //permgen monitor 作者::老哇的爪子At ...
- 家居环境监測系统设计(PC上位机版)(手机APP版待定)
下面是我的毕业设计:家居环境监測系统设计(PC上位机临时版.手机app版待定).本系统採用STC12C5A60S2单片机.结合传感器.分别对空气湿度.空气温度.气压.海拔.进水温度.出水温度.光照强度 ...
- 基于Unity3D云人脸监測技术
笔者介绍:姜雪伟,IT公司技术合伙人,IT高级讲师.CSDN社区专家,特邀编辑,畅销书作者,国家专利发明人;已出版书籍:<手把手教你架构3D游戏引擎>电子工业出版社和<Unity3D ...
- Key-Value Observing (键值监測)
Key-Value Observing (键值监測) 简单介绍 KVO是一套当目标对象的属性值改变时观察者对象能够接受到通知的机制.必须先理解KVC才干更好的理解KVO,前者是后者的实现基础. 这种通 ...
- 网络状态监測之 Reachability的使用
先下载 Reachability开源库地址: (一)git hub: https://github.com/tonymillion/Reachability (二)我自己改动的:http://down ...
- Atitit.软件仪表盘(4)--db数据库子系统-监測
Atitit.软件仪表盘(4)--db数据库子系统-监測 连接数::: 死锁表列表:死锁基础列表(近期几条记录,时间,sql等) 3.对server进行监控.获取CUP.I/O使用情况 4.对数据 ...
- Android实践--监測网络状态
Android 监測网络状态 我们在使用Android手机时候,一些APP须要网络环境才干执行,所以手机须要可用的网络,无论是2G.3G或者WIFI.甚至有一些比較耗流量的APP仅仅能在WI ...
- Android时时监測手机的旋转角度 依据旋转角度确定在什么角度载入竖屏布局 在什么时候载入横屏布局
一.场景描写叙述: 最近开发中遇到个问题,就是我们在做横竖屏切换的功能时.横竖屏布局是操作系统去感知的,作为开发员没法确定Activity在什么时候载入横屏布局,在什么时候载入竖屏布局.因此为了找到载 ...
- Atitit.软件仪表盘(7)--温度监測子系统--电脑重要部件温度与监控and警报
Atitit.软件仪表盘(7)--温度监測子系统--电脑重要部件温度与监控and警报 Cpu温度.风扇转速 主板温度 显卡温度 硬盘温度 电池温度 鲁大师 硬盘温度 Cpu温度 core temp ...
随机推荐
- LN : leetcode 3 Longest Substring Without Repeating Characters
lc 3 Longest Substring Without Repeating Characters 3 Longest Substring Without Repeating Characters ...
- outlook 2016 接收发送无法及时收下邮件,如何更改接收时间?
1. 单击“文件” > “选项” > “高级” > “发送和接收”,单击”发送/接收“ 2. 组“所有账户”的设置 > 打勾“安排自动发送/接收的时间间隔为(V)” 1 分钟 ...
- 【译】x86程序员手册31- 第9章 异常和中断
Chapter 9 Exceptions and Interrupts 第9章 异常和中断 Interrupts and exceptions are special kinds of control ...
- 安卓app测试之启动时间和电量监控
一.启动时间监控 通过adb命令获取 adb shell am start -W /<packageName> /<activityName> 案例: adb shell am ...
- 让元素div消失在视野中
让元素div消失在视野中1.position:absolute/relative/fixed + 方位 top/bottom/left/right: -9999px2.display:none3.vi ...
- Error LNK2019: unresolved external symbol C++模板类声明与定义链接错误问题
编译器在编译模板时,并不会生成代码,只有遇到实例化的时候才会生成代码.因此,当我们只引用模板声明文件的时候,在实例化的对象时候,模板的定义问文件是不可见的,于是出现链接错误.例如: //A.h #pr ...
- 安迪的第一个字典(Andy's First Dictionary,Uva 10815)
输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出.单 词不区分大小写. 样例输入: Adventures in Disneyland Two blondes were goin ...
- 利用CMD 創建新文件的機種方法
用 CMD 創建新文件 説明一下: 是在Windows的 CMD命令行模式下,或者在PowerShell命令行模式下創建新文件的機種方法. 創建空文件 cd.>a.txt cd.表示改变当前目录 ...
- ConcurrentHashMap笔记
概览: 内部存储的数据结构为:数组+链表+红黑树,图示: 重要的属性(内部类): //存放元素的数组 transient volatile Node<K,V>[] table; //数组中 ...
- 【模板】Lca倍增法
Codevs 1036 商务旅行 #include<cstdio> #include<cmath> #include<algorithm> using namesp ...