qq农场吧 关注:92,782贴子:3,893,980
  • 1回复贴,共1

【农场交流 20150728 】算是福利吧python的。给小号多的菜友

只看楼主收藏回复

# coding=utf-8
__author__ = 'Lilyu'
__END__ = "FALSE"
from pywinauto import Application
import os
import time
import thread
import threading
class timer(threading.Thread):
def __init__(self, num, interval):
threading.Thread.__init__(self)
self.thread_num = num
self.interval = interval
self.thread_stop = False
def run(self):
while True:
time.sleep(0.25)
os.system("python D:\Users\Lilyu\PycharmProjects\untitled3\CloseGG.py")
global __END__
if __END__ == 'TRUE':
break
def stop(self):
self.thread_stop = True
# ####################根据用户名登录QQ农场##############################################
def LoginQQNC(user):
app = Application().start("D:\QQNC\QQHelper_1398.exe")
while True:
try:
about_dlg = app.window_(title_re=u"登录")
about_dlg.Edit1.TypeKeys(user)
break
except:
continue
d2 = app.window_(title_re=u"登录")
# os.system("python D:\Users\Lilyu\PycharmProjects\untitled3\CloseGG.py")
time.sleep(0.5)
d2.SetFocus()
# os.system("python D:\Users\Lilyu\PycharmProjects\untitled3\CloseGG.py")
time.sleep(0.5)
d2.TsButton2.Click()
# #####################根据用户名登录QQ农场#############################################
# #####################登录QQ农场#############################################
def LoginQQNCAll():
# thread.start_new_thread(KillAll())
users = ["756xxxx76", "45xxxxx60", "12xxxxx11", "12xxxxx73", "10xxxxx23", "25xxxxx73", "51xxxxx86", "45xxxxx84"]
for user in users:
LoginQQNC(user)
time.sleep(5)
global __END__
__END__ = 'TRUE'
thread.exit_thread()
# os.system("python D:\Users\Lilyu\PycharmProjects\untitled3\CloseGG.py")
def CloseNCInfo():
os.system("python D:\Users\Lilyu\PycharmProjects\untitled3\CloseNC.py")
# ####################主函数#################################################
if __name__ == "__main__":
# CloseNCInfo()
thread1 = timer(1, 1)
thread1.start()
LoginQQNCAll()
time.sleep(5)
thread1.stop()
CloseGG.py
__author__ = 'Lilyu'
# coding=utf-8
import time
import win32api
import win32con
import win32pdh
import unicodedata
# ***********************************************************************
# ***********************************************************************
def GetAllProcesses():
object = "Process"
items, instances = win32pdh.EnumObjectItems(None, None, object, win32pdh.PERF_DETAIL_WIZARD)
return instances
# ***********************************************************************
# ***********************************************************************
# ***********************************************************************
def GetProcessID(name):
try:
object = "Process"
items, instances = win32pdh.EnumObjectItems(None, None, object, win32pdh.PERF_DETAIL_WIZARD)
val = None
if name in instances:
hq = win32pdh.OpenQuery()
hcs = []
item = "ID Process"
path = win32pdh.MakeCounterPath((None, object, name, None, 0, item))
hcs.append(win32pdh.AddCounter(hq, path))
win32pdh.CollectQueryData(hq)
time.sleep(0.01)
win32pdh.CollectQueryData(hq)
for hc in hcs:
type, val = win32pdh.GetFormattedCounterValue(hc, win32pdh.PDH_FMT_LONG)
win32pdh.RemoveCounter(hc)
win32pdh.CloseQuery(hq)
return val # ***********************************************************************
except:
return None
# ***********************************************************************
# ***********************************************************************
def Kill_Process_pid(pid):
handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, pid) # get process handle
win32api.TerminateProcess(handle, 0) # kill by handle
win32api.CloseHandle(handle) # close api
# ***********************************************************************
# ***********************************************************************
# ***********************************************************************
def Kill_Process(name):
pid = GetProcessID(name)
print pid
if pid:
print "exist"
Kill_Process_pid(pid)
else:
print "not this proccess"
# ***********************************************************************
def killUtmp(a):
for name in a:
line = unicodedata.normalize('NFKD', name).encode('ascii', 'ignore')
if '.uTMP' in line:
Kill_Process(line)
# ***********************************************************************
# ***********************************************************************
if __name__ == "__main__":
time.sleep(1)
a = GetAllProcesses()
killUtmp(a)
process = 'firefox' # process name
Kill_Process(process)
process = '360chrome'
Kill_Process(process)


IP属地:安徽1楼2015-07-28 17:51回复
    你没看不到


    来自Android客户端2楼2015-07-28 18:09
    回复