2

I am writing a Python script (3.10.2) which opens certain desktop applications via voice command using the pyttsx3 and speech_recognition modules.

I thought of including Whatsapp into this script as well, and provided the wa.me chat link of one of my whatsapp contacts, which would open after a certain voice command is said.

However, the problem lies when it opens the link, instead of directly opening it on the Whatsapp desktop application (already downloaded from MSStore) it redirects itself to the web and then the prompt asks if to continue on web or to open the desktop application.

I want to make it, directly opening the application, rather than going through the web prompts. Is there a way?

Thanks in advance!

kxnyshk
  • 167
  • 2
  • 9

1 Answers1

1

Ok, here. There are two ways one is this:

import subprocess

subprocess.Popen("C:\\Windows\\System32\\whatsapp.exe")

Another is this:

import os
os.system("program_name")
AstroGuy
  • 56
  • 6
  • thankyou for helping! Though I figured it out just a while after posting this. Went with the subprocess module way that you also mentioned with the help of cmd, it worked smoothly. Eg:- subprocess.Popen(["cmd", "/C", chatPath], shell=True) // chatPath = 'wa.me link' – kxnyshk Mar 02 '22 at 15:05
  • oh yeah sure thing. This is my first time asking here, didnt realise that :p – kxnyshk Mar 03 '22 at 08:43
  • 1
    It is fine welcome to Stack Overflow. – AstroGuy Mar 03 '22 at 18:25