Code: Select all
HWND hwnd = FindWindow(nullptr, L"Administrador: C:\\Windows\\System32\\cmd.exe");
int i = 0;
for (i = 0 ; i < msg.length() ; i++)
PostMessageW(hwnd, WM_CHAR, (int)msg[i], 0);
PostMessageW(hwnd, WM_KEYDOWN, 13, 28*65536+1);
Code: Select all
Run, %comspec% /k cd %path% ,,, PID
WinWait, ahk_pid %PID%
WinGetTitle, Title, ahk_pid %PID%
WinGet, hwnd, Id, %Title%
FileAppend, hwnd: %hwnd%.`n,*
Msg := "Hello World"
Msg := StrSplit(Msg)
for each, string in Msg {
PostMessage, WM_CHAR:=0x0102, %string%, 0,, ahk_id %hwnd%
FileAppend, ErrorLevel: %ErrorLevel% `n,*
}
; 13 VK_ENTER
PostMessage, WM_KEYDOWN:=0x0100, 13, 28*65536+1,, ahk_id %hwnd%
* Testing both codes in the same window, same msg, the c++ is one working correctly.
* Testing on a cmd window.
I must be doing something wrong in this line:
Code: Select all
%string%, 0,, ahk_id %hwnd%