I am using an application that copies text from a textbox of another running application. I do this through working with coredll.dll. But the problem is the running application's mainMenu should be clicked in order to return a text that I need to copy. How can i get the handle over a specific mainmenu using coredll.dll? I used remote Spy++ to view handlers but I cant distinguish which one is it. The handlers just contains handlers for controls such as textboxes and labels and not for mainmenus. I am a newbie in working windows CE c#.
Thanks a lot :)
I do not have any c# code ready, as this would require a lot of p/invokes, but to give you an idea on how to 'automate' foreign apps on windows CE/Mobile take a look at tscDialog.cpp at https://code.google.com/p/rdp-auto-login/source/browse/trunk/rdp-auto-login/tscDialog.cpp?r=20.
tscDialog.cpp is the code to identify and change the Remote Desktop Mobile (RDM) Dialog on windows mobile. But first I must say that you may not get the handle of a menu of a foreign window in Windows Mobile (may work on Windows CE), as the menu is not part of the window hierarchy of the foreign window but part of the desktop.
If you look at tscdialog.cpp you find the function scanTscWindow. This one enumerates all window elements of RDM to know the elements for later automated login (was used for debug and during development).
After filling and changing the RDM dialog, a click has to be performed on the Connect menu item. This is done in starTSC() function by simulating a mouse click:
To get the text of a window (or input field) you have to use GetWindowText with the right window handle.
So the simplest way to execute a menu is to simulate a mouse click on the menu.
To get a closer look at the windows on a windos ce/mobile device I use a modified version (smaller screens) of http://www.codeproject.com/Articles/9549/Capturing-Window-Controls-and-Modifying-their-prop called zDump: http://www.hjgode.de/wp/2009/06/11/zdump-take-a-look-inside-windows-ce/
You will see that it is impossible to get the menu handle of a foreign window. AFAIK there is no way for an external process. Possibly one can inject an DLL and get the window handle by code that runs inside the foreign process.