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)
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)