Dumb question is there an easy way to clear to the desktop and then open two explorer windows and call the "Show windows side by side" task bar call ? Just wondering if there is an api in an MS library way to do this.
You can use the TileWindows WinAPI function via p/invoke to resize the desired windows to side-by-side.
To hide all other windows, just enumerate through them and minimise them.
A lot of API functions can be easily found on MSDN Dev Center. Without having worked with the Win API much, this is where I would start:
Get collection of Windows with EnumWindows or EnumChildWindows
Manipulate Window State with ShowWindow or TileWindows
Related
Background
I am working on a program that needs to find a list of open Metro apps. I originally tried using pure python with ctypes and using win32 api. Unfortunately, I couldn't get the names of Metro apps. So I moved on to IronPython thinking I could leverage a .net function or two to get what I want. No luck.
Where I am at
I can easily get a list of running processes and their PID, but filtering the Metro apps from the non-metro apps is proving near impossible. Also, I need to get the HWND of that window so I can interact with it.
What Won't Work
EnumWindows doesn't seem to work. FindWindowEx seems promising, but I am not sure how to do this.
Thanks in advance.
EDIT: I am now able to get what I want using IsImmersiveProcess, but the process list is doesn't include the Windows Apps.
I don't think MS allows this functionality. As an alternative, you can have the user put their mouse over the window and press a keyboard shortcut (What I am doing).
That is the best one can do.
We have Delphi code that displays data capture and edit forms, and would like to integrate that into a WPP app. Changes can be made to the Delphi code, to communicate with a C# service that enables communication between the two apps.
Something that has been mentioned is, at a low level, changing the parent window of a Delphi window from another Delphi window (maybe even the main app window) to another window, a WPF or WinForms window. How feasible is this? How can it be done?
I am also pondering somehow using the WPF Remote Desktop control, but connecting to a remote desktop server on the same machine somewhere. Once again, how feasible, and how?
I'm embedding wpf windows into my delphi app. Yes, it's the opposite way, but maybe you get inspired. I build some COM-Objects on both sides - c# and delphi, which are used for exchanging events/functions etc. To embed the windows i use HWndSource Class.
If you want to embed a Delphi window into WPF, you can use the HWndHost Class.
There is a good C-sample which can nearly direct translated to Delphi in MSDN. See Walkthrough: Hosting a Win32 Control in WPF
Also a good starting point is this article "WPF and Win32 Interoperation".
I've never done it myself, but I've heard of RemObjects' Hydra framework, they do exactly what you want.
Check this out:
http://www.remobjects.com/hydra/
and an example on their wiki:
http://wiki.remobjects.com/wiki/Delphi_WPF_Sample_(Delphi)
Hydra itself will be a host application that can host both - WPF (managed) and Delphi (unmanaged) modules.
WPF Remote Desktop control is a bad idea in my view, users won't be happy with such experience.
I am trying to embed an application inside another one so the user can use the application in it. I have this working correctly inside of a windows only applications but i don't want to limit it to windows so im going to convert all the normal C# code to a mono C# application witch is easy enough but im using some windows only code like the user32.dll so i was wondering if there is an alternative one i can use to get the same effect as the setParent and setWindowPos functions inside the user32.dll. it would be awesome if there is a cross platform option but if there is not is there atleast one i can use to get the same result for mac and linux? At this time mainly mac. I have been searching all over the place and i cant find qny alternatives to it.
You have to find a different way than user32.dll on alternative platforms, the structure in for instance OSX and Linux is very different from Windows so you will have to go different ways. However depending on what you do there might be a different way to do things using only managed code. A good place for looking for managed alternatives is PInvoke.net which suggest that you can use MDI instead of setParent
But describe what you want to accomplish with calls to setParent and setWindowPos and maybe a OSX solutions is available you can utilize.
I want to write a desktop gadget that will group icons on my desktop (using c# & WPF).
It will be a docked window that I can drag icons to it and they will stay their. Also there can be couple of this windows.
Where do I begin?
**I saw all the post here about it but I got lost. Please direct me to examples and explanation pages.
To expand on cevik's answer:
You cannot create WPF applications as gadgets BUT you have two options (which aren't as bad as you'd expect).
The reason is that widgets are composed mainly of web pages (HTML) and not executable (*.exe).
The problem of course is that WPF will only work with & produce executables.
First option - Windows API:
When I said you can't what I really meant is you can't use the Windows Vista/7 gadget platform to make your widgets.
However, you can always achieve a similar effect by using the Windows API.
The Windows API will let you do stuff to windows such as making them always on the background of other programs, which sounds to me like ~80% there (The rest would be stuff like making sure your window doesn't get re-sized or minimized, etc.).
Just as a note, the function you'd be looking for to make the window behind all other windows would be SetWindowPos (specifically the second parameter).
However make sure there isn't a library which already implements these stuff because it can be rather difficult (and consist of A LOT of surprises).
Second option - Silverlight
silverlight can be perceived as WPF for the web.
That obviously solves our problem.
However there is a cost to it, as expected.
Silverlight doesn't have all the features WPF has (possibly not all of the .NET framework as-well, not sure about that as I'm not really using it).
However it should be more than enough to get you by so you should definitely check it out.
Once you have your Silverlight application (and webpage) you'll have to create a manifest & install the gadget to your desktop. See here how to do so.
Maybe this will help you.
Template to easily get started on developing a Sideber Gadget using Silverlight 3.0 or 4.0 controls in C#.
While talking with a friend over yahoo messenger, I told him would be really cool to make a bot to answer with generic messages when someone starts a conversation. Upon thinking about what I told him, I realized it would be quite interesting to do something like that. The problem is that I don't know much about win32.
So my question is this: how do you 'link' a process to both another one and the windows environment? The goal would be to have an application running in the background which makes some sort of a query to see what windows are opened and when a new yahoo messenger conversation window appears it should send a list of keystroke events to that window.
I could use either C# or VC++ for the programming part and I can use any help: either specific answers or tips that could help me - e.g.: what to google for. So far my google research only came up with some apps/dlls/code that do that for you and some scripting stuff and I'm not exactly searching for that. I want to do all the work myself so I can learn from it.
It seems like you basically want to control other applications.
There are roughly 2 ways to do this on windows
1 - Use the low level windows API to blindly fire keyboard and mouse events at your target application.
The basic way this works is using the Win32 SendInput method, but there's a ton of other work you have to do to find window handles, etc, etc
2 - Use a higher level UI automation API to interact with the application in a more structured manner.
The best (well, newest anyway) way to do this is using the Microsoft UI Automation API which shipped in windows vista and 7 (it's available on XP as well). Here's the MSDN starter page for it.
We use the microsoft UI automation API at my job for automated UI testing of our apps, and it's not too bad. Beware though, that no matter how you chose to solve this problem, it is fraught with peril, and whether or not it works at all depends on the target application.
Good luck
Not quite the same domain as what you're looking for, BUT this series of blog posts will tell you what you need to know (and some other cool stuff).
http://www.codingthewheel.com/archives/how-i-built-a-working-poker-bot
If you really want to learn everything from scratch, then you should use C++ and native WIN32 API functions.
If you want to play a bit with C#, then you should look the pinvoke.net site and Managed Windows API project.
What you'll surely need is the Spy++ tool.
http://pinvoke.net/ seems to be the website you are looking for. The site explains how to use Windows API functions in higher level languages. Search on pinvoke for any of the functions I've listed below and it gives you the code necessary to be able to use these functions in your application.
You'll likely want to use the FindWindow function to find the window in which you're interested.
You'll need the process ID, so use GetWindowThreadProcessId to grab it.
Next, you'll need to use OpenProcess allow for reading of the process's memory.
Afterwards, you'll want to use ReadProcessMemory to read into the process's memory to see what happening with it.
Lastly, you'll want to use the PostMessage function to send key presses to the window handle.
Welcome to the wonderful world of Windows API programming.
Check out Autohotkey. This is the fastest way to do what you want.