How to send a compsite key to window

zhouhaifeng mypromise at sina.com
Thu May 21 13:57:27 CEST 2009


just like "ctrl + A",

I want to select all the text in a window, now , I operate right menu to
get it, but it can not work all the time.
so I want to send "ctrl + a" to the window


blow is my code
thanks


hWnd = win32gui.FindWindow(None, "“中华会计网校”财税法规库下载版V1.09-法
规阅读器")
print hWnd
if hWnd <> 0:
print "将焦点移至窗口内"
point = (755, 175)
x, y = point
win32api.SetCursorPos(point)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
print "右键菜单"
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y, 0, 0)

win32api.Sleep(1000)

#单击"全选"
x = x + 10
y = y + 115
point = (x, y)
win32api.SetCursorPos(point)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)

win32api.Sleep(500)

#右键菜单
point = (455, 175)
x, y = point
win32api.SetCursorPos(point)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y, 0, 0)
#win32api.SendMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_CONTROL, 0)
#win32api.SendMessage(hwnd, win32con.WM_KEYUP, win32con.VK_CONTROL, 0)
win32api.Sleep(500)

#单击"复制"
x = x + 10
y = y + 25
point = (x, y)
win32api.SetCursorPos(point)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)



More information about the Python-list mailing list