我正在尝试使用jitbit宏录制器创建一个宏,我需要的是if语句的快捷方式,如“ctrl + y”,但软件没有if语句为shourtcuts。但是有Run“C#代码”功能。我正在尝试为此创建代码。但到目前为止失败了。任何人都可以帮助我吗?
注意:代码必须包含一个名为Program的类,其静态方法为Main。
以下是宏录制器的示例代码;
public class Program
{
public static void Main()
{
System.Windows.Forms.MessageBox.Show("test");
}
}
答案 0 :(得分:-1)
也许这就是你要找的东西:
class Program
{
static void Main(string[] args)
{
ConsoleKeyInfo keyinfo;
do
{
keyinfo = Console.ReadKey(true);
if (keyinfo.Modifiers == ConsoleModifiers.Control)
{
if (keyinfo.Key == ConsoleKey.Y)
{
// Do something
}
else if (keyinfo.Key == ConsoleKey.Z)
{
// Do something else
}
}
}
while (keyinfo.Key != ConsoleKey.X); // Ends the program if you press X
}
}