If host executable opened directly, it will show msg box to explain what it is used for

This commit is contained in:
Jaex 2017-02-11 20:27:38 +03:00
parent 52e9a63b0a
commit 89834c8840

View file

@ -35,6 +35,8 @@ namespace ShareX.NativeMessagingHost
internal class Program
{
private static void Main(string[] args)
{
if (args.Length > 0)
{
try
{
@ -45,6 +47,12 @@ private static void Main(string[] args)
MessageBox.Show(e.ToString(), "ShareX NativeMessagingHost - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("This executable is used to receive input from browser addon and send it to ShareX executable.",
"ShareX NativeMessagingHost", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private static void Run()
{
@ -52,20 +60,20 @@ private static void Run()
if (!string.IsNullOrEmpty(input))
{
NativeMessagingInput chromeInput = JsonConvert.DeserializeObject<NativeMessagingInput>(input);
NativeMessagingInput nativeMessagingInput = JsonConvert.DeserializeObject<NativeMessagingInput>(input);
if (chromeInput != null)
if (nativeMessagingInput != null)
{
string argument = null;
if (!string.IsNullOrEmpty(chromeInput.URL))
if (!string.IsNullOrEmpty(nativeMessagingInput.URL))
{
argument = Helpers.EscapeCLIText(chromeInput.URL);
argument = Helpers.EscapeCLIText(nativeMessagingInput.URL);
}
else if (!string.IsNullOrEmpty(chromeInput.Text))
else if (!string.IsNullOrEmpty(nativeMessagingInput.Text))
{
string filepath = Helpers.GetTempPath("txt");
File.WriteAllText(filepath, chromeInput.Text, Encoding.UTF8);
File.WriteAllText(filepath, nativeMessagingInput.Text, Encoding.UTF8);
argument = $"\"{filepath}\"";
}