how to get the spesific line of the text in the clipboard
I want to get the eighth line in the text of the text in the clipboad, but when I call GetClipboardData I only get a string, how can I repair it? thanks a lot. My code is here : try: win32clipboard.OpenClipboard(hWnd) #win32api.Sleep(500) text = win32clipboard.GetClipboardData(win32con.CF_TEXT) #win32clipboard.EmptyClipboard() win32clipboard.CloseClipboard() logging.info(len(text)) return text except Exception, exc: logging.info(exc) ... def get_file_title(filename): f = file(filename) #f = open(filename, encoding='gb2312', mode='w+') title = u"" line_count = 0 for line in f: line_count = line_count + 1 if line_count == 8:
How to send a compsite key to window
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) -- http://mail.python.org/mailman/listinfo/python-list
How to send a compsite key to window
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) -- http://mail.python.org/mailman/listinfo/python-list
SendMessage question
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) -- http://mail.python.org/mailman/listinfo/python-list