import win32gui import win32api import win32con from ctypes import * CLASS_NAME = "Receiver" def GetReceiver(): try: hwnd = win32gui.FindWindow(CLASS_NAME, None) return hwnd except: return None class COPYDATASTRUCT(Structure): _fields_ = [ ("dwData", c_void_p), ("cbData", c_ulong), ("lpData", c_char_p) ] def SendData(hwnd, buf, data_len): # prepare data and send it cds = COPYDATASTRUCT(0, data_len, buf.raw) win32api.SendMessage(hwnd, win32con.WM_COPYDATA, 0, addressof(cds)) def main(): hwnd = GetReceiver() if hwnd == None: print 'cannot find receiver' return xbuf = create_string_buffer(14) xbuf[0] = '\x00' xbuf[1] = '\x01' xbuf[13] = '\x13' SendData(hwnd, xbuf, 14) main()
更多資訊:
- Google 'COPYDATASTRUCT python lpData'
- Google 'python WM_COPYDATA SendMessage'
沒有留言:
張貼留言