<html>
<head>
<title>Python Process Lister</title>
<HTA:APPLICATION
ID="processlister"
APPLICATIONNAME="Python Process Lister"
SCROLL="auto"
SCROLLFLAT = "yes"
SINGLEINSTANCE="yes"
>
<style type="text/css">
body {
background-color: #ababcd;
font-family: Verdana
font-size: 0.9 em;
color: #fff;
}
a:link {text-decoration: none; color:#343456}
a:visited {text-decoration: none;color:#343456}
a:active {text-decoration: none; color:#343456}
a:hover {text-decoration: underline; color:452200;}
</style>
</head>
<body onLoad="Initialisation()">
<center><h2>Liste des Process</h2></center>
<span id = "ProcessList"></span>
<!-- Script Python -->
<SCRIPT LANGUAGE="Python">
from win32com.client import GetObject
import win32gui
doc = document.All
ChaineConnexion = r"WinMgMts:\\%s\%s"
listProcess = []
process = None
def displayProc(args):
proc = None
numproc = int(args)
rep = window.confirm("Voulez-vous terminer le processus %s ?"%args )
if rep:
for p in process:
proc = p
if int(p.Handle) == numproc:
alert(u"Le processus %d va être supprimé"%numproc)
break
proc.Terminate
def getAllObjects(serveur = ".", espaceDenom = "root\cimv2", classe = "Win32_Process"):
c = GetObject(ChaineConnexion%(serveur,espaceDenom))
objects = c.ExecQuery(r"select * from %s"%classe)
return objects
def Initialisation():
win32gui.MessageBox(0, " Hello From Python", "Message d'Invite", 0)
RefreshList()
iTimerID = window.setInterval("RefreshList()", 10000)
def RefreshList():
global process
process = getAllObjects()
result = "<table>"
for processus in process:
result += """<tr><td align="right">%4d</td>
<td style="padding-left:15px;"><a class="maya" href="#" onClick="displayProc(%d)">%s</a></div></td>
<td>%s</td>
</tr>"""%(int(processus.Handle),int(processus.Handle),processus.Name,processus.CommandLine)
result += "</table>"
doc.ProcessList.InnerHTML = result
</SCRIPT>
</body>
</html>
Thursday, July 19, 2007
HTA - Python : Gestionnaire de Tâches
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment