Page 1 of 1

c-sharp's class does not outputs anything

Posted: 04 Oct 2020 16:54
by WiVi71
Since VBScript's Sendkey doesn't support UTF-8 characters, I am making a code uses C-Sharp's SendKeys.SendWait.
Also, to prevent malicious use, I am adding simple passwords checks.

but there was a problem while doing this.

Code: Select all

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;

class CheckEncodedKey
{
	static void ChkKeynArg(string[] args)
	{
		Console.WriteLine("hello");
		System.Environment.Exit(50);  
	}
}
// https://www.c-sharpcorner.com/forums/sendingenter-in-console-project
class TextSendKeys
{
	[DllImport("user32.dll")]
	static extern bool SetForegroundWindow(IntPtr hWnd);

	static void Main()
	{
		Process[] procs = Process.GetProcessesByName("cmd");
		foreach(Process proc in procs)
		{
		  if (proc.MainWindowTitle == "a")
		  {
			  SetForegroundWindow(proc.MainWindowHandle);
			  SendKeys.SendWait("ab~cde~");
		  }
		}
	}
}
In this code, class CheckEncodedKey does not echos, does not exits, and does not outputs exit code.
I want to put the code below to check the password in this part.

Code: Select all

		if (args.Length > 1)
		{
			string EncodedKey = "password";
			string EncodedArg = args[1];
			if (String.Equals(EncodedKey, EncodedArg))
			{
				// Console.WriteLine(args.Length)
			}
			else
			{Environment.Exit(1);}
		}
		else
			Environment.Exit(1);
What is the problem with this code?

Re: c-sharp's class does not outputs anything

Posted: 04 Oct 2020 19:48
by Squashman
This forum is mostly dedicated to Windows Batch files and we extend other scripting languages (Vbscript, Jscript, Powershell) with the Windows Operating System. I am closing this thread until the moderators can discuss if we are going to allow questions on other programming languages.