pythongoogle-chrometabspywhatkit

auto closing of tabs after sending auto message using pywhatkit


I want to send auto message using pywhatkit. It is done by this code :

import pywhatkit

pywhatkit.sendwhatmsg("+92xxxxxxxxxx", "Hello ", 22, 28)
print("Successfully Sent!")

I have followed this link : https://www.geeksforgeeks.org/introduction-to-pywhatkit-module/

I just want to ask is there any way to auto-close the tab after sending an auto message? Thanks.


Solution

  • If you just want to close the google chrome tab, you can simulate pressing Ctrl+W to close it.

    you can use keyboard library - pip install keyboard in cmd, then:

    import keyboard
    
    keyboard.press_and_release('ctrl+w')
    

    Or you can use `win32`, `pyautogui` or any other library that let's you do it