How to hide process by clicking button

Asked

Viewed 477 times

1

I wonder if it is possible I get the id of a program like in the example and hide it (since it is already open), taking it from the navigation bar (http://i.imgur.com/fiAQ3fJ.png), that is, when clicking the button it hides the program, but it continues running normally and hidden. I haven’t tried anything yet because I still don’t understand how to do.

  • You don’t need to tag visual-studio when the problem is unrelated to the IDE. See this question for more details.

  • Explain better what you intend to do? Hide a third-party application? Or open your application "minimized"?

  • hide third party application, not only minimize too, I know how to open hidden, but do not know hide when already opened .

1 answer

1


There are several ways to do this, but here’s one of the easiest.

Above all, refer to this namespace:

Imports System.Runtime.InteropServices

Now declare that function.

<DllImport("user32.dll")> _
Private Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
End Function

And use this method to display or hide something.

Public Sub AlterarStatus(ByVal NomeDoProcesso$, ByVal Status As Integer)
    Dim mywindow As Integer
    Dim processRunning As Process() = Process.GetProcesses()
    For Each pr As Process In processRunning
        ' Uso do ToLower() para ignorar maiúsculas de minúsculas, se não quiser isso, remova
        ' nos dois membros
        If pr.ProcessName.ToLower() = NomeDoProcesso.ToLower() Then
            mywindow = pr.MainWindowHandle.ToInt32()
            ShowWindow(mywindow , Status)
        End If
    Next
End Sub

In the argument Status, if its value is 0, the window will be occult, if it’s 1, she will be showoff.

  • hello, your code seems to me useful, seems to be what I seek, but I did not understand how to use it

  • Insert the first code into the first line of your file; put the second and third code into the application class; call the method AlterarStatus() to change the display of a process.

  • Hello, the code worked to hide, but when I change 0 for 1 the process does not appear again, I am using it like this: http://i.imgur.com/Ba51idg.png

  • Try to implement an external call to show the process.

  • 1

    I am using 2 different button, as so external call, could show an example, but anyway your code was very useful to me ^^

  • Click the up arrow (next to the answer) and the V sign to mark this answer as correct, helps me a lot ^-^

  • It was very helpful your help thanks , but still could not make appear again u.u

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.