Problem in open dialog box in c++

Ask general questions here.
d_mak
Posts: 3
Joined: Thu Sep 04, 2008 5:08 pm

Problem in open dialog box in c++

Post by d_mak » Tue Nov 18, 2008 10:09 pm

1 problem:My application is, when i click a button i got a open dialog box.
Now my problem is how to automate to select particular file and click open button .

2 problem:
My Application has second button which open a console window and ask the user to enter something.
My problem is to automate this console window and write whatever i write in program.


plz help.Tell function names which can be used in c++ of visual studio.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Wed Nov 19, 2008 2:57 pm

1. Now my problem is how to automate to select particular file and click open button .
Please use the following C++ sample code:
(I tried this with the sample VS2005Application.exe)

Code: Select all

int ret = RxMenuSelectItemText(form, "Submenu3", "FileOpen", NULL);	
RxSleep(1000);
HWND fileOpenDialog = RxFormFindTitle("Open", MATCH_EXACT, TRUE, 1500);	

// Get the Element of the TextBox
ElementStruct element;
if ( RxControlGetElement(fileOpenDialog, &element) == TRUE)
{
	ElementStruct textbox;
	BOOL bRet = RxElementFindChild(&element, ROLE_SYSTEM_TEXT, "File name:", NULL, &textbox);
	if (bRet==TRUE)
	{
		//RxElementSelect(&listItem, SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION);
		RxElementSetValue(&textbox, "myFile");

		ElementStruct openButton;
		bRet = RxElementFindChild(&element, ROLE_SYSTEM_PUSHBUTTON, "Open", "Button", &openButton);
		if (bRet==TRUE)
		{
			::RxMouseClickElement(&openButton);
		}
	}
}
2. My problem is to automate this console window and write whatever i write in program.
Use the function RxControlSendKeys to write data into a console window.

Jenö
Ranorex Team