import win32api
import win32gui
import win32con
import time
hwnd = win32gui.FindWindowEx(0, 0, 0, "Untitled - Notepad")
print hwnd win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL)
win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL)
#this restores the proper window, so we know we have correct handle
#just to give it a little pause time.sleep(2)
print "trying to post message"
#try to send it a return key
win32api.SendMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0)
win32api.SendMessage(hwnd, win32con.WM_KEYUP, win32con.VK_RETURN, 0)
#the above generates absolutely no effect on the notepad window.
#same effect no matter what vk code i use (e.g. 65 for A, VK_SPACE for space, etc)
### end of script
代码开发环境 python2.7,wx2.8.12
win32gui,win32api,win32con,需要安装PythonWin
也许有不用调用win32API就可以解决的方法,如有更好的方法,请留言
MoveFrame.zip
阅读(2080) | 评论(0) | 转发(0) |