How to send a compsite key to window

Z

zhouhaifeng

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top