Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2298516
  • 博文数量: 321
  • 博客积分: 3440
  • 博客等级: 中校
  • 技术积分: 2992
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-24 09:08
个人简介

我就在这里

文章分类

全部博文(321)

文章存档

2015年(9)

2014年(84)

2013年(101)

2012年(25)

2011年(29)

2010年(21)

2009年(6)

2008年(23)

2007年(23)

分类: Python/Ruby

2013-03-07 10:19:49

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


阅读(2036) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~