Window Handlers: Get handle of sub-element

 

Hi, I'm writing an expert that knows to switch between accounts. Experiencing following issue:

hWnd - is handle of Login form in Terminal. I need to type Username/Password in fields and simulate pressing ENTER.

Here is my code so far:

PostMessageA(hWnd, WM_KEYDOWN, "MyUsername", 0); // Type username

PostMessageA(hWnd, WM_KEYDOWN, 0x09, 0);//Press TAB

PostMessageA(hWnd, WM_KEYDOWN, "MyPassword", 0); // Type password

PostMessageA(hWnd, WM_KEYDOWN, 0x0D, 0); // Press ENTER

Only ENTER pressing simulation is working - nothing else. Please advise how could I solve this?

Thanks in advance.

 

I fixed it as follows:

//Fill Account Number
hlogin=GetDlgItem(GetDlgItem(hWnd,0x49D),0x3E9);
SendMessageA(hlogin,WM_CLEAR,0,0);
SetWindowTextA(hlogin,login);

//Fill Password
hpass=GetDlgItem(hWnd,0x4C4);
SendMessageA(hpass,WM_CLEAR,0,0);
SetWindowTextA(hpass,password);

//Press Enter
hbutton=GetDlgItem(hWnd,0x1);
SendMessageA(hbutton,BM_CLICK,0,0);
 
Thanks for sharing the solution too. Good info.
 
Guys, do you have complete code?
Reason: