is there a Mono Alternitive to user.dll setparent and SetWindowPos? - c#

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.

Related

IronPython-List Open Metro Apps only

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.

Hide/Disable Start Button in Windows 8.1

I've searched a lot these days to find a way to programmatically hide or disable the start button in Windows 8.1, but could not find any useful information
Is there any way to do this? Either with C# or with some registry-keys...
A short explanation why I need to hide the button:
We have a .NET Desktop Application which runs on WinXP, Vista and 7 in a self-made kiosk mode. Now we have to get it running in Win8 (8.1) but as expected, the new Start-Menu (Metro, Modern UI, whatever you call it) is always there.
I already managed to disable the Hot Corners, but the Start Button in the left corner still appears when you move you mouse over it, and it also starts the Metro - what we don't want.
Any help would be appreciated!
It seems that there is no such way...
But you could use a third party tool like one of these http://lifehacker.com/how-can-i-hide-the-start-button-in-windows-8-1-1478012124.
This question belongs on SuperUser, since it's not code related, but I'll have a go at it.. You should create a system account with an assigned access. Here, read these two articles: first second
According to these articles, it shouldn't take you more than 5 minutes to achieve what you want.
... find a way to programmatically hide or disable the start button in Windows 8.1...
See Registry Key Controlling Start Button in Windows 8.1? on SuperUser. According to one commentor, there is no simple fix like a registry key. Tools like 7+ Taskbar Tweaker inject a DLL into explorer hook/subclass/redirect some of its methods.
If you are going to write your own DLL and inject it into Explorer, then you might want to take a look at Microsoft's Detours Library. I've used it in the past and its actually easy to use. The description from the website: Detours intercepts Win32 functions by re-writing the in-memory code for target functions. The Detours package also contains utilities to attach arbitrary DLLs and data segments to any Win32 binary.

Is it possible to generate executable from Windows RT?

Is it possible to generate any sort of executable from within Windows RT and .Net 4.5? In the desktop I know CSharpCodeProvider could be used, but it seems to not be allowed in Windows RT. The goal is to make an IDE for C#.
I haven't played with it myself, but I think Project Roslyn would be a good fit. You should be able to call those APIs from a WinRT front end, I think.
WinRT is not intended (as of today), to create such kind of applications, the closest is the eval function on Javascript, but it's the only one.

Getting input into a process

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.

automating .NET applications

I'm trying to automate a hidden .NET application, with another .NET application (written in c#) using the easiest way possible. It's NOT for testing purposes, it's a way to fulfill the lack of scripting for this application.
I already tried white framework, but there is one major problems with it: the way it's working. It's slow and it's not working on hidden windows and controls (like the winAPI does). Whats more, when "clicking" white moves the mouse, brings it's targeted window to the front and so on.
I was also thinking about using a user32.dll wrapper, because the way it's handling it's target is what I need, but I've red it's not working with .NET applications. It also would be a problem working with it, because my targeted application got 5 button labeled "...", and would be really hard finding 2 of them I need. I also would like to use the controls .NET id (the name the developer gave to it's controls when designing the GUI).
BTW, my targeted application is MeGUI if that helps. We do a lot of video encoding and a tool like this would help us a lot. I need the MeGUI to be hidden, because I'm the only programmer, others using my tool shouldn't see what happens in the background, not to talk about the many windows popping all around.
You can add a reference to the exe from your project and then create an AppDomain to run its main method. From there, it should be possible to queue delegates to its main thread's loop. With a bit of reflection, you could have those delegates invoke the click events and whatnot directly.
I've never attempted this approach, but it should work.
You should try Stephens idea instead of scripting a hidden app. A .NET Windows Forms App (EXE) is still a .NET Assembly and that means you can use that the same way as a DLL, just add a reference and use the public classes.
If you still want to try some scripting, take a look on the "Microsoft UI Automation" API and the "System.Windows.Automation" namespace.
Nice article here: http://msdn.microsoft.com/en-us/magazine/cc163465.aspx
MSDN Doc: http://msdn.microsoft.com/en-us/library/system.windows.automation.aspx

Categories