diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2cf373 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.cmd +*.exe \ No newline at end of file diff --git a/README.md b/README.md index 9dc8625..f6bf366 100644 --- a/README.md +++ b/README.md @@ -1,79 +1,65 @@ -#cPuTTY -A real cluster solution for PuTTY - -### Contents -[What the...?](#what-the) -[Features](#features) -[Installing cPuTTY](#installing-cputty) -[Working with cPuTTY](#working-with-cputty) -[Shortcuts](#shortcuts) -[Extended usage](#extended-usage) -[Troubleshooting](#troubleshooting) -[Acknowledgements](#acknowledgements) -[License](#license) +#cPuTTY +A real cluster solution for PuTTY. +Furter development of: +- https://github.com/deanhouseholder/PuTTY-Keystroke-Sender +- https://github.com/dprokscha/cputty ### What the...? -Are you one of the poor who have to make the same changes to a file on multiple servers with PuTTY? You don't want to do this manually on each server? You are tired of not working cluster solutions for PuTTY? You are still searching a tool which is a real cluster for PuTTY? Then you should give cPuTTY a try, your search might be over. cPuTTY recognises all keyboard and mouse events which were sent to a PuTTY window and forwards them to all other clustered PuTTY windows. Type character by character once for multiple windows - in real-time! +Are you one of the poor who have to make the same changes on multiple servers with PuTTY? You don't want to do this manually on each server? You are tired of not working cluster solutions for PuTTY? You are still searching a tool which is a real cluster for PuTTY? Then you should give cPuTTY a try, your search might be over. cPuTTY recognises all keyboard and mouse events which were sent to a PuTTY window and forwards them to all other clustered PuTTY windows. Type character by character once for multiple windows - in real-time! ### Features -* Add PuTTY windows to a cluster, remove them from a cluster or kill the whole cluster with shortcuts +* Add PuTTY windows to a numbered cluster, remove them from a cluster or kill the whole cluster with shortcuts * All keyboard and mouse events within a cluster are forwarded to all other clustered PuTTY windows * Each key and shortcut on your keyboard - even mouse commands (right-click only) - are supported -* PuTTY forks like FuTTY, KiTTY, PieTTY and TuTTY are also supported +* PuTTY forks like FuTTY, KiTTY, PieTTY and TuTTY are supported. Also including MinTTY. +* Tile PuTTY windows over (multiple) monitors * Fully support for UNIX commands like ``vi`` * No additional windows are needed - simply use your existing PuTTY windows -* Easy to use, works like expected :smile: +* It should work with Windows Vista, Windows 7 and later -### Installing cPuTTY -* Download the attached ZIP file of [the latest release](https://github.com/dprokscha/cputty/releases) -* Execute *cputty.exe* or *cputty_x64.exe* (for Windows 64-bit) -* That's all - cPuTTY is running now! +### Download +* Download compiled binary in [Releases](https://github.com/sepich/cputty/releases) section +* Or run from sources via [AutoHotKey](https://github.com/Lexikos/AutoHotkey_L) +* No installation needed -cPuTTY should work with Windows Vista, Windows 7 and later. +### Shortcuts +``Ctrl`` + ``Alt`` + ``1-4`` - Tile windows over 1-4 monitors +``Ctrl`` + ``Alt`` + ``5-0`` - Adds the active PuTTY window to a cluster group (see [extended usage](#extended-usage)) +``Ctrl`` + ``Alt`` + ``Page Down`` - Stop sending events to other windows +``Ctrl`` + ``Alt`` + ``Page Up`` - Resumes event sending +``Ctrl`` + ``Alt`` + ``Home`` - Brings all windows from all clusters to the top +``Ctrl`` + ``Alt`` + ``End`` - Removes windows from current cluster. Closes cPuTTY, if all clusters are empty. +``Win`` + ``W`` - Auto-enter saved text (password). On first run asks for the text +``Alt`` + ``G`` - Reload cPuTTY ### Working with cPuTTY -* Start cPuTTY -* Open multiple SHH connections with PuTTY -* Select a PuTTY window and press ``Ctrl`` + ``Alt`` + ``Page Up`` to add it to the cluster -* Add other PuTTY windows to the cluster as described above -* You can add all opened PuTTY windows to the cluster by pressing ``Ctrl`` + ``Alt`` + ``Insert`` -* Now type something in one of the windows you have added to the cluster and have a look to the other clustered windows -* Play a bit - everything you do in a clustered window will be imitated by the other clustered windows -* To remove a window from a cluster, press ``Ctrl`` + ``Alt`` + ``Page Down`` -* To kill the whole cluster, press ``Ctrl`` + ``Alt`` + ``End`` (if the cluster is empty, this shortcut closes cPuTTY) +* Start cPuTTY, it would sit in System Tray +* Open multiple PuTTY windows +* They would automatically added to default cluster (0), and have this number added to Window Title +* To tile/align all windows on one screen by pressing ``Ctrl`` + ``Alt`` + ``1`` +* To move some windows to another cluster, select the window and press ``Ctrl`` + ``Alt`` + ``5-9`` +* Now type something in one of the windows you have added to the cluster and have a look to the other windows of the same cluster +* To temporary stop replicating events, press ``Ctrl`` + ``Alt`` + ``Page Down``. System Tray icon would change to lock. To resume press ``Ctrl`` + ``Alt`` + ``Page Up`` * Press ``Ctrl`` + ``Alt`` + ``Home`` to bring all clustered windows to the top -### Shortcuts -``Ctrl`` + ``Alt`` + ``Page Up`` - Adds the active PuTTY window to the default cluster. -``Ctrl`` + ``Alt`` + ``0-9`` - Adds the active PuTTY window to a cluster group (see [extended usage](#extended-usage)) -``Ctrl`` + ``Alt`` + ``Page Down`` - Removes the active PuTTY window from its cluster. -``Ctrl`` + ``Alt`` + ``Insert`` - Adds all opened PuTTY windows to the default cluster. -``Ctrl`` + ``Alt`` + ``Home`` - Brings all windows from the default cluster to the top. -``Ctrl`` + ``Alt`` + ``End`` - Removes all windows from the cluster. Closes cPuTTY, if all clusters are empty. - ### Extended usage -cPuTTY allows up to ten grouped clusters. For example, open four PuTTY windows. For the first both press ``Ctrl`` + ``Alt`` + ``1``, for the last both ``Ctrl`` + ``Alt`` + ``2``. You have created two standalone clusters. By opening more PuTTY windows and pressing ``Ctrl`` + ``Alt`` + ``0-9`` you can easily extend your clusters. Please note, that ``0`` is the default cluster. This means, ``Ctrl`` + ``Alt`` + ``Page Up`` and ``Ctrl`` + ``Alt`` + ``0`` are equal. If a PuTTY window is already clustered, you can move it with ``Ctrl`` + ``Alt`` + ``0-9`` to any other cluster. While no PuTTY window is active, press ``Ctrl`` + ``Alt`` + ``0-9`` to bring your clusters to the top. +cPuTTY allows up to six grouped clusters. For example, open four PuTTY windows. For the first both press ``Ctrl`` + ``Alt`` + ``9``, for the last both ``Ctrl`` + ``Alt`` + ``5``. You have created two standalone clusters. By opening more PuTTY windows and pressing ``Ctrl`` + ``Alt`` + ``5-0`` you can easily extend your clusters. Please note, that ``0`` is the default cluster. This means that newly opened windows would be automatically added to it. If a PuTTY window is already clustered, you can move it with ``Ctrl`` + ``Alt`` + ``5-0`` to any other cluster. While no PuTTY window is active, press ``Ctrl`` + ``Alt`` + ``5-0`` to bring your clusters to the top. ### Troubleshooting ##### My antivirus software detects cPuTTY as a virus. -Ignore it. It's a false positive. +AutoHotKey sometimes being marked as a virus. In case precompiled binary looks unsafe for you - run cPuTTY as ahk script. ##### How can I start cPuTTY automatically on windows startup? -Simply create a shortcut of *cputty.exe* (or *cputty_x64.exe*) and move it to the autostart folder located in the Windows start menu. -##### The right-click (pasting things from the clipboard) does not work. What I am doing wrong? -Due to technical reasons the right-click only works for active PuTTY windows. Please activate a PuTTY window before you right-click. +Simply create a shortcut of *cputty.exe* and move it to the autostart folder located in the Windows start menu. ##### How can I change the default shortcuts of cPuTTY? Feel free to [download the source](src/cputty.ahk) and to change it - it is all made with [AutoHotKey](https://github.com/Lexikos/AutoHotkey_L). ##### I have another question, bug or feature request. -Please use the [GitHub Issue Tracker](https://github.com/dprokscha/cputty/issues). +Please use the [GitHub Issue Tracker](https://github.com/sepich/cputty/issues). ### Acknowledgements -Special thanks goes to [Dean Householder](http://www.deanhouseholder.com/). Your [PuTTY Keystroke Sender](http://www.deanhouseholder.com/projects/putty-keystroke-sender/) and finally its [source](http://www.autohotkey.com/board/topic/84935-send-keystrokes-to-multiple-windows/?p=541210) inspired me to develop a improved version of your idea. - -### License -Copyright (c) 2015 Daniel Prokscha - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +Thanks to the original [dprokscha/cputty](https://github.com/dprokscha/cputty) and [deanhouseholder/PuTTY-Keystroke-Sender](https://github.com/deanhouseholder/PuTTY-Keystroke-Sender) +Changes are: +- Windows tiling/aligning +- Auto-enter saved text +- Fixed: Right click to non active window +- Fixed: Win- shortcuts leave typed in other windows +- Fixed: Shift-Ins paste correctly to all windows diff --git a/src/cputty.ahk b/src/cputty.ahk index 2c77614..1ab2405 100644 --- a/src/cputty.ahk +++ b/src/cputty.ahk @@ -1,15 +1,15 @@ ; Copyright (c) 2015 Daniel Prokscha -; +; ; Permission is hereby granted, free of charge, to any person obtaining a copy ; of this software and associated documentation files (the "Software"), to deal ; in the Software without restriction, including without limitation the rights ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ; copies of the Software, and to permit persons to whom the Software is ; furnished to do so, subject to the following conditions: -; +; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. -; +; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -18,14 +18,15 @@ ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ; THE SOFTWARE. +#Warn #NoEnv -#NoTrayIcon #Persistent #SingleInstance force #WinActivateForce GroupAdd, WindowGroup, ahk_class FuTTY GroupAdd, WindowGroup, ahk_class KiTTY +GroupAdd, WindowGroup, ahk_class mintty GroupAdd, WindowGroup, ahk_class PieTTY GroupAdd, WindowGroup, ahk_class PuTTY GroupAdd, WindowGroup, ahk_class TuTTY @@ -33,347 +34,548 @@ GroupAdd, WindowGroup, ahk_class TTYPLUSMAIN GroupAdd, WindowGroup, ahk_class PUTTYCS_WND_CLASS AltDown := 0 -Cluster := [] +Cluster := [] ; key=HWND, value=Cluster # class Keys { - ; Identifier := [SYSKEY, Extended, SC , VK ] - static SC001 := [0 , 0 , 0x00, 0x00], - static SC002 := [0 , 0 , 0x00, 0x00], - static SC003 := [0 , 0 , 0x00, 0x00], - static SC004 := [0 , 0 , 0x00, 0x00], - static SC005 := [0 , 0 , 0x00, 0x00], - static SC006 := [0 , 0 , 0x00, 0x00], - static SC007 := [0 , 0 , 0x00, 0x00], - static SC008 := [0 , 0 , 0x00, 0x00], - static SC009 := [0 , 0 , 0x00, 0x00], - static SC00A := [0 , 0 , 0x00, 0x00], - static SC00B := [0 , 0 , 0x00, 0x00], - static SC00C := [0 , 0 , 0x00, 0x00], - static SC00D := [0 , 0 , 0x00, 0x00], - static SC00E := [0 , 0 , 0x00, 0x00], - static SC00F := [0 , 0 , 0x00, 0x00], - static SC010 := [0 , 0 , 0x00, 0x00], - static SC011 := [0 , 0 , 0x00, 0x00], - static SC012 := [0 , 0 , 0x00, 0x00], - static SC013 := [0 , 0 , 0x00, 0x00], - static SC014 := [0 , 0 , 0x00, 0x00], - static SC015 := [0 , 0 , 0x00, 0x00], - static SC016 := [0 , 0 , 0x00, 0x00], - static SC017 := [0 , 0 , 0x00, 0x00], - static SC018 := [0 , 0 , 0x00, 0x00], - static SC019 := [0 , 0 , 0x00, 0x00], - static SC01A := [0 , 0 , 0x00, 0x00], - static SC01B := [0 , 0 , 0x00, 0x00], - static SC01C := [0 , 0 , 0x00, 0x00], - static SC01D := [0 , 0 , 0x00, 0x11], - static SC01E := [0 , 0 , 0x00, 0x00], - static SC01F := [0 , 0 , 0x00, 0x00], - static SC020 := [0 , 0 , 0x00, 0x00], - static SC021 := [0 , 0 , 0x00, 0x00], - static SC022 := [0 , 0 , 0x00, 0x00], - static SC023 := [0 , 0 , 0x00, 0x00], - static SC024 := [0 , 0 , 0x00, 0x00], - static SC025 := [0 , 0 , 0x00, 0x00], - static SC026 := [0 , 0 , 0x00, 0x00], - static SC027 := [0 , 0 , 0x00, 0x00], - static SC028 := [0 , 0 , 0x00, 0x00], - static SC029 := [0 , 0 , 0x00, 0x00], - static SC02A := [0 , 0 , 0x00, 0x10], - static SC02B := [0 , 0 , 0x00, 0x00], - static SC02C := [0 , 0 , 0x00, 0x00], - static SC02D := [0 , 0 , 0x00, 0x00], - static SC02E := [0 , 0 , 0x00, 0x00], - static SC02F := [0 , 0 , 0x00, 0x00], - static SC030 := [0 , 0 , 0x00, 0x00], - static SC031 := [0 , 0 , 0x00, 0x00], - static SC032 := [0 , 0 , 0x00, 0x00], - static SC033 := [0 , 0 , 0x00, 0x00], - static SC034 := [0 , 0 , 0x00, 0x00], - static SC035 := [0 , 0 , 0x00, 0x00], - static SC038 := [1 , 0 , 0x00, 0x12], - static SC039 := [0 , 0 , 0x00, 0x00], - static SC03A := [0 , 0 , 0x00, 0x00], - static SC03B := [0 , 0 , 0x00, 0x00], - static SC03C := [0 , 0 , 0x00, 0x00], - static SC03D := [0 , 0 , 0x00, 0x00], - static SC03E := [0 , 0 , 0x00, 0x00], - static SC03F := [0 , 0 , 0x00, 0x00], - static SC040 := [0 , 0 , 0x00, 0x00], - static SC041 := [0 , 0 , 0x00, 0x00], - static SC042 := [0 , 0 , 0x00, 0x00], - static SC043 := [0 , 0 , 0x00, 0x00], - static SC044 := [1 , 0 , 0x00, 0x00], - static SC046 := [0 , 0 , 0x00, 0x00], - static SC056 := [0 , 0 , 0x00, 0x00], - static SC057 := [0 , 0 , 0x00, 0x00], - static SC058 := [0 , 0 , 0x00, 0x00], - static SC070 := [0 , 0 , 0x00, 0x00], - static SC073 := [0 , 0 , 0x00, 0x00], - static SC077 := [0 , 0 , 0x00, 0x00], - static SC079 := [0 , 0 , 0x00, 0x00], - static SC07B := [0 , 0 , 0x00, 0x00], - static SC07E := [0 , 0 , 0x00, 0x00], - static SC11D := [0 , 1 , 0x00, 0x11], - static SC136 := [0 , 0 , 0x00, 0x10], - static SC138 := [0 , 1 , 0x00, 0x12], - static SC145 := [0 , 1 , 0x00, 0x00], - static SC15B := [0 , 1 , 0x00, 0x00], - static SC15C := [0 , 1 , 0x00, 0x00], - static SC15D := [0 , 1 , 0x00, 0x00], - static SC15E := [0 , 1 , 0x00, 0x00], - static SC15F := [0 , 1 , 0x00, 0x00], - static SC163 := [0 , 1 , 0x00, 0x00], - static Break := [0 , 0 , 0x45, 0x00], - static CtrlBreak := [0 , 1 , 0x00, 0x00], - static Delete := [0 , 1 , 0x00, 0x00], - static Down := [0 , 1 , 0x00, 0x00], - static End := [0 , 1 , 0x00, 0x00], - static Home := [0 , 1 , 0x00, 0x00], - static Insert := [0 , 1 , 0x00, 0x00], - static Left := [0 , 1 , 0x00, 0x00], - static Numpad0 := [0 , 0 , 0x00, 0x00], - static Numpad1 := [0 , 0 , 0x00, 0x00], - static Numpad2 := [0 , 0 , 0x00, 0x00], - static Numpad3 := [0 , 0 , 0x00, 0x00], - static Numpad4 := [0 , 0 , 0x00, 0x00], - static Numpad5 := [0 , 0 , 0x00, 0x00], - static Numpad6 := [0 , 0 , 0x00, 0x00], - static Numpad7 := [0 , 0 , 0x00, 0x00], - static Numpad8 := [0 , 0 , 0x00, 0x00], - static Numpad9 := [0 , 0 , 0x00, 0x00], - static NumpadAdd := [0 , 0 , 0x00, 0x00], - static NumpadClear := [0 , 0 , 0x00, 0x00], - static NumpadDel := [0 , 0 , 0x00, 0x00], - static NumpadDiv := [0 , 1 , 0x00, 0x00], - static NumpadDot := [0 , 0 , 0x00, 0x00], - static NumpadDown := [0 , 0 , 0x00, 0x00], - static NumpadEnd := [0 , 0 , 0x00, 0x00], - static NumpadEnter := [0 , 1 , 0x00, 0x00], - static NumpadHome := [0 , 0 , 0x00, 0x00], - static NumpadIns := [0 , 0 , 0x00, 0x00], - static NumpadLeft := [0 , 0 , 0x00, 0x00], - static NumpadMult := [0 , 0 , 0x00, 0x00], - static NumpadPgDn := [0 , 0 , 0x00, 0x00], - static NumpadPgUp := [0 , 0 , 0x00, 0x00], - static NumpadRight := [0 , 0 , 0x00, 0x00], - static NumpadSub := [0 , 0 , 0x00, 0x00], - static NumpadUp := [0 , 0 , 0x00, 0x00], - static Pause := [0 , 0 , 0x45, 0x00], - static PgDn := [0 , 1 , 0x00, 0x00], - static PgUp := [0 , 1 , 0x00, 0x00], - static PrintScreen := [0 , 1 , 0x00, 0x00], - static Right := [0 , 1 , 0x00, 0x00], - static Up := [0 , 1 , 0x00, 0x00] + ; Identifier := [SYSKEY, Extended, SC , VK ] + static SC001 := [0 , 0 , 0x00, 0x00], + static SC002 := [0 , 0 , 0x00, 0x00], + static SC003 := [0 , 0 , 0x00, 0x00], + static SC004 := [0 , 0 , 0x00, 0x00], + static SC005 := [0 , 0 , 0x00, 0x00], + static SC006 := [0 , 0 , 0x00, 0x00], + static SC007 := [0 , 0 , 0x00, 0x00], + static SC008 := [0 , 0 , 0x00, 0x00], + static SC009 := [0 , 0 , 0x00, 0x00], + static SC00A := [0 , 0 , 0x00, 0x00], + static SC00B := [0 , 0 , 0x00, 0x00], + static SC00C := [0 , 0 , 0x00, 0x00], + static SC00D := [0 , 0 , 0x00, 0x00], + static SC00E := [0 , 0 , 0x00, 0x00], + static SC00F := [0 , 0 , 0x00, 0x00], + static SC010 := [0 , 0 , 0x00, 0x00], + static SC011 := [0 , 0 , 0x00, 0x00], + static SC012 := [0 , 0 , 0x00, 0x00], + static SC013 := [0 , 0 , 0x00, 0x00], + static SC014 := [0 , 0 , 0x00, 0x00], + static SC015 := [0 , 0 , 0x00, 0x00], + static SC016 := [0 , 0 , 0x00, 0x00], + static SC017 := [0 , 0 , 0x00, 0x00], + static SC018 := [0 , 0 , 0x00, 0x00], + static SC019 := [0 , 0 , 0x00, 0x00], + static SC01A := [0 , 0 , 0x00, 0x00], + static SC01B := [0 , 0 , 0x00, 0x00], + static SC01C := [0 , 0 , 0x00, 0x00], + static SC01D := [0 , 0 , 0x00, 0x11], + static SC01E := [0 , 0 , 0x00, 0x00], + static SC01F := [0 , 0 , 0x00, 0x00], + static SC020 := [0 , 0 , 0x00, 0x00], + static SC021 := [0 , 0 , 0x00, 0x00], + static SC022 := [0 , 0 , 0x00, 0x00], + static SC023 := [0 , 0 , 0x00, 0x00], + static SC024 := [0 , 0 , 0x00, 0x00], + static SC025 := [0 , 0 , 0x00, 0x00], + static SC026 := [0 , 0 , 0x00, 0x00], + static SC027 := [0 , 0 , 0x00, 0x00], + static SC028 := [0 , 0 , 0x00, 0x00], + static SC029 := [0 , 0 , 0x00, 0x00], + static SC02A := [0 , 0 , 0x00, 0x10], + static SC02B := [0 , 0 , 0x00, 0x00], + static SC02C := [0 , 0 , 0x00, 0x00], + static SC02D := [0 , 0 , 0x00, 0x00], + static SC02E := [0 , 0 , 0x00, 0x00], + static SC02F := [0 , 0 , 0x00, 0x00], + static SC030 := [0 , 0 , 0x00, 0x00], + static SC031 := [0 , 0 , 0x00, 0x00], + static SC032 := [0 , 0 , 0x00, 0x00], + static SC033 := [0 , 0 , 0x00, 0x00], + static SC034 := [0 , 0 , 0x00, 0x00], + static SC035 := [0 , 0 , 0x00, 0x00], + static SC038 := [1 , 0 , 0x00, 0x12], + static SC039 := [0 , 0 , 0x00, 0x00], + static SC03A := [0 , 0 , 0x00, 0x00], + static SC03B := [0 , 0 , 0x00, 0x00], + static SC03C := [0 , 0 , 0x00, 0x00], + static SC03D := [0 , 0 , 0x00, 0x00], + static SC03E := [0 , 0 , 0x00, 0x00], + static SC03F := [0 , 0 , 0x00, 0x00], + static SC040 := [0 , 0 , 0x00, 0x00], + static SC041 := [0 , 0 , 0x00, 0x00], + static SC042 := [0 , 0 , 0x00, 0x00], + static SC043 := [0 , 0 , 0x00, 0x00], + static SC044 := [1 , 0 , 0x00, 0x00], + static SC046 := [0 , 0 , 0x00, 0x00], + static SC056 := [0 , 0 , 0x00, 0x00], + static SC057 := [0 , 0 , 0x00, 0x00], + static SC058 := [0 , 0 , 0x00, 0x00], + static SC070 := [0 , 0 , 0x00, 0x00], + static SC073 := [0 , 0 , 0x00, 0x00], + static SC077 := [0 , 0 , 0x00, 0x00], + static SC079 := [0 , 0 , 0x00, 0x00], + static SC07B := [0 , 0 , 0x00, 0x00], + static SC07E := [0 , 0 , 0x00, 0x00], + static SC11D := [0 , 1 , 0x00, 0x11], + static SC136 := [0 , 0 , 0x00, 0x10], + static SC138 := [0 , 1 , 0x00, 0x12], + static SC145 := [0 , 1 , 0x00, 0x00], + static SC15B := [0 , 1 , 0x00, 0x00], + static SC15C := [0 , 1 , 0x00, 0x00], + static SC15D := [0 , 1 , 0x00, 0x00], + static SC15E := [0 , 1 , 0x00, 0x00], + static SC15F := [0 , 1 , 0x00, 0x00], + static SC163 := [0 , 1 , 0x00, 0x00], + static Break := [0 , 0 , 0x45, 0x00], + static CtrlBreak := [0 , 1 , 0x00, 0x00], + static Delete := [0 , 1 , 0x00, 0x00], + static Down := [0 , 1 , 0x00, 0x00], + static End := [0 , 1 , 0x00, 0x00], + static Home := [0 , 1 , 0x00, 0x00], + static Insert := [0 , 1 , 0x00, 0x00], + static Left := [0 , 1 , 0x00, 0x00], + static Numpad0 := [0 , 0 , 0x00, 0x00], + static Numpad1 := [0 , 0 , 0x00, 0x00], + static Numpad2 := [0 , 0 , 0x00, 0x00], + static Numpad3 := [0 , 0 , 0x00, 0x00], + static Numpad4 := [0 , 0 , 0x00, 0x00], + static Numpad5 := [0 , 0 , 0x00, 0x00], + static Numpad6 := [0 , 0 , 0x00, 0x00], + static Numpad7 := [0 , 0 , 0x00, 0x00], + static Numpad8 := [0 , 0 , 0x00, 0x00], + static Numpad9 := [0 , 0 , 0x00, 0x00], + static NumpadAdd := [0 , 0 , 0x00, 0x00], + static NumpadClear := [0 , 0 , 0x00, 0x00], + static NumpadDel := [0 , 0 , 0x00, 0x00], + static NumpadDiv := [0 , 1 , 0x00, 0x00], + static NumpadDot := [0 , 0 , 0x00, 0x00], + static NumpadDown := [0 , 0 , 0x00, 0x00], + static NumpadEnd := [0 , 0 , 0x00, 0x00], + static NumpadEnter := [0 , 1 , 0x00, 0x00], + static NumpadHome := [0 , 0 , 0x00, 0x00], + static NumpadIns := [0 , 0 , 0x00, 0x00], + static NumpadLeft := [0 , 0 , 0x00, 0x00], + static NumpadMult := [0 , 0 , 0x00, 0x00], + static NumpadPgDn := [0 , 0 , 0x00, 0x00], + static NumpadPgUp := [0 , 0 , 0x00, 0x00], + static NumpadRight := [0 , 0 , 0x00, 0x00], + static NumpadSub := [0 , 0 , 0x00, 0x00], + static NumpadUp := [0 , 0 , 0x00, 0x00], + static Pause := [0 , 0 , 0x45, 0x00], + static PgDn := [0 , 1 , 0x00, 0x00], + static PgUp := [0 , 1 , 0x00, 0x00], + static PrintScreen := [0 , 1 , 0x00, 0x00], + static Right := [0 , 1 , 0x00, 0x00], + static Up := [0 , 1 , 0x00, 0x00] } -For Identifier, None In Keys { - if ("__Class" != Identifier) { - Hotkey, IfWinActive, ahk_group WindowGroup - Hotkey, % "~*" Identifier, ClusterKeyDown - Hotkey, % "~*" Identifier " up", ClusterKeyUp - if (0 == Keys[Identifier][3]) { - Keys[Identifier][3] := GetKeySC(Identifier) - } - if (0 == Keys[Identifier][4]) { - Keys[Identifier][4] := GetKeyVK(Identifier) - } +for k in Keys { + if (k != "__Class") { + Hotkey, IfWinActive, ahk_group WindowGroup + Hotkey, % "~*" k, ClusterKeyDown + Hotkey, % "~*" k " up", ClusterKeyUp + if (Keys[k][3] == 0) { + Keys[k][3] := GetKeySC(k) + } + if (Keys[k][4] == 0) { + Keys[k][4] := GetKeyVK(k) } + } } -AddToCluster(Group := 0) -{ - global AltDown - global Cluster - WinGet, WinActive, ID, A - Cluster[WinActive] := Group - AltDown := 0 +ClusterKeyDown() { + global AltDown + global Cluster + ; Omit unclustered windows + WinGet, WinActive, ID, A + if (Cluster[WinActive] == "") { + Return + } + ; Omit Win + if GetKeyState("LWin"){ + Return + } + ; Prepare post + Identifier := RegExReplace(A_ThisHotkey, "[~*]") + Message := 0x100 ; WM_KEYDOWN + ScanCode := Keys[Identifier][3] + VirtualKey := Keys[Identifier][4] + LParam := 1 | ScanCode << 16 + ; ALT down + if (VirtualKey == 0x12) { + AltDown := 1 + } + ; SYSKEY pressed (ALT pressed or F10) + if (Keys[Identifier][1] or AltDown) { + Message := 0x104 ; WM_SYSKEYDOWN + } + ; ALT pressed + if (AltDown) { + LParam := LParam | 1 << 29 + } + ; Extended flag + if (Keys[Identifier][2]) { + LParam := LParam | 1 << 24 + } + ; Post to clustered windows + for WinClustered, Group in Cluster { + if (WinClustered != WinActive && Group == Cluster[WinActive]) { + PostMessage, Message, VirtualKey, LParam, , ahk_id %WinClustered% + } + } } -AllToCluster() -{ - global Cluster - WinGet AllWindows, List, ahk_group WindowGroup - Loop %AllWindows% { - Cluster[AllWindows%A_Index%] := 0 +ClusterKeyUp() { + global AltDown + global Cluster + ; Omit unclustered windows + WinGet, WinActive, ID, A + if (Cluster[WinActive] == "") { + Return + } + ; Omit Win + if GetKeyState("LWin"){ + Return + } + ; Prepare post + Identifier := RegExReplace(A_ThisHotkey, "[~* up]") + Message := 0x101 ; WM_KEYUP + ScanCode := Keys[Identifier][3] + VirtualKey := Keys[Identifier][4] + LParam := 1 | ScanCode << 16 + LParam := LParam | 1 << 30 + LParam := LParam | 1 << 31 + ; SYSKEY pressed (ALT, ALT pressed or F10) + if (Keys[Identifier][1] or AltDown) { + Message := 0x105 ; WM_SYSKEYUP + } + ; ALT up + if (VirtualKey == 0x12) { + AltDown := 0 + } + ; ALT pressed + if (AltDown) { + LParam := LParam | 1 << 29 + } + ; Extended flag + if (Keys[Identifier][2]) { + LParam := LParam | 1 << 24 + } + ; Post to clustered windows + for WinClustered, Group in Cluster { + if (WinClustered != WinActive && Group == Cluster[WinActive]) { + PostMessage, Message, VirtualKey, LParam, , ahk_id %WinClustered% } + } } -ClusterKeyDown() -{ - global AltDown - global Cluster - ; Omit unclustered windows - WinGet, WinActive, ID, A - if ("" == Cluster[WinActive]) { - return - } - ; Prepare post - Identifier := RegExReplace(A_ThisHotkey, "[~*]") - Message := 0x100 - ScanCode := Keys[Identifier][3] - VirtualKey := Keys[Identifier][4] - LParam := 1 | ScanCode << 16 - ; SYSKEY pressed (ALT, ALT pressed or F10) - if (1 == Keys[Identifier][1] or AltDown) { - Message := 0x104 - } - ; ALT down - if (0x12 == VirtualKey) { - AltDown := 1 - } - ; ALT pressed - if (1 == AltDown) { - LParam := LParam | 1 << 29 - } - ; Extended flag - if (1 == Keys[Identifier][2]) { - LParam := LParam | 1 << 24 - } - ; Post to clustered windows - for WinClustered, Group in Cluster { - if (WinActive != WinClustered && Cluster[WinActive] == Group) { - PostMessage, Message, VirtualKey, LParam, , ahk_id %WinClustered% - } +; get window under mouse +ClusterMouse() { + global Cluster + MouseGetPos, , , WinActive + if (Cluster[WinActive] == "") { + Return + } + for WinClustered, Group in Cluster { + if (WinActive != WinClustered && Cluster[WinActive] == Group) { + ControlClick, , ahk_id %WinClustered%, , RIGHT } + } } -ClusterKeyUp() -{ - global AltDown - global Cluster - ; Omit unclustered windows - WinGet, WinActive, ID, A - if ("" == Cluster[WinActive]) { - return - } - ; Prepare post - Identifier := RegExReplace(A_ThisHotkey, "[~* up]") - Message := 0x101 - ScanCode := Keys[Identifier][3] - VirtualKey := Keys[Identifier][4] - LParam := 1 | ScanCode << 16 - LParam := LParam | 1 << 30 - LParam := LParam | 1 << 31 - ; SYSKEY pressed (ALT, ALT pressed or F10) - if (1 == Keys[Identifier][1] or AltDown) { - Message := 0x105 - } - ; ALT up - if (0x12 == VirtualKey) { - AltDown := 0 +; force paste to all windows +ClusterPaste() { + global Cluster + WinGet, WinActive, ID, A + if (Cluster[WinActive]=="") { + Return + } + for win, grp in Cluster { + if (grp == Cluster[WinActive]) { + ControlClick, , ahk_id %win%, , RIGHT } - ; ALT pressed - if (1 == AltDown) { - LParam := LParam | 1 << 29 - } - ; Extended flag - if (1 == Keys[Identifier][2]) { - LParam := LParam | 1 << 24 + } +} + +AddToCluster(Group := 0) { + global AltDown + global Cluster + WinGet, WinActive, ID, A + Cluster[WinActive] := Group + AltDown := 0 +} + +AllToCluster() { + global Cluster + WinGet AllWindows, List, ahk_group WindowGroup + Loop %AllWindows% { + Cluster[AllWindows%A_Index%] := 0 + } +} + +FocusCluster(Group := 0) { + global Cluster + for WinClustered in Cluster { + if (Cluster[WinClustered] == Group) { + WinActivate ahk_id %WinClustered% } - ; Post to clustered windows + } +} + +RemoveFromCluster() { + global AltDown + global Cluster + WinGet, WinActive, ID, A + Cluster.Remove(WinActive, "") + AltDown := 0 +} + +StopClustering() { + global AltDown, Cluster + + if !Cluster.Length() { + MsgBox, 36, cPuTTY, Do you really want to close cPuTTY? + IfMsgBox, Yes + ExitApp + } + AltDown := 0 + WinGet, WinActive, ID, A + if (Cluster[WinActive] != "") { + SplashTextOn, 300, 70, cPuTTY, % "Clearing group " . Cluster[WinActive] + + Tmp := [] for WinClustered, Group in Cluster { - if (WinActive != WinClustered && Cluster[WinActive] == Group) { - PostMessage, Message, VirtualKey, LParam, , ahk_id %WinClustered% - } + if (Group != Cluster[WinActive]) { + Tmp[WinClustered] := Group + } } + Cluster := Tmp + + Sleep, 1000 + SplashTextOff + Return + } + Cluster := [] } -ClusterMouse() -{ +; How many monitors to use for tiling +TileCluster(usemons := 1) { + ; number of putty windows in all Clusters global Cluster - WinGet, WinActive, ID, A - if ("" == Cluster[WinActive]) { - return + for win in Cluster { + IfWinExist, ahk_id %win% + total++ } - for WinClustered, Group in Cluster { - if (WinActive != WinClustered && Cluster[WinActive] == Group) { - ControlClick, , ahk_id %WinClustered%, , RIGHT + if (total<1) + return + + WM_ENTERSIZEMOVE=0x0231 + WM_EXITSIZEMOVE=0x0232 + ; number of screens to tile on + SysGet, monitors, 80 ;SM_CMONITORS + if (usemons > monitors) + usemons := monitors + + iMax:=1 + iMin:=1 + Loop, %usemons% { + ; windows per this screen + if (A_Index = usemons) + num := total + else { + num := Ceil(total/(usemons - A_Index + 1)) + total -= num } - } -} + rows := Floor(Sqrt(num)) + cols := Ceil(num/rows) -FocusCluster(Group := 0) -{ - global Cluster - for WinClustered, None in Cluster { - if (Cluster[WinClustered] == Group) { - WinActivate ahk_id %WinClustered% + if (usemons = 1) { + SysGet, prim, MonitorPrimary + SysGet, mwa, MonitorWorkArea, %prim% } + else + SysGet, mwa, MonitorWorkArea, %A_Index% + + ; reduced borders for Win10 + if % substr(a_osversion, 1, 2) = 10 + if ((mwaBottom - mwaTop)>1400) { + brd=12 + } else { + brd=4 + } + else + brd=0 + + puttyWidth := (mwaRight - mwaLeft)/cols + 2*brd + puttyHeight := (mwaBottom - mwaTop)/rows + brd + yPos := mwaTop + xPos := mwaLeft - brd + yCount:=0 + i:=1 + iMax+=num + ;MsgBox %A_Index% monitor %xPos%:%yPos% start, %num% windows, %cols%x%rows%, %iMin%-%iMax% + for win in Cluster { + if (i>=iMin and i= rows) { + xPos := xPos + puttyWidth - 2*brd + yPos := mwaTop + yCount := 0 + } + } + IfWinExist, ahk_id %win% + i++ + } + iMin:=iMax } } -RemoveFromCluster() -{ - global AltDown - global Cluster +AutoType(){ + static txt := "" + global Cluster + if (txt) { WinGet, WinActive, ID, A - Cluster.Remove(WinActive, "") - AltDown := 0 + if (Cluster[WinActive] == "" or A_IsSuspended) { + Send, {Raw}%txt% + Send, {enter} + Return + } + SetKeyDelay, -1, 10 + for win, grp in Cluster { + if (Cluster[WinActive] == grp) { + ControlSendRaw, , %txt%, ahk_id %win% + ControlSend, , {enter}, ahk_id %win% + } + } + } + else + InputBox, txt, cPuTTY auto type, , hide, 200, 100 } -StopClustering() -{ - global AltDown - global Cluster - WinGet, WinActive, ID, A - if ("" == Cluster.MaxIndex()) { - MsgBox, 36, cPuTTY, Do you really want to close cPuTTY? - IfMsgBox, Yes - ExitApp +SetTimer, TimerJobs, 1000 +TimerJobs() { + global Cluster, WindowGroup + WinGet wnds, List, ahk_group WindowGroup + + if !wnds { + if Cluster.Length() + Cluster:=[] + Return + } + if !Cluster.Length() and A_IsSuspended + Return + + ; Clean up closed windows from Cluster array + for win in Cluster { + found := 0 + Loop %wnds% { + if (win == wnds%A_Index%) { + found := 1 + } } - AltDown := 0 - if ("" != Cluster[WinActive]) { - Tmp := [] - for WinClustered, Group in Cluster { - if (Cluster[WinActive] != Group) { - Tmp[WinClustered] := Group - } - } - Cluster := Tmp - return + if !found + Cluster.Delete(win) + } + + ; Check each window + WinGet, WinActive, ID, A + GrpActive := Cluster[WinActive] + Loop %wnds% { + win := % wnds%A_Index% + WinGetTitle, Title, ahk_id %win% + ; No group assigned (new window opened or script just restarted) + if !Cluster.HasKey(win) { + if !RegExMatch(Title, "([05-9])(:|>) .*", match, 1) { + ; No current group found. Assign to group 0 + Cluster[win] := 0 + } else { + ; Previous group found. Assign it to previous group + Cluster[win] := match1 + } } - Cluster := [] + ; Fix titles + grp := Cluster[win] + mark := (grp == GrpActive) ? "> " : ": " + if RegExMatch(Title, "[05-9](:|>) (.*)", match, 1) + Title := match2 + else if (A_IsSuspended) + Continue + if (A_IsSuspended) + WinSetTitle, ahk_id %win%, , % Title + else + WinSetTitle, ahk_id %win%, , % grp . mark . Title + } } -$<^