struct module usage

BW Glitch bwglitch at
Mon Dec 1 00:50:55 CET 2003


I'm trying to send a message from a Python script to a Scite window via
win32gui.SendMessage() I'm trying to pack the commands using the struct
module. However, I can't figure out why Scite isn't responding as I
expect. The SendMessage is returning 0.

I've searched Google and haven't found anything that would help me.
There was a discussion about this same thing about 2 years ago and the
poster solved the problem using calldll. I checked last night and
calldll is available only for Python 2.1, while I'm using 2.3.

Here's a snippet from the code:

import win32api, win32gui, win32con
import sys
import struct

SDI = win32api.RegisterWindowMessage("SciTEDirectorInterface");
w = win32gui.GetWindow(win32gui.GetDesktopWindow(),win32con.GW_CHILD)

while w:
     res = 0;
     res = win32gui.SendMessageTimeout(w, SDI, 0, 0,
win32con.SMTO_NORMAL, 1000)
     if res[1] != SDI:
         w = win32gui.GetWindow(w, win32con.GW_HWNDNEXT)
n = len("goto:20") + 1
s = struct.pack(`n` + "sii", "goto:20,3", 9, 0)

res = win32gui.SendMessage(w, win32con.WM_COPYDATA, s, SDI)

I've tried almost every combination on the struct format.


Andres Rosado
Email: andresr at
ICQ: 66750646
AIM: pantear

We make the standards and we make the rules.
         -- Standards;  The Jam

More information about the Python-list mailing list