I created an application that sends keyboard input to cmd.exe
.
This works when running cmd
as a normal user but fails when cmd
is run as Administrator.
This is my code:
Var
Wnd:hwnd;
begin
wnd:=FindWindow('ConsoleWindowClass',0);
if wnd <> 0 then
begin
setforegroundWindow(wnd);
keybd_event(Ord('A'),0,0,0);
end;
end;
Notice that ConsoleWindowClass
is the class name of cmd
.
How can I send input to cmd
when cmd
is running as administrator?