It seems, that starting tor.exe is hardcoded in a way to opening a window from outside.
At least, when I changed middlemouse.openNewWindow false → true, clicking on the Tor Browser icon with the wheel started showing the “is-already-running” message.
Here’s my solution I’m currently fine with (kind of). Hope, it helps for others who need the same behavior (returning the New Window feature from Firefox to the taskbar).
- Install AutoIt. It’s a pretty good scripting language/interpreter. Saves your time, though you can write the same in C/C++/C#.
- Create
start-tor.au3:
#include <WinAPI.au3>
#Include <WindowsConstants.au3> ; Some of them are not needed
#include <GUIConstantsEx.au3> ; I tried to disable Close (x)
#include <WinAPISysWin.au3> ; with CS_NOCLOSE -- to no avail
#include <WindowsStylesConstants.au3>
Opt("WinTitleMatchMode", 2) ; Substring mode for finding windows
Run("C:\Bin\Tor\Browser\firefox.exe")
Sleep(1000) ; It will be "restored" (unminimized)
Local $hWnd = WinWait("Tor Browser")
If IsHWnd($hWnd) Then
; Move to the secondary monitor
WinMove($hWnd, "", -1050, -400, 1000, 1000)
WinSetState($hWnd, "", @SW_MAXIMIZE)
WinSetTitle($hWnd, "", "MainTor")
WinSetState($hWnd, "", @SW_MINIMIZE)
EndIf
This will be the main window. We rename it from “Tor Browser” → “MainTor” for future using as an anchor. It sits minimized silently and provides access to the tor.exe settings. Create a shortcut to the file and place it to the Startup folder, so it starts on login.
- Create
tor-new-window.au3:
#include <WinAPI.au3>
$hWnd = WinActivate("MainTor")
If IsHWnd($hWnd) Then
Send("^n")
Local $hNewWnd = WinWait("[TITLE:Tor Browser; CLASS:MozillaWindowClass]")
If IsHWnd($hNewWnd) Then
WinMove($hNewWnd, "", 30, 50, 1800, 900)
WinSetState($hNewWnd, "", @SW_MAXIMIZE)
EndIf
WinSetState($hWnd, "", @SW_MINIMIZE)
Else ; If not found the window, start new Tor Browser instance
Run("D:\Bin\Scripts\AutoIt\start-tor.au3")
EndIf
It finds the anchor (main) window, activates it, sends Ctrl + N, finds a newly opened window, move it to the primary monitor. If the anchor window is not found (Tor Browser is not running), it starts it anew.
- Create a shortcut to
tor-new-window.au3. (It’s a .lnk file).
- Change its icon to the New Window icon from
firefox.exe.
- Open its properties. Add
explorer.exe (space-concluded) at the beginning of the target field. Now click the Right Mouse Button and Pin to taskbar (without changing the target you are not allowed to pin a shortcut to the taskbar).
- Click it every time you need a new window.
Damn, a lot of time and engineering for what could be done, if Tor Browser developers didn’t turn off the already working feature.
UPD. The window class MUST be specified, otherwise another window (preview) is found sometimes.