A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/322257.html below:

PyWin SendMessage

PyWin SendMessageg.franzkowiak g.franzkowiak at onlinehome.de
Thu Sep 29 10:04:06 EDT 2005
Hello everybody,

I've tryed to use an interprocess communication via
SendMessage on Windows.
Unfortunately, nothing goes on

#########################################################################
#! /usr/bin/env python

import win32api, win32ui, win32con
import struct, array

"""
typedef struct tagCOPYDATASTRUCT {  // cds
    DWORD dwData;
    DWORD cbData;
    PVOID lpData;
} COPYDATASTRUCT;
"""

def packCopyData(nNum, sString):
    int_buffer  = array.array("L",[nNum])
    char_buffer = array.array('c', sString)
    int_buffer_address  = int_buffer.buffer_info()[0]
    char_buffer_address = char_buffer.buffer_info()[0]
    char_buffer_size    = char_buffer.buffer_info()[1]
    copy_struct = struct.pack("pLp",        # dword*, dword, char*
                              int_buffer_address,
                              char_buffer_size,
                              char_buffer)
    return copy_struct


# get the window handle
hwnd = win32ui.FindWindow(None, "special window")

# print just for fun
print hwnd

cds = packCopyData(1, '1')
print cds

# try to send it a message
win32api.SendMessage(hwnd,
                     win32con.WM_COPYDATA,
                     0,
                     cds)

#########################################################################

The last parameter shut be an integer, but I think it must be a pointer ?

Any experience or a tip for me ?


gf

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4