import win32gui
import win32con
import sys
def setText(aString):
"""设置剪贴板文本"""
w.OpenClipboard()
w.EmptyClipboard()
w.SetClipboardData(win32con.CF_UNICODETEXT, aString)
w.CloseClipboard()
def openWangwAndSend(father,son,msg):
setText(msg)
fbox = win32gui.FindWindow(None,father)
print(fbox);
sbox = win32gui.FindWindowEx(fbox,0,None,son)
print(son);
win32gui.ShowWindow(sbox,1)
win32gui.SendMessage(sbox, 258, 22, 0)
win32gui.SendMessage(sbox, 770, 0, 0)
win32gui.SendMessage(sbox, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0)
win32gui.SendMessage(sbox, win32con.WM_KEYUP, win32con.VK_RETURN, 0)
win32gui.ShowWindow(sbox, 2)
#发送旺旺群
father = u'阿里旺旺 - ****'
son=u'****'
openWangwAndSend(father,son,'for test~')
代码如上,print(son)这行,能打印出名称,但后面的打开窗口和发送消息一直不行,感觉没有定位到,求大神指教。
慕婉清6378909
相关分类