Note that there are some explanatory texts on larger screens.

plurals
  1. POSending WM_COPYDATA with Python 3
    text
    copied!<p>I'm trying to write a python script that will interface with my copy of <a href="http://zhornsoftware.co.uk/stickies/api/" rel="nofollow">stickies</a>. I'm having trouble with how Python interacts with the WM_COPYDATA struct, and unfortunately I haven't been able to find many examples online.</p> <p>Using the code:</p> <pre><code>import struct import win32con import win32gui import struct, array int_buffer = array.array("L", [0]) char_buffer = array.array('b', 'do new sticky') int_buffer_address = int_buffer.buffer_info()[0] char_buffer_address, char_buffer_size = char_buffer.buffer_info copy_struct = struct.pack("pLp", int_buffer_address, char_buffer_size, char_buffer_address) hwnd = win32gui.FindWindow("ZhornSoftwareStickiesMain", None) win32gui.SendMessage(w, WM_COPYDATA, hwnd, copy_struct) </code></pre> <p>I get the following error: </p> <pre><code>C:\Users\%userprofile%\Desktop&gt;python sender.py Traceback (most recent call last): File "sender.py", line 7, in &lt;module&gt; char_buffer = array.array('b', 'do new sticky') TypeError: an integer is required </code></pre> <p>I can't seem to figure out why I'm getting such an error. Any ideas?</p> <p><strong>Edit:</strong> Some partially working code</p> <pre><code>import struct import win32con import win32gui import struct, array int_buffer = array.array("L", [0]) char_buffer = array.array('b', b"do manage open") int_buffer_address = int_buffer.buffer_info()[0] # Add () to buffer_info to call it. char_buffer_address, char_buffer_size = char_buffer.buffer_info() # Need P type for the addresses. copy_struct = struct.pack("PLP",int_buffer_address,char_buffer_size, char_buffer_address) hwnd = win32gui.FindWindow(None, "ZhornSoftwareStickiesMain") win32gui.SendMessage(hwnd, win32con.WM_COPYDATA, None, copy_struct) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload