Hiding Console2 if it is active, activating or starting a new process if it is not

0

2

This is a Community Wiki based on a question that was deleted right before I was able to post a solution. The user's AutoHotkey script had a few mistakes in it, so I wrote one that fixes them. The problem they were facing was that a new Console2 process was started every time, instead of activating a process that was set to the background. My solution is below...

iglvzx

Posted 2012-05-23T17:41:40.470

Reputation: 21 611

Answers

1

Are you running Console2 as an administrator? If so, certain AutoHotkey commands performed on or in Console2's window may be ignored. You can get around this by running the AHK script as an administrator, too.

One important thing to realize: you had a hotkey mapped more than once, so AHK would run through each method in order, from top to bottom. I fixed your logic and changed a couple of things. This should work! :)

Note: This script can easily be adapted for other programs. Just change the IfWinExist, WinMove, and Run commands.

#c::
    DetectHiddenWindows, On

    IfWinExist, ahk_class Console_2_Main
    {
        IfWinActive
        {
            WinMinimize
            WinHide
        }
        else
        {
            WinShow
            WinActivate
            WinMove, 100, 50
        }
    }
    else
    {
        Run, "%UserProfile%\Console2\Console.exe"
    }

    return

iglvzx

Posted 2012-05-23T17:41:40.470

Reputation: 21 611