Saturday, July 28, 2007

Python - HTA : Capturer la position de la Souris

Cet exemple montre comment capturer la position de la souris en Python

Article de référence :
http://msdn2.microsoft.com/en-us/library/ms531073.aspx

<HTML>
<HEAD><TITLE>Report mouse moves in Python</TITLE>

<BODY onmousemove="reportMove()">
<H1>Python catch the Mouse</H1>

<div id="pos"></div>

<SCRIPT LANGUAGE="Python">
d = document.all
def reportMove():
x = window.event.x
y = window.event.y
d.pos.innerHTML = "posx = %d, posy =%d"%(x, y)
</SCRIPT>

</BODY>
</HTML>

Python - HTA : Simple Wizard


Voici comment afficher des pages contenues dans de simples fichiers texte.
Très pratique pour écrire par exemple, des assistants


Fichier tutorhta.txt (servant dans le script tutor.hta)

%pywizard%
%
<h1>Introduction</h1>
D'apr&egrave;s l'article de microsoft :
<a href="http://msdn2.microsoft.com/en-us/library/bb264002.aspx">Getting Your Page's Data into a Bind</a>
%
%
<h2>Chapitre 1</h2>
%
%
<h2>Chapitre 2</h2>
%

fichier tutor.hta

<html>
<head>
<OBJECT ID="Content" WIDTH=0 HEIGHT=0
CLASSID="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME="TextQualifier" VALUE="%">
<PARAM NAME="FieldDelim" VALUE="|">
<PARAM NAME="DataURL" VALUE="tutorhta.txt">
<PARAM NAME="UseHeader" VALUE="true">
</OBJECT>
</head>
<body style="font-family: verdana">

<span style="font-weight: bold; cursor: hand" onclick="goBackward()"><<</span>
Python - HTA
<span style="font-weight: bold; cursor: hand" onclick="goForward()">>></span>
<br>
<span id=Status></span><br>
<div id=TheStory datasrc=#Content datafld="pywizard" dataformatas="HTML"></div>

<SCRIPT language=Python>

doc = document.all
rs = None

def goForward():
global rs
if (rs.absolutePosition != rs.recordCount) :
rs.MoveNext()
else :
rs.MoveFirst()

def goBackward():
global rs
if (rs.absolutePosition > 1) :
rs.MovePrevious()
else :
rs.MoveLast()

def initialize():
global rs
rs=doc.Content.recordset;


window.onload = initialize()

</SCRIPT>
</body>
</html>