Another one about Win32 Vs UI Automation

坚强是说给别人听的谎言 提交于 2019-12-25 08:14:28

问题


I'm building a (Web/WinForms Application I didn't decide yet) and I have a running simple WinForms Application that I couldn't access through my new application by any means and I just want to read some values and maybe edit some values (Labels, Buttons, some trivial stuff). so I used Spy++ as advised in this question.

So, I was able to see the values that I need to read/edit through this great tool. and I was able to edit some values (Like hide, Uncheck, Disable, etc on some labels and buttons) and they reflected on the application.

So I want to move to the next step and I was advised that I have two options. Whether Win32 or UI Automation. I have no clue about both of them, so a little guidance would be great.

I just have 3 more questions regarding this problem:

  1. which would be better to use against WinForms and why?

  2. and does any of the two options can be used through a WebApplication or both options need to be implemented within a WinForms Application ?

  3. Does any of those options have a limitation in editing values ?


回答1:


(If you are still searching..)

It depends on what is mor familiar to you. Also, generally, I think, UI Automation is slightly easier, since for Wind32SDK you need to use a lot of pinvoke and stuff like that which probably does not come easy to pure .net people.

For Win32, http://www.pinvoke.net/default.aspx/ is really the one greatest place to start, giving you all the signatures and some sample code.

For UI Automation, there are a lot of places as well to start with lots of samples. One among many is http://blogs.msdn.com/b/winuiautomation/ .

Also note that they are not comparable in power and usability. Like said, UI Automation is more natural, Win32 also allows you to access many values you cannot reach through automation. I think UI Automation is mostly read-only.

It is fun to enable/disable a button in a foreign application. When finding out that it often works I thought to use it on some protected commercial product (that simply has the "pro" buttons disabled") just to check if there is an additional protection in place. :) Meaning as well that if you want to have such a feature in your app, know that a user can always make a hidden element visible or a disabled one enabled.



来源:https://stackoverflow.com/questions/7707113/another-one-about-win32-vs-ui-automation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!