user32

How can I determine the current focused process name and version in C#

For example if I'm working on Visual Studio 2008, I want the values devenv and 2008 or 9. The version number is very important... ...

User32 API calls in .NET

I'm currently planning out a project involving creating a shell replacement for Windows (based on Blackbox, bblean specifically). However I wish to leverage the power of .NET to do so. Many of the API calls I'll need are housed within the User32 library. I can of course use P/Invoke and create a static class to handle this for me. Ho...

User32's ShowWindow doesn't act as expected

I am using the ShowWindow method from User32 to hide a window (cmd.exe) from the user (mainly to prevent them from closing it). When the user opens the form, the process is started, and hid, then when the form is closing the process is killed. However, when the form is opened again, it doesn't hide the window (and sometimes doesn't the f...

How to get the active window of a logged on user from a service

I am writing a C# service which has to retrieve information from the currently logged on user like the active window or the last mouse movement. I already learned that I can retrieve these information by using the user32.dll but this does only work from within the user context which calls the methods. This way my service could only retr...

Swapping left and right mouse button in .NET

How do I swap left and right mouse buttons in .NET (preferably C#)? Basically the result should be the same as if the user checked the "Switch primary and secondary buttons" checkbox in the Mouse Properties through the control panel. I'm dealing with Windows XP, in case that makes a difference. ...

How to determine if the Caps Lock is toggled in a Silverlight Application?

In a Silverlight application's log in screen, i need to determine if Caps Lock is toggled. This is easy enough by handling the KeyUp or KeyDown event, however how does one determine if it is toggled on or off even if a key hasn't been pressed? The reason I want todo this is what if the user doesn't press Caps Lock while the Silverlight ...

Automated Clicking Problem

I am coding up a program for automated testing which randomly clicks an open application window using various User32.dll library calls. My current problem is this, if a click would open a dialog, using Process.WaitForInputIdle() does not wait long enough for that dialog to be detected the next trip around the loop, which means several cl...

Using SendMessage for Simulating User Mouse Clicks

I need to use SendMessage fro simulating user clicks in a target program as SendMessage blocks until the event that it triggers is finished processing. The reason for this is that this blocking gives opportunity to detect if any dialogs have opened up as a result of the clicking. My problem currently is that although I can get the clic...

SendMessage to click on Non-Client items.

I am having trouble getting SendMessage to activate a menu on another program. When looking through Spy++ when a user clicks on the menu the following occurs: 000A0628 P WM_NCLBUTTONDOWN nHittest:HTMENU xPos:1706 yPos:395 [wParam:00000005 lParam:018B06AA time:27:23:56.156 point:(1706, 395)] 000A0628 S WM_SYSCOMMAND uCmdType:SC_MOUSE...

Setting Virtual Key/MouseButton State Without Triggering Events

Is it possible to set the virtual key state / mouse button state for all programs on a computer without triggering the associated events at the same time (like setting the left mouse button to be currently pressed without sending a mouse down event). Could this be achieved by setting up a fake keyboard or mouse driver for a fake keyboar...

How do I get the active ChildWindow of an application?

Hi guys, I have this problem: I have an handler to the mainWindow of a certain application, and I want to simulate a keypress on that application... I'm using sendMessage/postMessage api calls to do this. The reason why I don't use the .Net SendKeys function or the keybd_event of the win32 api, is that they simulate the keypress at a gl...

How do I get the active ChildWindow of an application?

Hi, I want to send a pressKey event to a certain application which is not the active application IN Windows so I have to use the sendMessage/postMessage api calls. However, I need to know the exact child window that is active IN the application and send the pressKey message to it... I was using GetTopWindow and GetWindow(GW_CHILD) ap...

How to get minimized window's RESTORED bounds?

It's easy to get the bounding rectangle for all the visible windows on a screen. It's also easy to tell if any window is iconic or not. But for minimized windows, the Top and Left is reported as -32000 from User32.GetWindowInfo.rcWindow. I've looked all through the API and can't find a call to return the bounds the window would restore...

How can I be notified when a new window is created on Win32?

Is there a way using Win32, to register for notifications when a new window is created. I'm trying to keep a list of current open windows, but am now just polling the list of current windows using EnumWindows(). Anyone done something similar? Thanks ...

Changing system colors for a single application (Windows, .NET)

I know I should generally avoid messing up with such system settings, but my application do already use nonstandard colors and I have no influence on that. I would like to be able to add standard .NET controls in some places, but their colors do not match. I would like to have a hack that would replace system colors for this one applicat...

How do I hide the titlebar and lock the position on an exe (unmanaged code) that I have moved inside a panel in a c# form?

I have to "embed" an .exe within a panel in a .net windows form. I am doing this using user32.dll SetParent to set the launched app's parent to the forms Panel handle. Once this is done, I would like to Hide the title bar of the .exe lock the exe into the panel (maximized) so it cannot be moved or closed. Suggestions? ...

GetIconInfo function not working properly

I have written an application which is getting the Icon info of current cursor using GetIconInfo function of user32.dll, It works fine for some time, but after some time it starts providing wrong information in ICONINFO.hbmMask (some negative value), and when on the next line I try to get Bitmap object from Bitmap.HBitmap(bitmask), it th...

Enable a control of another application with User32 (vb .net)

I was wondering if there was a function in user32 that could enable a hwnd control if it is disabled (grayed out) If I know the handle then can I do this? Also, if it is a menuitem, can it be done too? Thanks ...

How do I turn of WS_CAPTION style of a window (using user32.dll)?

I am embedding a 3rd party app into a panel on a c# windows form (using SetParent from user32.dll). I need to then turn off the title bar windows style (WS_CAPTION) so that it looks like a part of the hosting application. How do I change a window's style to accomplish this? For sake of example, say _hWnd is the handle of the applicati...

Better way to "dock" a third party running application inside a windows.forms panel?

I am currently doing this as follows: // _Container is the panel that the program is to be displayed in. System.Diagnostics.Process procTest = new System.Diagnostics.Process(); procTest.StartInfo.FileName = "TEST.EXE"; procTest.StartInfo.CreateNoWindow = false; procTest.StartInfo.WindowStyle = ProcessWindowStyle.Normal; procTest.Star...