ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Simple Python automouse click
    Hack/Python 2020. 4. 6. 09:34

    코드를 실행하면 start() 함수에 의해 현재 마우스의 포인터 값을 가져온다.

    적당한 포인터 값을 확인한 뒤 ''' while True: ~ time.sleep(60) ''' 부분의 마우스 포인터 값을 입력하고 주석(''')을 제거한 후 실행하면 sleep 주기에 따라 클릭을 수행한다.  (* sleep(60)은 60초)

     

    동영상 강의에서 Next 클릭하기 귀찮을 때 쓸 수 있다.

     

    [Python 2.7 code]

    import win32api

    import win32con

    import time

     

    def click(x,y):

       win32api.SetCursorPos((x,y))

       win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x,y,0,0)

       win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x,y,0,0)

     

    def start():

       x,y = win32api.GetCursorPos()

       print "Mouse at " + str(x) + ", " + str(y)

     

    start()

    """

    while True:

       click (1421, 868)

       time.sleep(60)

    '''

    반응형
Designed by Tistory.