I am trying to perform some UI Automation on an old Smalltalk application (Win32). We are not able to change this legacy app.
I have a separate c# program whoch opens the Samlltalk app. Currently I have used sendkey processing to call a menu option. Eg. File Open
IntPtr productWindow = (IntPtr)0;
productWindow = FindWindow((string)null, "Product");
SendKeys.SendWait("%F");
SendKeys.SendWait("%O");
SendKeys.SendWait("ENTER");
Natually, this is not a very robust solution as the user may upset the process be doing something on their desktop.
My question, how do programatically click on a menu option? It is easy for me if it is a button (see below)., but is there a simalar way I can access and send a click event to the menu?
IntPtr child;
IntPtr child = GetWindow(mainWindow, GW_CHILD);
IntPtr nButton = (IntPtr)0;
int childCount = 1;
while (child != (IntPtr)0)
{
StringBuilder sbMsg = new StringBuilder(2000);
SendMessage(child, WM_GETTEXT, (IntPtr)sbMsg.Capacity, sbMsg);
string msg = sbMsg.ToString();
if (msg == "&ButtonName")
nationalButton = child;
childCount++;
child = GetWindow(child, GW_HWNDNEXT);
}
SendMessage(nButton, BN_CLICK, IntPtr.Zero, IntPtr.Zero);
1, Is this possible and could you give me an example of code to pick a menu item?
2, Should I be looking at the smalltalk events that are fired behind the scenes and see if I can fire them instead?
3, Am I better making the choices available as buttons so that i can easily access them. [would involve another smalltalk app but with buttons instead?
NOTE I am not a windows programmer so any easy solution via c# is appreciated.