Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to send a compsite key to window

Reply
Thread Tools

How to send a compsite key to window

 
 
zhouhaifeng
Guest
Posts: n/a
 
      05-21-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_RIGHTDOW N,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_RIGHTDOW N,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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to send a compsite key to window zhouhaifeng Python 0 05-21-2009 12:38 PM
Replace Tab Key to Return Key (Enter Key) from Web Forms? M P ASP General 1 08-06-2004 08:32 AM
How can a window send message to other window Frank ASP .Net 1 12-31-2003 05:47 AM



Advertisments