How to open whatsapp desktop instead of web using C# - c#

I need C# code to open the WhatsApp desktop application instead of open WhatsApp on the web.
I tried
Process.Start("https://web.whatsapp.com/send?phone=" + textBox1.Text);
but it opens WhatsApp on the web, instead of the WhatsApp Desktop application.
I want to open this link in desktop WhatsApp application

The desktop version of WhatsApp can be found in %LocalAppData%\WhatsApp\Whatsapp.exe.
You get the environment variable with
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Use Path.Combine() to get the backslashes right when combining multiple paths.
Note that the executable above likely just starts another version of WhatsApp.exe. The latest version seems to be in the default key of the Registry at
HKEY_CLASSES_ROOT\whatsapp\shell\open\command
Starting point for an implementation: Registry.ClassesRoot.

Try using the whatsapp protocol:
var process = $"whatsapp://send?phone={textBox1.Text}";
Process.Start(process);
You can append the text argument to send a text:
whatsapp://send?phone=5555555555&text=hello

Related

Open video file by "Movies & TV" (windows 10)

Using Process.Start(#"C:\clip.mp4") will open video with default apps.
How can I open it with app "Movies & TV" (it's not default app) in C# Windows Form?
Necroposting here. I have had found out that you could treat the mswindowsvideo:// protocol as an application path on the command line.
Simply write on a command line or shell:
start "mswindowsvideo://" "<filePath>"
In your code, that would be: Process.Start("mswindowsvideo://", filePath);
For UWP you can use Launcher.
await Windows.System.Launcher.LaunchFileAsync(storageFile); //in my case this is .mkv file

(W10) Register application to manage phone numbers in web browsers (like skype)

I need to register my app coded in c# on (at least) Windows10, in order to make it elegible to open URLs that are phone numbers on web browsers (preferably Chrome). If i'm not wrong, skype does/did it. Anyone knows how to do it?
Best regards and thanks in advance :)
UPDATE: Thanks to Oscar for his answer.
I've tried to put this keys:
HKEY_CLASSES_ROOT
tel
(Default) = "URL:tel Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "c:\Program Files\Test\Test.exe,1"
shell
open
command
(Default) = "C:\Program Files\Test\Test.exe" "%1"
When I click a phone number with this scheme ("tel:nnnnnnnnn"), both Chrome and IE open a new windown allowing me to choose what app open, but my custom app doesn't appear :(
UPDATE 2: Seems like is not possible to do it on W10 (see comments bellow)
It involves writing some keys to register the tel: URI as handled by your application.
HKEY_CLASSES_ROOT
alert
(Default) = "URL:Alert Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "alert.exe,1"
shell
open
command
(Default) = "C:\Program Files\Alert\alert.exe" "%1"
See this article for a full description:
https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx
And this one about the tel: URI
https://www.rfc-editor.org/rfc/rfc3966
Seems like is not possible on W10...
The way that the applications can set itself as default ones has changed. Now the user is who decides what app should do the action... and the app has to be on the Windows Store...
See this article for a full explanation:
http://www.tenforums.com/software-apps/21303-how-do-you-set-protocol-association-standalone-exe.html

execute SIP call to deskphone .net

Need to build a simple c# app that takes command line args and then sends/makes a call to a deskphone which is SIP based so that the desktop phone dials the number
The application that does this is frSIP free app but this is for android, I need to make a simple desktop version. The format is (I think)
"sip:" + username + "#" + domain
I also want to replace the "callto" in skype to use this app instead. How do I change the windows registry to override this callto function programatically?
I just want the desk phone to dial the number
In your registry under HKEY_LOCAL_MACHINE\SOFTWARE\Classes\skype.callto\ there are a few different options to help you play with that.
You can probably replace the Skyp.exe value inside HKEY_LOCAL_MACHINE\SOFTWARE\Classes\skype.callto\shell\open\command to your own .exe file. Just be sure to accept the same parameter input as Skype does when a link is clicked.

http authorization with webdriver and popup window

I'm trying to use Selenium WebDriver to automatically login in to a site with a user-name and password. I've done my research and I don't believe this feature is supported by WebDriver, so I need to find another way. The site I'm trying to automate logging into is located here.
When prompted to login a popup window comes up that doesn't seem to be part of the browser. I'm using Firefox and Chrome. It seems Windows API may be required? I already tried passing the credentials in the URL but that didn't work. Also tried sendkeys, but received a Windows exception that the application was not accepting Windows messages. I also tried switching the current handle using driver.windowhandles but the popup doesn't seem to be a new handle.
Does anybody have any ideas? I'm kinda stuck. The preliminary code to get to the popup window is:
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.portal.adp.com");
string currentWindow = driver.CurrentWindowHandle;
IWebElement userLogin = driver.FindElement(By.Id("employee"));
userLogin.Click();
The popup you are seeing is prompted by web server and is a authentication prompt. Selenium doesn't support this operation.
One of the way to handle this limitation is to pass user and password in the url like like below:
http://user:password#example.com
More info available here : http://aleetesting.blogspot.in/2011/10/selenium-webdriver-tips.html
I wanted my answer out there because I think I've solved it. This answer does not require passing the credentials through the URL (for those of you that are unable to like me). It also does not require any custom Firefox Profiles or extensions to be installed or included with the solution or installed onto the browser eliminating cross-machine compatibility issues.
The issue with me was that the authentication could not be completed via passing the credentials through the URL because the login was behind a proxy.
So, I turned to windows automation toolkits and found AutoIT. Using AutoIT and Selenium, you can login automatically by sending the username and password to the windows dialog that appears. Here's how (note the steps below are for c#:
1 - Download AutoIT from http://www.autoitscript.com/site/autoit/downloads/
2 - Add the autoit .dll to your project references.
Right click on references, select Add Reference. Next click the browse button and browse to the dll location (most default installations it will be c:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll), and add to project.
3 - use AutoIT and Selenium like this (assuming your web driver is already initialized):
//Initialize AutoIT
var AutoIT = new AutoItX3();
//Set Selenium page load timeout to 2 seconds so it doesn't wait forever
Driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(2));
//Ingore the error
try
{
Driver.Url = url;
}
catch
{
return;
}
//Wait for the authentication window to appear, then send username and password
AutoIT.WinWait("Authentication Required");
AutoIT.WinActivate("Authentication Required");
AutoIT.Send("username");
AutoIT.Send("{TAB}");
AutoIt.Send("password");
AutoIT.Send("{ENTER}");
//Return Selenium page timeout to infinity again
Driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(-1));
Anyway, that's it, and it works like a charm :)
Also note that there are some special characters that need to be escaped in AutoIT using the sequence "{x}". For example, if your password is "!tRocks", you'd need to pass it into AutoIT as "{!}tRocks".
Happy automating.
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.http.phishy-userpass-length", 255);
profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", hostname);
Driver = new FirefoxDriver(profile);
hostname is your URL (example.com) then try to
Driver.Navigate().GoToUrl(http://user:password#example.com);
I just got done working on a prototype project that is supposed to handle exactly this kind of situation.
It utilizes BrowserMob, a popular open source proxy, to perform the authentication.
SeleniumBasicAuthWrapper Hope it helps! It is still a work in progress, but hopefully we'll get any kinks or defects ironed out in the near future.

Send file with skype4com in C#?

Is it possible send file from C# application over Skype? I searched several topics but I haven't found any solution.
either try to open file dialog in attached skype client:
var skype = new SKYPE4COMLib.Skype();
skype.Client.OpenFileTransferDialog("TargetUserHandle", "sourcePath");
or try to send the contents (1) via Stream in C# or (2) via Stream in pas
else you have to use (3) Skype Kit SDK - requires C/C++
[(1) and (3) worked for me]

Categories