c#如何使用coredll.dll来处理特定的主菜单 [英] c# how to get handle over a specific mainmenu using coredll.dll

查看:343
本文介绍了c#如何使用coredll.dll来处理特定的主菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个从另一个正在运行的应用程序的文本框中复制文本的应用程序。我通过使用coredll.dll这样做。
但问题是运行应用程序的mainMenu应该被点击,以返回我需要复制的文本。如何使用coredll.dll获取特定主菜单的句柄?我使用远程Spy ++查看处理程序,但我无法区分哪一个。处理程序只包含诸如文本框和标签等控件的处理程序,而不是主菜单。
我是一个工作Windows CE c#的新手。

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#.

非常感谢:)

推荐答案

我没有任何c#代码准备好,因为这将需要很多p /调用,但是给你一个想法如何自动化外部应用程序在Windows CE / Mobile采取看看tscDialog.cpp在 https://code.google.com/p/rdp-auto-login/source/browse/trunk/rdp-auto-login/tscDialog.cpp?r=20

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是用于识别和更改Windows Mobile上的远程桌面移动(RDM)对话框的代码。但首先我必须说,Windows Mobile中可能无法获取外部窗口的菜单(可能在Windows CE上工作),因为菜单不是外部窗口的窗口层次结构的一部分,而是桌面的一部分。

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.

如果你看tscdialog.cpp,你可以找到函数scanTscWindow。这一个枚举了RDM的所有窗口元素,以了解稍后自动登录的元素(用于调试和开发期间)。

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).

填写并更改RDM对话框后,必须在连接菜单项上执行点击。这通过模拟鼠标点击在starTSC()函数中完成:

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:

                    //Solution two with mouse_event, click at 13,306. The 13 comes from the assumption that hight of
                    //menu bar is 26 pixel and I want to click in the mid
                    //this solution does work as keyb_event does work
                    //      normalized coordinates:
                    //      (0,0) = upper left corner
                    //      (0xFFFF,0xFFFF) = lower right corner
                    DWORD dX = (0xFFFF / iScreenWidth) * (80); // changed from 13 to width=240, 1/3=80
                    DWORD dY = (0xFFFF / iScreenHeight) * (iScreenHeight - 13);
                    DEBUGMSG(1, (L"mouse click at: %u, %u\n", dX * 0xFFFFFFFF / 240, dY * 0xFFFFFFFF / 320));
                    //SetForegroundWindow(hTscDialog); //dont mess with windows z-order

                    //this will make a cursor visible
                    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN, dX, dY, 0, 0);
                    Sleep(5);
                    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP, dX, dY, 0, 0);
                    Sleep(30);
                    /*
                    //this is what happens, if you tap the screen
                    mouse_event(MOUSEEVENTF_TOUCH | MOUSEEVENTF_LEFTDOWN, dX, dY, 0, 0);
                    mouse_event(MOUSEEVENTF_TOUCH | MOUSEEVENTF_LEFTUP, dX, dY, 0, 0);
                    //Sleep(3000);
                    */

要获取窗口(或输入字段)的文本,您必须使用GetWindowText与正确的窗口句柄。

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.

要仔细观察windos ce / mobile设备上的窗口,我使用 http://www.codeproject.com/Articles/9549/Capturing-Window-Controls-and-Modifying-their-prop 称为zDump: http: //www.hjgode.de/wp/2009/06/11/zdump-take-a-look-inside-windows-ce/

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/

你将看到无法获取外部窗口的菜单句柄。 AFAIK没有办法进行外部程序。可能可以通过在外部进程中运行的代码注入DLL并获取窗口句柄。

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.

这篇关于c#如何使用coredll.dll来处理特定的主菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆