1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | from tkinter import * from tkinter import ttk from pynput import mouse import pyautogui root = Tk() root.title("마우스 좌표 찾기") root.geometry("350x100") ######################################## label1 = Label(root, text = "X좌표") label1.grid(row=1, column=1) entry1 = Entry(root, width=10 ) entry1.grid(row=1, column=2) label2 = Label(root, text = "Y좌표") label2.grid(row=1, column=3) entry2 = Entry(root, width=10 ) entry2.grid(row=1, column=4) button1 = Button(root, text="마우스위치", command = lambda:aaa()) button1.grid(row=1, column=5) ############################################ label3 = Label(root, text = "반복횟수") label3.grid(row=2, column=1) entry3 = Entry(root, width=10) entry3.grid(row=2, column=2) entry3.insert('end','100') ########################################### button2 = Button(root, text="클릭 시작", command = lambda:click_m()) button2.grid(row=3, column=3) ######################################## def aaa(): with mouse.Listener( on_click=bbb ) as listener: listener.join() entry1.insert("end",x1) entry2.insert("end",y1) def bbb(x, y, button, pressed): if pressed: global x1 global y1 x1 = x y1 = y if not pressed : return False def ccc(): entry1.insert("end",x1) entry2.insert("end",y1) def click_m(): click_num = int(entry3.get()) ##반복시작 for a in range(0,click_num): pyautogui.click(x1,y1) root.mainloop() | cs |
간략 설명 : 원하는 구역을 마우스로 클릭해서 좌표를 입력하고 그 좌표를 마우스가 자동으로 반복 클릭하는 오토마우스
1.[마우스위치] 버튼을 클릭해서 함수를 작동시킨다.
2.pynput 를 사용해서 윈도우 전체화면에서 마우스의 좌표를 찾는다.
(with mouse.Listener)
3.전체화면에서 반복 클릭하고 싶은 곳에 마우스를 클릭하면 Entry에 마우스의 x값과 y값을 넣는다. (entry.insert)
4.반복 횟수를 정한다
5.[클릭시작] 버튼을 눌러서 x,y위치에 반복횟수반큼 클릭을 시작한다.
pyautogui
https://drive.google.com/drive/folders/1Xiw6XoFzP3ILq2ZSmHzG60dKIKnm3RWh?usp=sharing
mouse event in Python tkinter
python mouse click cursor position using pynput with tkinter
pyautogui click
윈도우10. 파이썬3.6
pynput 1.4
pyautogui 0.9.38
V앱이나 인스타라이브 같은거 반복적으로 하트 누를 때 사용하면 좋을듯
'파이썬' 카테고리의 다른 글
파이썬 xlrd 엑셀 시트값 읽기 (0) | 2019.03.16 |
---|---|
네이버 단체메일 발송 (파이썬+엑셀파일) (0) | 2019.03.16 |
파이썬 클릭해서 마우스 좌표값 얻어오기 (0) | 2019.02.15 |