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 ...
随机推荐
- Kali Linux的介绍
Kali Linux是什么? Kali Linux是一个渗透测试平台兼安全审计平台,它集成了多款漏洞检测.目标识别和漏洞利用工具. Kali Linux是专门用于渗透测试的Linux操作系统:基于De ...
- 2017-12-04HTML布局_div布局
HTML布局_div布局 <!doctpye> <html> <head> <meta charset = 'utf-8'> <title> ...
- 关于加减和es6
console.log(1+ "2"+"2"); //对于加法来说,如果只有一个操作数是字符串,则将另一个操作数也转换为字符串,然后将两者拼接,为122 c ...
- Errors reported here must be corrected before the service can be started
场景: 安装.配置Apache24时候,最后会给出提示,如图:Errors reported here must be corrected before the service can be star ...
- Python中深拷贝与浅拷贝的区别
转自:http://blog.csdn.net/u014745194/article/details/70271868 定义: 在Python中对象的赋值其实就是对象的引用.当创建一个对象,把它赋值给 ...
- ProcessBar 与SeekBar进度条
1.进度条关键属性 2.进度条的常用方法 progress = (ProgressBar) findViewById(R.id.horiz); (1)获取第一进度条:progress.getProgr ...
- Farseer.net轻量级开源框架 中级篇:自定义配置文件
导航 目 录:Farseer.net轻量级开源框架 目录 上一篇:Farseer.net轻量级开源框架 中级篇: 数据绑定 下一篇:Farseer.net轻量级开源框架 中级篇: 动态数据库访问 ...
- Dreamweaver启动出错--Designer.xml错误
Designer.xml错误导致Dreamweaver CS4无法启动 xml parsing fatal error:Invalid document structure,line:1, file: ...
- Vue指令2:v-bind
v-bind 指令可以更新 HTML 属性: <a v-bind:href="url">...</a> 在这里 href 是参数,告知 v-bind 指令将 ...
- BZOJ1996: [Hnoi2010]chorus 合唱队 (DP)
就是想水一发 #include <stdio.h> #include <algorithm> #include <iostream> using namespace ...