SendMessage question

Z

zhouhaifeng

Hi,I want to send "ctrl + A" and "ctrl + C" to a window,
but my code can not work, who can help me ?

Thanks a lot!

hWnd = win32gui.FindWindow(None, "¡°pad")
print hWnd
if hWnd <> 0:
point = (555, 175)
x, y = point
win32api.SetCursorPos(point)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x, y, 0, 0)
win32api.SetCursorPos(point)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)

#ctrl + A
win32api.SendMessage(hWnd, 0, win32con.VK_CONTROL, 0)
win32api.Sleep(10)
win32api.SendMessage(hWnd, 0, 65, 0)
win32api.SendMessage(hWnd, win32con.KEYEVENTF_KEYUP, 65, 0)
win32api.SendMessage(hWnd, win32con.KEYEVENTF_KEYUP, win32con.VK_CONTROL, 0)
win32api.Sleep(10)

#ctrl + C
win32api.SendMessage(hWnd, win32con.WM_KEYDOWN, win32con.VK_CONTROL, 0)
win32api.Sleep(10)
win32api.SendMessage(hWnd, win32con.WM_KEYDOWN, 67, 0)
win32api.SendMessage(hWnd, win32con.WM_KEYUP, 67, 0)
win32api.SendMessage(hWnd, win32con.WM_KEYUP, win32con.VK_CONTROL, 0)
win32api.Sleep(10)
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top