How to programatically fill data in a dialog based UI
-
I am writing a program that opens a dialog based application (for which I don't have the source code), fills data in the edit boxes there and clicks the "OK" button. I can open the application through ShellExecute function, but I am not able to fill data in the edit boxes or get the "OK" button clicked. Can anybody help?? Please...
-
I am writing a program that opens a dialog based application (for which I don't have the source code), fills data in the edit boxes there and clicks the "OK" button. I can open the application through ShellExecute function, but I am not able to fill data in the edit boxes or get the "OK" button clicked. Can anybody help?? Please...
thevoyager wrote: but I am not able to fill data in the edit boxes or get the "OK" button clicked. 1. First Find Handle to Remote Window Using
FindWindow()
andFindWindowEx
Api's. 2. Now, Find the Edit Box and OK Button, In Which you want to fill your custom values off course usingFindWindowEx
orEnumChildWindow
Api. 3. UsingWM_SETTEXT
message Fill the Edit Box of remote Window from your custom text. 4. After completing above task, PostBN_CLICKED
message for OK Button to Remote Window"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta
-
thevoyager wrote: but I am not able to fill data in the edit boxes or get the "OK" button clicked. 1. First Find Handle to Remote Window Using
FindWindow()
andFindWindowEx
Api's. 2. Now, Find the Edit Box and OK Button, In Which you want to fill your custom values off course usingFindWindowEx
orEnumChildWindow
Api. 3. UsingWM_SETTEXT
message Fill the Edit Box of remote Window from your custom text. 4. After completing above task, PostBN_CLICKED
message for OK Button to Remote Window"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta
Thanks Alok, it works :) I got the Handle to Remote Window and also to the buttons on it, but... i) I'm not able to get control of the edit box (I searched for the button based on it's caption, but editboxes don't have a caption and i don't know what to give in the parameter lpszClassName). ii) Sending BN_CLICKED message for the OK Button doesn't seem to work. I'm sending you my code. Could you please figure out the problem:
CWnd* pClientWnd = NULL; pClientWnd = FindWindow(NULL, "Login"); CWnd* pControl = new CWnd(); HWND hWndOk = FindWindowEx((pClientWnd->m_hWnd), NULL, NULL, "&OK"); pControl->Attach(hWndOk); pControl->EnableWindow(TRUE); pControl->PostMessage(BN_CLICKED);
-
Thanks Alok, it works :) I got the Handle to Remote Window and also to the buttons on it, but... i) I'm not able to get control of the edit box (I searched for the button based on it's caption, but editboxes don't have a caption and i don't know what to give in the parameter lpszClassName). ii) Sending BN_CLICKED message for the OK Button doesn't seem to work. I'm sending you my code. Could you please figure out the problem:
CWnd* pClientWnd = NULL; pClientWnd = FindWindow(NULL, "Login"); CWnd* pControl = new CWnd(); HWND hWndOk = FindWindowEx((pClientWnd->m_hWnd), NULL, NULL, "&OK"); pControl->Attach(hWndOk); pControl->EnableWindow(TRUE); pControl->PostMessage(BN_CLICKED);
thevoyager wrote: I'm not able to get control of the edit box Try obtaining its Control ID by using Spy++ and then searching by this ID among pClientWnd's children. thevoyager wrote: pControl->PostMessage(BN_CLICKED); BN_CLICKED is not a message. It's a notification code to be used in a WM_COMMAND message. Check the documentation for both BN_CLICKED and WM_COMMAND. You should post a WM_COMMAND message to the button's parent window (not the button), indicating a BN_CLICKED code and the button's ID. In fact, for the OK button, this ID is most likely IDOK, so you wouldn't even need to search and obtain a handle to the button itself. Hope that helps, -- jlr http://jlamas.blogspot.com/[^]
-
thevoyager wrote: I'm not able to get control of the edit box Try obtaining its Control ID by using Spy++ and then searching by this ID among pClientWnd's children. thevoyager wrote: pControl->PostMessage(BN_CLICKED); BN_CLICKED is not a message. It's a notification code to be used in a WM_COMMAND message. Check the documentation for both BN_CLICKED and WM_COMMAND. You should post a WM_COMMAND message to the button's parent window (not the button), indicating a BN_CLICKED code and the button's ID. In fact, for the OK button, this ID is most likely IDOK, so you wouldn't even need to search and obtain a handle to the button itself. Hope that helps, -- jlr http://jlamas.blogspot.com/[^]
Jose Lamas Rios wrote: You should post a WM_COMMAND message to the button's parent window (not the button), indicating a BN_CLICKED code and the button's ID. Yeap, You are Right, Thanks for Correcting me Again Mr. Rios :).
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta
-
Jose Lamas Rios wrote: You should post a WM_COMMAND message to the button's parent window (not the button), indicating a BN_CLICKED code and the button's ID. Yeap, You are Right, Thanks for Correcting me Again Mr. Rios :).
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta
ThatsAlok wrote: Yeap, You are Right, Thanks for Correcting me Again Mr. Rios He, no problem :) But if you like my corrections, that would be "Mr. Lamas", or "Mr. Lamas Ríos" ;P Anyway, just "José" or "jlr" will do. Cheers, -- jlr http://jlamas.blogspot.com/[^]
-
ThatsAlok wrote: Yeap, You are Right, Thanks for Correcting me Again Mr. Rios He, no problem :) But if you like my corrections, that would be "Mr. Lamas", or "Mr. Lamas Ríos" ;P Anyway, just "José" or "jlr" will do. Cheers, -- jlr http://jlamas.blogspot.com/[^]
Jose Lamas Rios wrote: But if you like my corrections, that would be "Mr. Lamas", or "Mr. Lamas Ríos" :), So i Will refer you by Jlr :)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta