Topview Logo
  • Create viral videos with
    GPT-4o + Ads library
    Use GPT-4o to edit video empowered by Youtube & Tiktok & Facebook ads library. Turns your links or media assets into viral videos in one click.
    Try it free
    gpt video

    Comment on Tiktok videos automatically - Coding Tutorial

    blog thumbnail

    Comment on Tiktok videos automatically - Coding Tutorial

    In this coding tutorial, we will guide you step by step on how to build a bot using Python and the PyAutoGUI framework to automatically send comments on different TikTok videos.


    Before we start, you will need the following:

    1. Install Python: Visit the Python website (link) or download it from the Microsoft Store for Windows computers.

    2. Android simulator: Install an Android simulator like BlueStacks and make sure TikTok is installed and logged into your account.

    3. Code editor: Install a code editor like Visual Studio Code (link).

    Step 1: Get the mouse coordinates

    Create a Python script called and import the pyautogui module. This script will generate the x and y coordinates of the mouse position. Use the following code:

    import pyautogui
    x, y = pyautogui.position()
    print(f"x: (str(x)), y: (str(y))")

    Run the script to get the current mouse coordinates.

    Step 2: Build the TikTok Comment Bot

    Create another Python file called for building the TikTok Comment Bot. Import the pyautogui module and the time module for delaying the execution. Use the following code as a starting point:

    import pyautogui
    import time
    # Get user input for the comment
    comment = input("Please enter your comment: ")
    # Click on the comment icon, y=COMMENT_ICON_Y)
    # Click on the comment box and write the comment, y=COMMENT_BOX_Y)
    # Click on the send button, y=SEND_BUTTON_Y)
    # Close the comments section, y=CLOSE_Y)
    # Scroll to the next video

    Replace the COMMENT_ICON_X, COMMENT_ICON_Y, COMMENT_BOX_X, COMMENT_BOX_Y, SEND_BUTTON_X, SEND_BUTTON_Y, CLOSE_X, and CLOSE_Y with the respective coordinates generated in the script.

    Step 3: Repeat the process for multiple videos

    To repeat the process for multiple videos, add a loop based on user input. Ask the user how many videos they want to comment on and use a for loop to iterate through the specified number of times. Use the following code:

    how_many = int(input("Please enter how many videos you want to comment on: "))
    for i in range(how_many):
        comment = input("Please enter your comment: ")
        # Rest of the code here

    Save both Python files and execute to start the TikTok Comment Bot. Enter the desired comment and the number of videos you want to comment on. The bot will automatically perform the specified actions for each video.


    TikTok, comment bot, Python, PyAutoGUI, automation, scripting, tutorial


    Q: Can I run this script on any operating system? A: Yes, you can run this script on Windows, macOS, and Linux as long as you have Python and the necessary dependencies installed.

    Q: Is it against TikTok's terms of service to use a comment bot? A: Using a comment bot may go against TikTok's terms of service, so make sure to use it responsibly and within the platform's guidelines.

    Q: How can I customize the bot to perform additional actions? A: You can modify the script to perform additional actions such as liking videos or following users by adding appropriate code using PyAutoGUI functions.

    Q: Can I schedule the bot to run automatically at specific times? A: Yes, you can schedule the bot to run at specific times using task scheduling tools available on your operating system.

    One more thing

    In addition to the incredible tools mentioned above, for those looking to elevate their video creation process even further, stands out as a revolutionary online AI video editor. provides two powerful tools to help you make ads video in one click.

    Materials to Video: you can upload your raw footage or pictures, will edit video based on media you uploaded for you.

    Link to Video: you can paste an E-Commerce product link, will generate a video for you.

    You may also like