I use UI Spy and Spy++ to view windows text of some windows, but none offers a result. As people said, some windows are built up and executed by some components, say they are embedded inside those components. Except the two tools to view the window handles, text, could you introduce me other tools or ways to get a window text or handle without using hooks ?
Edit: I also use Spy Object to retrieve windows objects information and search from ancestors till I can meet the right object but this tool to the particular windows I am watching is incapable to do the job because it also reports incorrect parents positions in ancestor hierarchy, I try out the MAAS and UI-Automation without luck, Thank you for you help.
Edit3: I don't like their windows'ideas of internal designs (I mean only they-designers- know how to untie the knots)
Usually the Accessibility APIs are used, the ones used for text-to-speech screen readers for blind users. In your question you mentioned MAAS, did you mean MSAA (Microsoft Active Accessibility)? If not, that's where I'd look next.
http://white.codeplex.com/ is a great framework which does such things.
White is a framework for automating rich client applications based on Win32, WinForms, WPF, Silverlight and SWT (Java) platforms. It is .NET based and does not require the use of any proprietary scripting languages. Tests/automation programs using White can be written with whatever .NET language, IDE and tools you are already using. White provides a consistent object-oriented API, hiding the complexity of Microsoft's UIAutomation library (on which White is based) and windows messages. Only stable versions of White are released, so all releases are production-ready.
Related
Is it possible to write a code that will copy text values from a window belonging to another application?
I have an application that gives me live results(only texts), every 5 minutes, and I cannot copy paste them every 5 min.
Maybe.
It depends on how the target application is exposing its text to the OS.
If the application is using a private 2D/drawing library to render text by itself to an in-memory or in-VRAM buffer, then no. You'll need to grab a screenshot and perform OCR on it - or you could inject your own code into the target process and intercept those 2D/drawing library calls to get the text being rendered.
If the application is using the Windows-provided GDI then there are ways of intercepting those calls to get the text. I believe Direct2D and DirectWrite also offer straightforward ways of intercepting/profiling their calls as well.
If the application is using a GUI framework or platform like WinForms or WPF then there are ways of inspecting the rendered view's object-model to extract data and text - this is how various "Spy" utilities work. "Spy++" (spyxx.exe included in Visual Studio and the Windows SDK) can inspect native Win32 hWnd windows and "Snoop" is a very powerful tool for inspecting WPF applications (Visual Studio's built-in Visual Inspector does the same thing).
Additionally, often GUI frameworks and platforms will support the OS' built-in Accessibility platform and will expose on-screen data as machine-readable structured data for use by screen-readers for the blind and visually impaired as well as automation software. Windows' built-in platform is called Active Accessibility and Windows UI Automation. There are premade tools you can download to inspect Active Accessibility data.
If it's a HTML application (e.g. Windows HTA, Electron app, Chrome desktop app, etc) then that's another topic.
Recently I’ve been working on a windows wallpaper manager. It will scan multiple directories for images and have a settings window to customize. In addition, I want to bypass the built-in wallpaper and instead use a windows form based off the ideas discussed here: Setting a Windows form to be bottommost to allow for greater control over image placement. I have built the file operations to find the wallpapers, and various other support operations.
However, I am stumped on how to implement a windows form properly. Not just the one in the Stack Overflow post above. So far none of my CompSci classes (7 so far) have discussed GUIs, and thus I have no knowledge to work from. I turned to the internet to learn how to work with GUIs. While I learned plenty to start a thread, or show a form, I was never able to find anything that described the proper way to engineer an application with a GUI. All I have learned in respect to engineering the application is to limit the number of threads, and try to separate the GUI from the non-GUI related code (if that makes sense).
Like I have said, I have no clue what I am doing. If someone would be willing to give me pointers or even a link to something on this subject, that would be amazing!
EDIT: I have been using this as a learning exercise, and I have mostly been learning from trial and error, probably mostly error
To draw on the true desktop, you need to get a handle to it: GetDesktopWindow is the function to use. But to change the wallpaper you do not draw on the desktop, but instead you use the dedicated API for handling the desktop wallpaper: SystemParametersInfo(SPI_SETDESKWALLPAPER, ...). There is also the legacy COM Shell interface, IActiveDesktop and IActiveDesktop::SetWallpaper.
As you can see, none of the APIs to manipulate the desktop and the wallpaper are managed (C#, .Net) so you will have to jump through some hoops to get this working from C#. If your goal is to learn C# style UI, I would recommend to stick to the 'blessed' way of doing this (winforms, WPF etc) and do not try to jump straight to p-Invoke and COM interop. Perhaps you can pick another project, eg. display the images/pictures in a carousel in a form.
If you're curious still, Google for C# and SystemParametersInfo or IActiveDesktop and you'll find examples of how to do this from managed C#, many examples right here on StackOverflow.
Bonus: of course Raymond Chen has a blog on this topic: How do I put a different wallpaper on each monitor?.
I'm using WINFORMS not WPF.
I just know basic c# .net gui programming. I donot want the traditional windows look. I want to have my own custom look (eg. gtalk, antivirus softwares, media players, google chrome).
Actually I'm inspired by google's PICASA software. Its awesome. I want to do something like that.How can I do that? If there is something I should learn please point me.
Also I may have to write my own custom controls (like modified tree view etc..) I guess. Please give some good learning resources.
This article describes how to draw custom windows. The author also shows how to draw non-rectangular windows.
If you could use WPF instead of Windows Forms, this is a good article about customizing window drawing:
http://www.codeguru.com/csharp/.net/net_wpf/article.php/c16379/
There is also a question with some good answers here on SO:
Creating custom forms in WPF?
Update:
I think that skinning and custom drawing is fun to do from a programmers perspective, but I also think that there is almost no benefit for the user.
The creators of the platform you are developing for might have put a lot of effort into the design of their windowing toolkits.
If you just want to change some visual aspects of your application you also should take into account that you might miss some important other aspects of UI design:
consistency
accessibility
aesthetics (if you are overdoing
effects, gradients, ...)
internationalization
...
As you are developing for Windows, you also lose the skinning ability of the OS itself. And I think that some of the skins that come with newer versions of Windows are pretty good.
You can try any of the following:
telerik
Syncfusion
(source: componentsource.co.jp)
Or other components.
They do make your UI pretty.
Edit: if you want to study how they do it, you can buy the source code-- along with documentation and understand from there.
There are some commercial control libraries available.
I can recommend the Krypton Suite. It consists of the free Krypton Toolkit (which contains a lot of skinnable controls) and other non-free controls (Navigator, Ribbon, Docking, Workspace). It has some built-in palettes and renderers that allow you to make your UI look like Office 2010, Office 2007, Office 2003, ...
You want to look for +winforms +skinning. I haven't tried these, but the first hits don't look bad. Most decent skinning tools will be paid for.
From what you said, you want to develop your own custom controls. You have some frameworks for this like Qt which can use Direct3D for hardware accelerated graphics. It also have a Visual Studio plugin. There is a free LGPL version and a commercial version of it.
I remembered about Qt because you mentioned Picasa and as far as I remember, I heard the Picasa UI has been written through Qt.
You can try using "SetWindowRgn(..)" to set an arbitrary region for your window. This may range from giving a rounded rectangle shape to giving a weird looking shape to the form!
Check this out: Link.
There is another option if you are working in Vista(aero enabled), ie you can check out DwmExtendFrameIntoClientArea(..) function here: link text
You can set the form's border style to 'none' and go on to create your custom form! You then might have to create custom buttons to carry out tasks like close, minimise, maximise etc. You might even need to write code for drag and drop events..
For the background, you might need to have a look at the gradient fills to give a great effect, otherwise you can use great looking pictures as Background..! But the latter option isnt good unless you have really good pic.
How can I implement ActiveX Document on C#/.NET? (ActiveX Document can draw itself in IE)
Update: I need a solution for drawing my own document type in IE windows (like MS Word or MS Excel draw its documents in IE).
You need to dive into OLE for that purpose.
Things like IOleDocument, IOleInPlaceSite (see MSDN for that). Figure out which interfaces are needed for the client (as IE would be the container and will need to communicate with your interface implementations), and how the communication is going on, e.g. what gets called when.It's not rocket science, but I believe still a fair amount of work.
Look at http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.domdocument.aspx, it's .NET wrapper for DOM Document
My first thought is that you could use a WPF Page, which can be hosted in a WPF window or in IE.
From MSDN:
Encapsulates a page of content that can be
navigated to and hosted by Windows
Internet Explorer, NavigationWindow,
and Frame.
This is possible but it is tough.. What is bad is the lack of documentation... Microsoft has no interest in supporting this scenario. Another difficult part is debugging the boundaries between the HTML/DOM and the ActiveX control.
For what you're doing, it sounds like Silverlight would be a better choice. It only supports a subset of .Net, but it supports drawing graphics. It'll be a lot easier for you to find documentation. And it will run on non-Windows computers.
But maybe you need something Silverlight doesn't do (like audio input support). If thats the case, there's various blogs on the subject of varying quality. Here are the two that stood out as most helpful to me:
http://www.codeproject.com/KB/cs/CreateActiveXDotNet.aspx
http://blog.ianchivers.com/wordpress/?p=22
I do recommend using OleView to inspect the type libraries you produce, and make sure its what you expect. You can also do this to see how to break event properties into get/set functions, which is something I had to do to debug some scenarios.
Also be cognizant of the difference of "attaching debugger to process" with scripted or managed debugging. At some point you'll attach with one when you think you've used the other.
i m developing a little tool on my Pocket PC using WM6 SDK but i would like to implement a finger friendly user interface (iphone-like).
So i m looking for a free .NET framework that offers the possibility to easily integrate a finger friendly interface for Windows Mobile 6 Pro .
Any ideas ?
EDIT : Finger friendly means big icons, big buttons , scrollable screens with a simple touch of the thumb... Because the Winforms in Compact framework are made for the stylus, not fingers !!
I know of no such interface API.
I would code such an interface from scratch, overriding Paint and mouse events. If you need more fancy drawing tools that compact framework provides, you should look for pinvoke to access GDI+.
You should really check out Resco's MobileForms Toolkit 2009.
I bet their controls are exactly what you are looking for. Plus they have a whitepaper and videos to show off the controls.
I am not sure it is what you are looking for (I didn't have time to examine it yet myself, but I definately intend to); this UI Framework looks interesting:
http://code.msdn.microsoft.com/uiframework
Check out the Fluid windows mobile controls available at http://fluid.codeplex.com/
This might be what you are looking for, and its open source.
Any current readers on this thread should check out SlideUI (http://www.devslide.com/products/slideui). It's a current (and supported) product which offers touch friendly (iphone-like) scrolling and controls.
I'm not entirely sure what you're asking here... Windows Mobile 6.0 Pro is touch-screen enabled, so you should simply have to create your project targeting the Windows Mobile 6.0 Pro (note, however, that your application will not be compatible with Windows Mobile 6.0 Standard devices).
I know exactly what you are talking about. All the .NET Controls are designed for the stylus. When you make them bigger for the finger, there is no guarantee they will respond well. Add to that every hardware devices sensitivity is different and its even harder.
I recently built an application attempting to incorporate some touch like functionality. it was a pain having hand code all this stuff.
The problem with a 3rd party library, as opposed as coming in Windows MObile is then everyone is designing their own library and navigation techiques. Hopefully MS will wise up on this front.
http://sites.google.com/site/nebowiki/
If you are developing finger friendly apps, your target device needs a process to handle finger input as opposed to the stylus. HTC devices (Such as the Kaiser, Mogul, Touch Pro, etc.) use TouchFlo for this purpose. There are a few different versions of TouchFlo and I'm not sure if there is an SDK, but you need to incorporate it into whatever you program. xda-developers.com will have lots of info about it.
It IS amazing that with WM6.1 Pro, .NET CF 3.5 and VS2008 that all we have available are the basic stylus-sized controls that are are spartan in the extreme. i.e., coyote-ugly. I'm about ready to chew my hand off rather than use them in an app.
So where is the third-party collection of controls that all WM developers are flocking to, to provide touch-friendly apps?
Ugly is truly the correct word for most (mine included) mobile win apps.
I am developing for an older piece of hardware with a mono screen which makes it even worse.
Take a look here:
http://www.windowsfordevices.com/news/NS9328208835.html
and here:
http://msdn.microsoft.com/en-us/library/dd630622.aspx
This is not free, but it is affordable - some of the screen shots are pretty nice looking:
http://www.basic4ppc.com/?gclid=CIiO1di1nJoCFRAhDQodYX8-9A
Anyway...sorry if this was just googledragging - maybe it had something you had missed.
--Joe
Finger Freindlyness is a result of the touch screen technology (capacitive screens are less accurate, but require zero pressure; resistive screens require physical pressure and are harder to swipe, flick, etc.)
With Windows Mobile 6.5, they have introduced a system gestures library (and if you'd rather not have to P/Invoke it, there is a sample wrapper on MSDN Code Gallery). Theoretically, it would be possible to write to this new library, and maybe emulate the gestures on pre-WM6.5 devices, if required.