所以我正在创建一个脚本,我需要它来运行对程序的按键操作。但我一直收到错误" SendKeys不在当前的背景下#34;我是c#
的新手//MCCScript 1.0
MCC.LoadBot(new WatchLamp());
// MCCScript Extensions
/ * ChatBot将定期访问世界以观察灯泡。 *这是一个如何从C#脚本访问播放器周围世界的示例。 * /
class WatchLamp : ChatBot
{
/* == CONFIG == */
int lampX = 6169;
int lampY = 250;
int lampZ = -7492;
/* == CODE == */
int checkCount = 0;
Location lampLoc;
public WatchLamp()
{
if (!Settings.TerrainAndMovements)
{
LogToConsole("WARNING: Terrain handling is disabled in INI file.");
LogToConsole("WARNING: This means this bot cannot watch for lamps.");
UnloadBot();
}
else
{
lampLoc = new Location(lampX, lampY, lampZ);
LogToConsole("Watching lamp at " + lampLoc);
}
}
public override void Update()
{
if (checkCount > 10)
{
checkCount = 0;
Material blockType = GetWorld().GetBlock(lampLoc).Type;
switch (blockType)
{
case Material.RedstoneLampOn:
//Lamp is on. All right. Nothing to say here.
break;
case Material.RedstoneLampOff:
SendKeys.WaitSend("{UP}");
SendText("TNT DETECTED AT SOUTH/EAST");
Thread.Sleep(5000);
LogToConsole("Lamp at " + lampLoc + " is currently turned OFF !!!");
for (int i = 0; i < 3; i++)
Console.Beep();
break;
}
}
else checkCount++;
}
}