Hola que tal, tengo el siguiente código pero no logro que funcione, quiero que haga foco a una ventana(envió el handle desde ams) pero no funciona
using RGiesecke.DllExport;
using LuaVM.Utilities.Lua;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Collections.Generic;
using System.Windows.Forms;
namespace lcserveradmin
{
public class lcserveradmin
{
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
public static int f_sendkeys(IntPtr Ls)
{
string text = Lua.lua_tostring(Ls, 1);
IntPtr window_handle = Lua.lua_topointer(Ls, 2);
SetForegroundWindow(window_handle);
SendKeys.SendWait(text);
return 1;
}
[DllExport(CallingConvention = CallingConvention.Cdecl)]
public static int luaopen_lcserveradmin(IntPtr Ls)
{
Lua.lua_register(Ls, "luasendkeys", new Lua.LuaFunction(lcserveradmin.f_sendkeys));
return 1;
}
}
}