我想使用 pywhatkit 发送自动消息。 这是通过这段代码完成的:
import pywhatkit
pywhatkit.sendwhatmsg("+92xxxxxxxxxx", "Hello ", 22, 28)
print("Successfully Sent!")
我已点击此链接: https://www.geeksforgeeks.org/introduction-to-pywhatkit-module/
我只是想问有没有办法在发送自动消息后自动关闭选项卡? 谢谢。
如果您只想关闭 google chrome 选项卡,可以模拟按
Ctrl+W
来关闭它。你可以在cmd中使用
keyboard
库 - pip install keyboard
,然后:
import keyboard
keyboard.press_and_release('ctrl+w')
sendwhatmsg 还有一个参数是 tab_close
import pywhatkit
pywhatkit.sendwhatmsg("+92xxxxxxxxxx", "Hello ", 22, 28,tap_close=True)
print("Successfully Sent!")
import pywhatkit as pwk
import pyautogui as gui
try:
// 5 ARGUMENTS = PHONE_NUMBER,HOUR,MINUTE,TAB CLOSE = True or False, Close tab in secs //
while(pwk.sendmessage_instantly("PHONE_NUM","H","M","True")
gui.press("Enter")
except:
print("Error")