I really like using SciTE4AutoHotkey, and I wish it had this feature. Since it doesn't, I wrote a script that makes a second SciTE4AutoHotkey window behave much like a second pane of the same window. It does so by doing the following:
- the second pane is created within the original main window area
- you can move the "split" between the two panes by dragging it
- both panes resize/move together when either is resized/moved (i.e., they stay linked)
- when one pane is activated, the other also moves in front of any other windows
- when the main window is minimized or restored, the second pane minimizes/restores also
- when you maximize the main window, both the main window and the second pane fill the screen
- when the second pane is closed, the main window takes the size that both did together
- when the main window is closed, the second pane closes as well (if open files are saved)
- the second pane doesn't have a title bar or taskbar icon
Spoiler
Note: Edits made in a second SciTE4AutoHotkey window containing the same file (whether using this script or not), do not appear in the other window until the file is saved. Save your edits in one window before making edits in the other window if you choose to edit the same file in both windows. You may wish to use the second window mainly for viewing and searching without losing your place in the main window.Added feature: Support for TillaGoto for the second pane. Additional windows in SciTE4AutoHotkey don't have the TillaGoto controls, but this script adds functionality that allows for the second pane created by this script to make use of TillaGoto.
- Both panes must be showing the same file.
- If the second pane is active, press F12 once to activate the main window, and press it again to select TillaGoto. If the main window is already active, just press F12 once as usual.
- Type the beginning of the function/label/hotkey (FLH) until the desired item is the first (or only) displayed item
- Press F11, and the the script will automatically perform a "Find" and move to the desired FLH in the second pane
Code: Select all
; -------------------------------------------------------------
; Second Edit Pane for SciTE4AutoHotkey
; boiler at ahkscript.org
; -------------------------------------------------------------
; Causes a second SciTE window to behave similar to a second
; edit pane within the main window, similar to NotePad++.
; Run this script before opening a second window, and keep it
; open during your SciTE4AutoHotkey editing session.
; -------------------------------------------------------------
; Thanks to:
; fincs at ahkscript.org for SciTE4AutoHotkey
; Joetazz at ahkscript.org for SciTE new window properties
; maul.esel at autohotkey.com for removing taskbar icons code
; -------------------------------------------------------------
/*
To add the ability to create a second window via menu selection or
shortcut key, add the following to the SciTEUser.properties file:
# Open file in a new window
command.name.17.*=Open in New Window
command.mode.17.*=subsystem:2
command.shortcut.17.*=Ctrl+Shift+N
command.17.*="$(SciteDefaultHome)\SciTE.exe" -check.if.already.open=0 -save.session=0 "$(FilePath)"
# Open a new window
command.name.18.*=Open New Window
command.mode.18.*=subsystem:2,savebefore:no
command.shortcut.18.*=Alt+Shift+N
command.18.*="$(SciteDefaultHome)\SciTE.exe" -check.if.already.open=0 -save.session=0
*/
#SingleInstance, Force
#Persistent
SetTitleMatchMode, 2
SetWinDelay, 1
SysGet, SM_CXFRAME, 32
SysGet, SM_CYFRAME, 33
IID_ITaskbarList := "{56FDF342-FD6D-11d0-958A-006097C9A090}"
CLSID_TaskbarList := "{56FDF344-FD6D-11d0-958A-006097C9A090}"
; set LastCount with the initial number of SciTE4AutoHotkey windows:
WinGet, LastCount, Count, - SciTE4AutoHotkey ahk_exe SciTE.exe
SetTimer, WindowUpdate, 50
return
F11::
if (WinExist("TillaGoto.ahk")) and (WinExist(ahk_id%SecondID%))
{
ControlGet, List, List,, Listbox1, TillaGoto.ahk
StringSplit, ListItems, List, `n
StringReplace, ListItems1, ListItems1, )
WinClose, TillaGoto.ahk
WinActivate, ahk_id%SecondID%
WinMenuSelectItem, ahk_id%SecondID%,, Search, Find...
Send, %ListItems1%
ControlClick, Button2, ahk_id%SecondID%
ControlFocus, Scintilla1, ahk_id%SecondID%
Send, {Home}
}
return
#if WinActive("ahk_id" . SecondID)
F12::WinActivate, ahk_id%MainID%
WindowUpdate:
WinGet, NewCount, Count, % " SciTE4AutoHotkey" "ahk_exe SciTE.exe"
if (LastCount = 1)
{
if (NewCount = 1)
{
WinGet, MainID, ID, % " SciTE4AutoHotkey" "ahk_exe SciTE.exe"
WinGetPos, MainX, MainY, MainW, MainH, ahk_id %MainID%
WinSet, Style, +0xC00000, ahk_id%SecondID%
}
else if (NewCount = 2) ; got here if new window appeared
{
WinGet, MainState, MinMax, ahk_id %MainID%
if (MainState = 1)
{
WinRestore, ahk_id %MainID%
WinMove, ahk_id %MainID%,, MainX + SM_CXFRAME, MainY + SM_CYFRAME, MainW - 2 * SM_CXFRAME, MainH - 2 * SM_CYFRAME
}
WinGet, WinList, List, % " SciTE4AutoHotkey" "ahk_exe SciTE.exe"
Loop, %WinList%
if (WinList%A_Index% != MainID)
{
SecondID := WinList%A_Index%
WinGetPos, MainX, MainY, MainW, MainH, ahk_id %MainID%
LastMainX := MainX
LastMainY := MainY
LastMainW := MainW
LastMainH := MainH * 0.6
LastSecondW := MainW
LastSecondH := MainH * 0.4
WinMove, ahk_id%MainID%,,,,, LastMainH
WinMove, ahk_id%SecondID%,, MainX, MainY + LastMainH, MainW, LastSecondH
LastSecondX := MainX
LastSecondY := MainY + LastSecondH
LastSecondW := MainW
WinSet, Style, -0xC00000, ahk_id%SecondID%
tbl := ComObjCreate(CLSID_TaskbarList, IID_ITaskbarList)
DllCall(NumGet(NumGet(tbl+0), 3*A_PtrSize), "ptr", tbl)
DllCall(NumGet(NumGet(tbl+0), 5*A_PtrSize), "ptr", tbl, "ptr", SecondID)
}
}
}
if (LastCount >= 2)
{
if (NewCount = 1) ; got here if 2nd pane was closed
{
WinMove, % " SciTE4AutoHotkey" "ahk_exe SciTE.exe",, MainX, MainY, MainW, MainH
IfWinNotExist, ahk_id%MainID%
WinClose, ahk_id%SecondID%
}
if (NewCount >= 2) ; got here if the second pane was opened and is still open
{
Gosub, Sync
}
}
LastCount := NewCount
return
Sync:
{
WinGet, MainState, MinMax, ahk_id%MainID%
WinGet, SecondState, MinMax, ahk_id%SecondID%
if (MainState = 1)
{
WinGetPos, MX, MY, MW, MH, ahk_id%MainID%
WinRestore, ahk_id%MainID%
LastMainX := MX + SM_CXFRAME
LastMainY := MY + SM_CYFRAME
LastMainW := MW - 2 * SM_CXFRAME
LastMainH := MH - 2 * SM_CYFRAME - LastSecondH
LastSecondX := LastMainX
LastSecondY := LastMainY + LastMainH
LastSecondW := LastMainW
MainX := LastMainX
MainY := LastMainY
MainW := LastMainW
MainH := LastMainH + LastSecondH
WinMove, ahk_id%MainID%,, LastMainX, LastMainY, LastMainW, LastMainH
WinMove, ahk_id%SecondID%,, LastSecondX, LastSecondY, LastSecondW, LastSecondH
}
if (MainState = -1) or (SecondState = -1)
{
if (MainState != -1) and (SecondState = -1)
WinRestore, ahk_id%SecondID%
if (MainState = -1) and (SecondState != -1)
WinMinimize, ahk_id%SecondID%
}
else
{
WinGetPos, NewMainX, NewMainY, NewMainW, NewMainH, ahk_id %MainID%
WinGetPos, NewSecondX, NewSecondY, NewSecondW, NewSecondH, ahk_id %SecondID%
; main window resized but not moved:
if ((NewMainW != LastMainW) or (NewMainH != LastMainH)) and (NewMainX = LastMainX) and (NewMainY = LastMainY)
{
WinMove, ahk_id%SecondID%,,, NewMainY + NewMainH, NewMainW, LastSecondH + LastMainH - NewMainH
LastSecondY := NewMainY + NewMainH
LastSecondH := LastSecondH + LastMainH - NewMainH
LastMainW := NewMainW
LastMainH := NewMainH
MainW := NewMainW
MainH := NewMainH + LastSecondH
}
; second pane resized but not moved:
else if ((NewSecondW != LastSecondW) or (NewSecondH != LastSecondH)) and (NewSecondX = LastSecondX) and (NewSecondY = LastSecondY)
{
WinMove, ahk_id%MainID%,,,, NewSecondW
LastMainW := NewSecondW
LastSecondW := NewSecondW
LastSecondH := NewSecondH
MainW := NewSecondW
MainH := LastMainH + NewSecondH
}
; main window moved but not resized:
else if ((NewMainX != LastMainX) or (NewMainY != LastMainY)) and (NewMainW = LastMainW) and (NewMainH = LastMainH)
{
WinMove, ahk_id%SecondID%,, NewMainX, NewMainY + NewMainH
LastMainX := NewMainX
LastMainY := NewMainY
LastSecondX := NewMainX
LastSecondY := NewMainY + NewMainH
MainX := NewMainX
MainY := NewMainY
}
; main window resized and moved:
else if ((NewMainX != LastMainX) or (NewMainY != LastMainY)) and ((NewMainW != LastMainW) or (NewMainH != LastMainH))
{
WinMove, ahk_id%SecondID%,, NewMainX, NewMainY + NewMainH, NewMainW, LastSecondH
LastSecondX := NewMainX
LastSecondY := NewMainY + NewMainH
LastSecondW := NewMainW
LastMainX := NewMainX
LastMainY := NewMainY
LastMainW := NewMainW
LastMainH := NewMainH
MainX := NewMainX
MainY := NewMainY
MainW := NewMainW
MainH := NewMainH + LastSecondH
}
; second pane resized and moved from bottom:
else if (NewSecondY = LastSecondY) and (NewSecondH != LastSecondH)
{
WinMove, ahk_id%MainID%,, NewSecondX,, NewSecondW
LastSecondX := NewSecondX
LastSecondY := NewSecondY
LastSecondW := NewSecondW
LastSecondH := NewSecondH
LastMainX := NewSecondX
MainX := NewSecondX
MainW := NewSecondW
MainH := LastMainH + NewSecondH
}
; second pane resized and moved from top:
else if ((NewSecondX != LastSecondX) or (NewSecondY != LastSecondY)) and ((NewSecondW != LastSecondW) or (NewSecondH != LastSecondH))
{
WinMove, ahk_id%MainID%,, NewSecondX,, NewSecondW, LastMainH + LastSecondH - NewSecondH
LastSecondX := NewSecondX
LastSecondY := NewSecondY
LastMainX := NewSecondX
MainX := NewSecondX
MainW := NewSecondW
}
}
}
IfWinActive, ahk_id%MainID%
{
DllCall("SetWindowPos", "uint", SecondID, "uint", MainID, "uint", 0, "uint", 0, "uint", 0, "uint", 0, "uint", 19) ;SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE
}
IfWinActive, ahk_id%SecondID%
{
DllCall("SetWindowPos", "uint", MainID, "uint", SecondID, "uint", 0, "uint", 0, "uint", 0, "uint", 0, "uint", 19) ;SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE
}
return