Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Shell 

Open the Last Active Window

In Windows 7 and later version of Windows OS, when you click a Taskbar icon and more than one instance of a program is running, you will be presented with thumbnails of all the running instances.

[Image: Ek2XFqU.png]


You can change this behavior with this batch script so that clicking the icon automatically displays the last running instance on the desktop (you can use Alt+Tab to switch to the others).


Code
:: This batch script created by FreeBooter

@Echo Off & Color 1A

Cd %systemroot%\system32

REM  --> Check for permissions
Reg query "HKU\S-1-5-19\Environment"
REM --> If error flag set, we do not have admin.
if %errorlevel% NEQ 0 (
ECHO                 **************************************
ECHO                  Running Admin shell... Please wait...
ECHO                 **************************************

   goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
   echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
   set params = "%*:"=""
   echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

   "%temp%\getadmin.vbs"
   del "%temp%\getadmin.vbs"
   exit /B


:gotAdmin

Cls & Mode CON  LINES=11 COLS=70 & Color 0D & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo       ノヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘサ
Echo       コ Do You Want To Open Last Active Program Window (Y/N)? コ  
Echo       ネヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘシ
Echo.
Echo.


Set /p input= RESPONSE:
If /i  Not %input%==Y (Goto :_Ex) Else (Goto :_Start)

:_Ex
If /i Not %input%==N  (Goto :EOF) Else (Goto :_RegRestore)



:_Start

Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "LastActiveClick" /t REG_DWORD /d "1" /f

Cls & Mode CON  LINES=11 COLS=60 & Color 0D & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo       ノヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘサ
Echo       コ Open Last Active Program Window Enabled コ  
Echo       ネヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘシ
Echo.
Echo.

Taskkill /im Explorer.exe /f >Nul

Start Explorer.exe

ping -n 8 localhost >Nul
Exit


:_RegRestore

Reg Query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "LastActiveClick"

If %ErrorLevel% EQU 1 Goto :EOF

Reg Delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "LastActiveClick" /f


Cls & Mode CON  LINES=11 COLS=60 & Color 0D & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo       ノヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘサ
Echo       コ Open Last Active Program Window Disabled コ  
Echo       ネヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘシ
Echo.
Echo.

Taskkill /im Explorer.exe /f >Nul

Start Explorer.exe

ping -n 8 localhost >nul
Exit
Nicely done, that is pretty neat probably edit the registry for the right click context menu and make this a thing as i can see this being useful
thx m8
"You can pick your friends, you can pick your nose, but you can't pick your friend's nose, because they usually get mad, butt we all know there hiding secrets in there" -James Bond
(May 5, 2018 12:07 PM)SlowMehMo Wrote:  Nicely done, that is pretty neat probably edit the registry for the right click context menu and make this a thing as i can see this being useful
thx m8
Thank you very much!
Very useful time saving batch script, thanks!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by SkidyMay 1, 2017 03:56 AM 3 197 May 1, 2017 03:56 AM
Last Post: Skidy
[Python] by Solar_FlareDec 30, 2016 04:37 PM 4 159 Dec 30, 2016 04:37 PM
Last Post: Solar_Flare
[.NET] by MattixioApr 26, 2015 01:26 PM 6 152 Apr 26, 2015 01:26 PM
Last Post: He B TeMy