ShowWindow is unable to show or minimize Task ManagerHow to kill an alert window in Windows using C#?Need to activate a windowStart 2nd instance of a c# program with a parameter, which the 1st instance of the program usesOpen Tab in IE8 using SendMessage() C#Error - Unable to access the IIS metabaseSet position of TabTip keyboard c# is not workingInvalidOperationException by InitializeComponentRemove titlebar from window. Window process started by different userProcessing WM_GESTURE in C#Unable to restore windows hidden with ShowWindow

Wired to Wireless Doorbell

US entry with tourist visa but past alcohol arrest

Do things made of adamantine rust?

Runaway-argument error message when line break occurs inside argument of a macro

Algorithm that spans orthogonal vectors: Python

Debussy as term for bathroom?

GitHub repo with Apache License version 2 in package.json, but no full license copy nor comment headers

I reverse the source code, you negate the output!

Why are some of the Stunts in The Expanse RPG labelled 'Core'?

Nanomachines exist that enable Axolotl-levels of regeneration - So how can crippling injuries exist as well?

Cheap antenna for new HF HAM

Can Bless or Bardic Inspiration help a creature from rolling a 1 on a death save?

CDG baggage claim before or after immigration?

How to deal with my team leader who keeps calling me about project updates even though I am on leave for personal reasons?

Where Does VDD+0.3V Input Limit Come From on IC chips?

Which museums have artworks of all four ninja turtles' namesakes?

When does removing Goblin Warchief affect its cost reduction ability?

Why does NASA publish all the results/data it gets?

Why there so many pitch control surfaces on the Piaggio P180 Avanti?

I reverse the source code, you negate the input!

Hilbert's hotel, why can't I repeat it infinitely many times?

Temporarily moving a SQL Server 2016 database to SQL Server 2017 and then moving back. Is it possible?

What do these pins mean? Where should I plug them in?

As a discovery writer, how do I complete an unfinished novel (which has highly diverged from the original plot ) after a time-gap?



ShowWindow is unable to show or minimize Task Manager


How to kill an alert window in Windows using C#?Need to activate a windowStart 2nd instance of a c# program with a parameter, which the 1st instance of the program usesOpen Tab in IE8 using SendMessage() C#Error - Unable to access the IIS metabaseSet position of TabTip keyboard c# is not workingInvalidOperationException by InitializeComponentRemove titlebar from window. Window process started by different userProcessing WM_GESTURE in C#Unable to restore windows hidden with ShowWindow






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















I need to show Task Manager app programatically, maximize it and minimize it as any other window but there is a problem and it simply doesn't respond to ShowWindow(int hWnd, int nCmdShow).



I am pretty sure I use the correct handle because I enumerated all of the windows with EnumWindows(PCallBack callback, int lParam) and the only window that didn't respond was the task manager window with title process.MainWindowTitle = "Task Manager", I even manually found its handle using spy++ but it still doesn't respond to SW_SHOWNORMAL or any other nCmdShow parameter. I tried running apps as administrator to see if it has something to do with the issue but they kept behaving like normal when proper handle was given to ShowWindow function;



private delegate bool PCallBack(int hWnd, int lParam);

private static void ShowWindows()

EnumWindows(new PCallBack(FindWindows), 0);


private bool FindWindows(int handle, int lparam)

Console.WriteLine("showing");
ShowWindow(handle, (int)SW.SHOWMINIMIZED);
ShowWindow(handle, (int)SW.SHOWNORMAL);
Thread.Sleep(3000);

return true;


static void Main(string[] args)

ShowWindows();



This code literally shows every window EnumWindows can find even if they are not visible and task manager was never shown which proved to me that the problem has nothing to do with wrong handle.
This is how I find it by the way.



// the correct handle of Task Manager window
var handle = (int)Process.GetProcessesByName("taskmgr").FirstOrDefault().MainWindowHandle;


Basically this is my problem. Need help.










share|improve this question


























  • Show the code you are using if you want help.

    – LarsTech
    Mar 28 at 19:47











  • I just added some code I used to get to the conclusions stated above.

    – Santi6
    Mar 28 at 22:26











  • Task Manager seems like a special window. By the way, those parameters should be IntPtr.

    – LarsTech
    Mar 28 at 23:51











  • Of course that isn't possible, the virus writers would instantly exploit this. Just one of the basic goodies we get from UAC, Task Manager always runs elevated.

    – Hans Passant
    Mar 29 at 21:53











  • Absolutely no workaround available?

    – Santi6
    Apr 1 at 9:40

















-1















I need to show Task Manager app programatically, maximize it and minimize it as any other window but there is a problem and it simply doesn't respond to ShowWindow(int hWnd, int nCmdShow).



I am pretty sure I use the correct handle because I enumerated all of the windows with EnumWindows(PCallBack callback, int lParam) and the only window that didn't respond was the task manager window with title process.MainWindowTitle = "Task Manager", I even manually found its handle using spy++ but it still doesn't respond to SW_SHOWNORMAL or any other nCmdShow parameter. I tried running apps as administrator to see if it has something to do with the issue but they kept behaving like normal when proper handle was given to ShowWindow function;



private delegate bool PCallBack(int hWnd, int lParam);

private static void ShowWindows()

EnumWindows(new PCallBack(FindWindows), 0);


private bool FindWindows(int handle, int lparam)

Console.WriteLine("showing");
ShowWindow(handle, (int)SW.SHOWMINIMIZED);
ShowWindow(handle, (int)SW.SHOWNORMAL);
Thread.Sleep(3000);

return true;


static void Main(string[] args)

ShowWindows();



This code literally shows every window EnumWindows can find even if they are not visible and task manager was never shown which proved to me that the problem has nothing to do with wrong handle.
This is how I find it by the way.



// the correct handle of Task Manager window
var handle = (int)Process.GetProcessesByName("taskmgr").FirstOrDefault().MainWindowHandle;


Basically this is my problem. Need help.










share|improve this question


























  • Show the code you are using if you want help.

    – LarsTech
    Mar 28 at 19:47











  • I just added some code I used to get to the conclusions stated above.

    – Santi6
    Mar 28 at 22:26











  • Task Manager seems like a special window. By the way, those parameters should be IntPtr.

    – LarsTech
    Mar 28 at 23:51











  • Of course that isn't possible, the virus writers would instantly exploit this. Just one of the basic goodies we get from UAC, Task Manager always runs elevated.

    – Hans Passant
    Mar 29 at 21:53











  • Absolutely no workaround available?

    – Santi6
    Apr 1 at 9:40













-1












-1








-1








I need to show Task Manager app programatically, maximize it and minimize it as any other window but there is a problem and it simply doesn't respond to ShowWindow(int hWnd, int nCmdShow).



I am pretty sure I use the correct handle because I enumerated all of the windows with EnumWindows(PCallBack callback, int lParam) and the only window that didn't respond was the task manager window with title process.MainWindowTitle = "Task Manager", I even manually found its handle using spy++ but it still doesn't respond to SW_SHOWNORMAL or any other nCmdShow parameter. I tried running apps as administrator to see if it has something to do with the issue but they kept behaving like normal when proper handle was given to ShowWindow function;



private delegate bool PCallBack(int hWnd, int lParam);

private static void ShowWindows()

EnumWindows(new PCallBack(FindWindows), 0);


private bool FindWindows(int handle, int lparam)

Console.WriteLine("showing");
ShowWindow(handle, (int)SW.SHOWMINIMIZED);
ShowWindow(handle, (int)SW.SHOWNORMAL);
Thread.Sleep(3000);

return true;


static void Main(string[] args)

ShowWindows();



This code literally shows every window EnumWindows can find even if they are not visible and task manager was never shown which proved to me that the problem has nothing to do with wrong handle.
This is how I find it by the way.



// the correct handle of Task Manager window
var handle = (int)Process.GetProcessesByName("taskmgr").FirstOrDefault().MainWindowHandle;


Basically this is my problem. Need help.










share|improve this question
















I need to show Task Manager app programatically, maximize it and minimize it as any other window but there is a problem and it simply doesn't respond to ShowWindow(int hWnd, int nCmdShow).



I am pretty sure I use the correct handle because I enumerated all of the windows with EnumWindows(PCallBack callback, int lParam) and the only window that didn't respond was the task manager window with title process.MainWindowTitle = "Task Manager", I even manually found its handle using spy++ but it still doesn't respond to SW_SHOWNORMAL or any other nCmdShow parameter. I tried running apps as administrator to see if it has something to do with the issue but they kept behaving like normal when proper handle was given to ShowWindow function;



private delegate bool PCallBack(int hWnd, int lParam);

private static void ShowWindows()

EnumWindows(new PCallBack(FindWindows), 0);


private bool FindWindows(int handle, int lparam)

Console.WriteLine("showing");
ShowWindow(handle, (int)SW.SHOWMINIMIZED);
ShowWindow(handle, (int)SW.SHOWNORMAL);
Thread.Sleep(3000);

return true;


static void Main(string[] args)

ShowWindows();



This code literally shows every window EnumWindows can find even if they are not visible and task manager was never shown which proved to me that the problem has nothing to do with wrong handle.
This is how I find it by the way.



// the correct handle of Task Manager window
var handle = (int)Process.GetProcessesByName("taskmgr").FirstOrDefault().MainWindowHandle;


Basically this is my problem. Need help.







c# pinvoke taskmanager user32






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 29 at 19:15







Santi6

















asked Mar 28 at 15:03









Santi6Santi6

11 bronze badge




11 bronze badge















  • Show the code you are using if you want help.

    – LarsTech
    Mar 28 at 19:47











  • I just added some code I used to get to the conclusions stated above.

    – Santi6
    Mar 28 at 22:26











  • Task Manager seems like a special window. By the way, those parameters should be IntPtr.

    – LarsTech
    Mar 28 at 23:51











  • Of course that isn't possible, the virus writers would instantly exploit this. Just one of the basic goodies we get from UAC, Task Manager always runs elevated.

    – Hans Passant
    Mar 29 at 21:53











  • Absolutely no workaround available?

    – Santi6
    Apr 1 at 9:40

















  • Show the code you are using if you want help.

    – LarsTech
    Mar 28 at 19:47











  • I just added some code I used to get to the conclusions stated above.

    – Santi6
    Mar 28 at 22:26











  • Task Manager seems like a special window. By the way, those parameters should be IntPtr.

    – LarsTech
    Mar 28 at 23:51











  • Of course that isn't possible, the virus writers would instantly exploit this. Just one of the basic goodies we get from UAC, Task Manager always runs elevated.

    – Hans Passant
    Mar 29 at 21:53











  • Absolutely no workaround available?

    – Santi6
    Apr 1 at 9:40
















Show the code you are using if you want help.

– LarsTech
Mar 28 at 19:47





Show the code you are using if you want help.

– LarsTech
Mar 28 at 19:47













I just added some code I used to get to the conclusions stated above.

– Santi6
Mar 28 at 22:26





I just added some code I used to get to the conclusions stated above.

– Santi6
Mar 28 at 22:26













Task Manager seems like a special window. By the way, those parameters should be IntPtr.

– LarsTech
Mar 28 at 23:51





Task Manager seems like a special window. By the way, those parameters should be IntPtr.

– LarsTech
Mar 28 at 23:51













Of course that isn't possible, the virus writers would instantly exploit this. Just one of the basic goodies we get from UAC, Task Manager always runs elevated.

– Hans Passant
Mar 29 at 21:53





Of course that isn't possible, the virus writers would instantly exploit this. Just one of the basic goodies we get from UAC, Task Manager always runs elevated.

– Hans Passant
Mar 29 at 21:53













Absolutely no workaround available?

– Santi6
Apr 1 at 9:40





Absolutely no workaround available?

– Santi6
Apr 1 at 9:40












1 Answer
1






active

oldest

votes


















0

















it simply doesn't respond to ShowWindow(int hWnd, int nCmdShow).




I tested on Windows 10 and this works for me :



  • Manifest file with level="requireAdministrator"


  • Test :



    IntPtr hWndTarget = FindWindow("TaskManagerWindow", null);
    bool bRet = ShowWindow(hWndTarget, SW_SHOWMINIMIZED);


    with declarations :



    [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)]
    public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
    public const int SW_HIDE = 0;
    public const int SW_SHOWNORMAL = 1;
    public const int SW_SHOWMINIMIZED = 2;
    public const int SW_SHOWMAXIMIZED = 3;






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400855%2fshowwindow-is-unable-to-show-or-minimize-task-manager%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0

















    it simply doesn't respond to ShowWindow(int hWnd, int nCmdShow).




    I tested on Windows 10 and this works for me :



    • Manifest file with level="requireAdministrator"


    • Test :



      IntPtr hWndTarget = FindWindow("TaskManagerWindow", null);
      bool bRet = ShowWindow(hWndTarget, SW_SHOWMINIMIZED);


      with declarations :



      [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
      public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

      [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)]
      public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
      public const int SW_HIDE = 0;
      public const int SW_SHOWNORMAL = 1;
      public const int SW_SHOWMINIMIZED = 2;
      public const int SW_SHOWMAXIMIZED = 3;






    share|improve this answer





























      0

















      it simply doesn't respond to ShowWindow(int hWnd, int nCmdShow).




      I tested on Windows 10 and this works for me :



      • Manifest file with level="requireAdministrator"


      • Test :



        IntPtr hWndTarget = FindWindow("TaskManagerWindow", null);
        bool bRet = ShowWindow(hWndTarget, SW_SHOWMINIMIZED);


        with declarations :



        [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
        public const int SW_HIDE = 0;
        public const int SW_SHOWNORMAL = 1;
        public const int SW_SHOWMINIMIZED = 2;
        public const int SW_SHOWMAXIMIZED = 3;






      share|improve this answer



























        0














        0










        0










        it simply doesn't respond to ShowWindow(int hWnd, int nCmdShow).




        I tested on Windows 10 and this works for me :



        • Manifest file with level="requireAdministrator"


        • Test :



          IntPtr hWndTarget = FindWindow("TaskManagerWindow", null);
          bool bRet = ShowWindow(hWndTarget, SW_SHOWMINIMIZED);


          with declarations :



          [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
          public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

          [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)]
          public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
          public const int SW_HIDE = 0;
          public const int SW_SHOWNORMAL = 1;
          public const int SW_SHOWMINIMIZED = 2;
          public const int SW_SHOWMAXIMIZED = 3;






        share|improve this answer














        it simply doesn't respond to ShowWindow(int hWnd, int nCmdShow).




        I tested on Windows 10 and this works for me :



        • Manifest file with level="requireAdministrator"


        • Test :



          IntPtr hWndTarget = FindWindow("TaskManagerWindow", null);
          bool bRet = ShowWindow(hWndTarget, SW_SHOWMINIMIZED);


          with declarations :



          [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
          public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

          [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)]
          public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
          public const int SW_HIDE = 0;
          public const int SW_SHOWNORMAL = 1;
          public const int SW_SHOWMINIMIZED = 2;
          public const int SW_SHOWMAXIMIZED = 3;







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 18 at 10:05









        CastorixCastorix

        1,0731 gold badge6 silver badges6 bronze badges




        1,0731 gold badge6 silver badges6 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















            draft saved

            draft discarded















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400855%2fshowwindow-is-unable-to-show-or-minimize-task-manager%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현