Python & Litestep

Lukas Cenovsky xcenovsk at fi.muni.cz
Sun Jun 23 18:17:59 EDT 2002


Here is the function how send to Litestep a Bang Command
from Python script. Maybe someone will find it helpful.

def SendBang(bang, arg = ''):
   import win32gui, array, struct, win32api
   try:
     LMBANGCOMMAND = "II64s256s"
     copyDataStruct = "IIP"
     a = struct.pack(LMBANGCOMMAND, struct.calcsize(LMBANGCOMMAND), 0, bang, arg)
     ar = array.array('c', a)
     msg = ar.buffer_info()
     cds = struct.pack(copyDataStruct, 9420, msg[1], msg[0])
     cdsa = array.array('c', cds)
     cdsb = cdsa.buffer_info()
     ls = win32gui.FindWindow("TApplication", "Litestep");
     if (win32api.SendMessage(ls, 0x004A, 0, cdsb[0]) <> 1):
       return 0
     else:
       return 1
   except:
     return 0

Use it like:
SendBang('!alert', '"I am an alert from Python."')
SendBang('!Amp_PlayPause')

-- 
-- Cendicek




More information about the Python-list mailing list