3

I have the following code snippet

List<String> sensitiveApps = testConnection.SelectSensitive();

foreach (string sensitiveApp in sensitiveApps)
        {
            Console.Write(sensitiveApp);

            // retrieve applications to minimize handle (connect to database and systematically minimize all applications?)
            IntPtr hwnd = UnsafeNativeMethods.FindWindow(sensitiveApp, null);
            StringBuilder stringBuilder = new StringBuilder(256);
            UnsafeNativeMethods.GetWindowText(hwnd, stringBuilder, stringBuilder.Capacity);
            Console.WriteLine(stringBuilder.ToString());

            if (!hwnd.Equals(IntPtr.Zero))
            {
                // SW_SHOWMAXIMIZED to maximize the window
                // SW_SHOWMINIMIZED to minimize the window
                // SW_SHOWNORMAL to make the window be normal size
                ShowWindowAsync(hwnd, SW_SHOWMINIMIZED);
            }
        }

Where sensitiveApps is a list containing the strings "Notepad", "Recuva" and "VLC media player 2.0.3".

However, the only application that can be minimized using this code is Notepad. Debugging the program finds that

Console.WriteLine(stringBuilder.ToString());

would not return any value for the last 2 programs, but would return a Untitled - Notepad.

Is there anything I'm doing wrong?

2
  • 1
    1. Using Spy++ the FindWindow names are correct? 2. Recuva & VLC don't have skinning ability? 3. Have you tried using SetWindowText on it and changing the title to something else? Commented Jan 21, 2013 at 4:32
  • Thanks! I had no idea that there was such a program called Spy++... Found out that MS Word is OpusApp, and VLC is QWidget. Commented Jan 21, 2013 at 4:59

1 Answer 1

3

Try using Spy++ and check the FindWindow names are correct.

MS Word is OpusApp and VLC is QWidget.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.